00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "avcodec.h"
00022
00023
00024 static int text2movsub(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,
00025 uint8_t **poutbuf, int *poutbuf_size,
00026 const uint8_t *buf, int buf_size, int keyframe){
00027 if (buf_size > 0xffff) return 0;
00028 *poutbuf_size = buf_size + 2;
00029 *poutbuf = av_malloc(*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE);
00030 AV_WB16(*poutbuf, buf_size);
00031 memcpy(*poutbuf + 2, buf, buf_size);
00032 return 1;
00033 }
00034
00035 AVBitStreamFilter text2movsub_bsf={
00036 "text2movsub",
00037 0,
00038 text2movsub,
00039 };
00040
00041 static int mov2textsub(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,
00042 uint8_t **poutbuf, int *poutbuf_size,
00043 const uint8_t *buf, int buf_size, int keyframe){
00044 if (buf_size < 2) return 0;
00045 *poutbuf_size = FFMIN(buf_size - 2, AV_RB16(buf));
00046 *poutbuf = av_malloc(*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE);
00047 memcpy(*poutbuf, buf + 2, *poutbuf_size);
00048 return 1;
00049 }
00050
00051 AVBitStreamFilter mov2textsub_bsf={
00052 "mov2textsub",
00053 0,
00054 mov2textsub,
00055 };