Index: patches/to_upstream/05_vc1_bsfs.patch |
=================================================================== |
--- patches/to_upstream/05_vc1_bsfs.patch (revision 41250) |
+++ patches/to_upstream/05_vc1_bsfs.patch (working copy) |
@@ -1,8 +1,42 @@ |
-Index: patched-ffmpeg-mt/libavcodec/allcodecs.c |
-=================================================================== |
---- patched-ffmpeg-mt/libavcodec/allcodecs.c (revision 39951) |
-+++ patched-ffmpeg-mt/libavcodec/allcodecs.c (working copy) |
-@@ -382,9 +382,10 @@ |
+Only in unpatched_ffmpeg-mt: ffmpeg-mt |
+diff -rpu unpatched_ffmpeg-mt/libavcodec/Makefile ffmpeg-mt/libavcodec/Makefile |
+--- unpatched_ffmpeg-mt/libavcodec/Makefile 2010-03-11 17:46:30 -0800 |
++++ ffmpeg-mt/libavcodec/Makefile 2010-03-11 19:12:19 -0800 |
+@@ -564,6 +564,14 @@ OBJS-$(CONFIG_VP3_PARSER) + |
+ OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o |
+ OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o |
+ OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF) += h264_mp4toannexb_bsf.o |
++OBJS-$(CONFIG_MPEG4VIDEO_ES_BSF) += mpeg4video_es_bsf.o \ |
++ mpeg4videoenc.o ituh263enc.o \ |
++ mpegvideo_enc.o motion_est.o \ |
++ ratecontrol.o mpeg12data.o \ |
++ aandcttab.o jfdctfst.o \ |
++ jfdctint.o faandct.o \ |
++ mpeg4video_parser.o mpegvideo.o \ |
++ error_resilience.o |
+ OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF) += imx_dump_header_bsf.o |
+ OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += mjpega_dump_header_bsf.o |
+ OBJS-$(CONFIG_MOV2TEXTSUB_BSF) += movsub_bsf.o |
+@@ -573,6 +581,9 @@ OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF) |
+ OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o |
+ OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o |
+ OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o |
++OBJS-$(CONFIG_VC1_ASFTORCV_BSF) += vc1_asftorcv_bsf.o |
++OBJS-$(CONFIG_VC1_ASFTOANNEXG_BSF) += vc1_asftoannexg_bsf.o vc1.o \ |
++ vc1data.o |
+ |
+ # thread libraries |
+ OBJS-$(HAVE_BEOSTHREADS) += beosthread.o |
+Only in ffmpeg-mt/libavcodec: Makefile~ |
+diff -rpu unpatched_ffmpeg-mt/libavcodec/allcodecs.c ffmpeg-mt/libavcodec/allcodecs.c |
+--- unpatched_ffmpeg-mt/libavcodec/allcodecs.c 2010-03-11 17:46:29 -0800 |
++++ ffmpeg-mt/libavcodec/allcodecs.c 2010-03-11 19:12:19 -0800 |
+@@ -384,13 +384,15 @@ void avcodec_register_all(void) |
+ REGISTER_BSF (AAC_ADTSTOASC, aac_adtstoasc); |
+ REGISTER_BSF (DUMP_EXTRADATA, dump_extradata); |
+ REGISTER_BSF (H264_MP4TOANNEXB, h264_mp4toannexb); |
++ REGISTER_BSF (MPEG4VIDEO_ES, mpeg4video_es); |
+ REGISTER_BSF (IMX_DUMP_HEADER, imx_dump_header); |
REGISTER_BSF (MJPEGA_DUMP_HEADER, mjpega_dump_header); |
REGISTER_BSF (MP3_HEADER_COMPRESS, mp3_header_compress); |
REGISTER_BSF (MP3_HEADER_DECOMPRESS, mp3_header_decompress); |
@@ -14,297 +48,64 @@ |
REGISTER_BSF (TEXT2MOVSUB, text2movsub); |
} |
- |
-Index: patched-ffmpeg-mt/libavcodec/vc1_asftorcv_bsf.c |
-=================================================================== |
---- patched-ffmpeg-mt/libavcodec/vc1_asftorcv_bsf.c (revision 0) |
-+++ patched-ffmpeg-mt/libavcodec/vc1_asftorcv_bsf.c (revision 0) |
-@@ -0,0 +1,88 @@ |
-+/* |
-+ * copyright (c) 2010 Google Inc. |
-+ * |
-+ * This file is part of FFmpeg. |
-+ * |
-+ * FFmpeg is free software; you can redistribute it and/or |
-+ * modify it under the terms of the GNU Lesser General Public |
-+ * License as published by the Free Software Foundation; either |
-+ * version 2.1 of the License, or (at your option) any later version. |
-+ * |
-+ * FFmpeg is distributed in the hope that it will be useful, |
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
-+ * Lesser General Public License for more details. |
-+ * |
-+ * You should have received a copy of the GNU Lesser General Public |
-+ * License along with FFmpeg; if not, write to the Free Software |
-+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
-+ */ |
-+ |
-+#include "avcodec.h" |
-+#include "bytestream.h" |
-+ |
-+#define RCV_STREAM_HEADER_SIZE 36 |
-+#define RCV_PICTURE_HEADER_SIZE 8 |
-+ |
-+typedef struct ASFTORCVBSFContext { |
-+ int frames; |
-+} ASFTORCVBSFContext; |
-+ |
-+static int asftorcv_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, |
-+ uint8_t **poutbuf, int *poutbuf_size, |
-+ const uint8_t *buf, int buf_size, int keyframe){ |
-+ ASFTORCVBSFContext* ctx = (ASFTORCVBSFContext*)bsfc->priv_data; |
-+ |
-+ if (avctx->codec_id != CODEC_ID_WMV3) { |
-+ av_log(avctx, AV_LOG_ERROR, "Only WMV3 is accepted!\n"); |
-+ return -1; |
-+ } |
-+ |
-+ uint8_t* bs = NULL; |
-+ if (!ctx->frames) { |
-+ // Write the header if this is the first frame. |
-+ *poutbuf = av_malloc(RCV_STREAM_HEADER_SIZE + RCV_PICTURE_HEADER_SIZE + buf_size); |
-+ *poutbuf_size = RCV_STREAM_HEADER_SIZE + RCV_PICTURE_HEADER_SIZE + buf_size; |
-+ bs = *poutbuf; |
-+ |
-+ // The following structure of stream header comes from libavformat/vc1testenc.c. |
-+ bytestream_put_le24(&bs, 0); // Frame count. 0 for streaming. |
-+ bytestream_put_byte(&bs, 0xC5); |
-+ bytestream_put_le32(&bs, 4); // 4 bytes of extra data. |
-+ bytestream_put_byte(&bs, avctx->extradata[0]); |
-+ bytestream_put_byte(&bs, avctx->extradata[1]); |
-+ bytestream_put_byte(&bs, avctx->extradata[2]); |
-+ bytestream_put_byte(&bs, avctx->extradata[3]); |
-+ bytestream_put_le32(&bs, avctx->height); |
-+ bytestream_put_le32(&bs, avctx->width); |
-+ bytestream_put_le32(&bs, 0xC); |
-+ bytestream_put_le24(&bs, 0); // hrd_buffer |
-+ bytestream_put_byte(&bs, 0x80); // level|cbr|res1 |
-+ bytestream_put_le32(&bs, 0); // hrd_rate |
-+ |
-+ // The following LE32 describes the frame rate. Since we don't care so fill |
-+ // it with 0xFFFFFFFF which means variable framerate. |
-+ // See: libavformat/vc1testenc.c |
-+ bytestream_put_le32(&bs, 0xFFFFFFFF); |
-+ } else { |
-+ *poutbuf = av_malloc(RCV_PICTURE_HEADER_SIZE + buf_size); |
-+ *poutbuf_size = RCV_PICTURE_HEADER_SIZE + buf_size; |
-+ bs = *poutbuf; |
-+ } |
-+ |
-+ // Write the picture header. |
-+ bytestream_put_le32(&bs, buf_size | (keyframe ? 0x80000000 : 0)); |
-+ |
-+ // The following LE32 describes the pts. Since we don't care so fill it with 0. |
-+ bytestream_put_le32(&bs, 0); |
-+ memcpy(bs, buf, buf_size); |
-+ |
-+ ++ctx->frames; |
-+ return 0; |
-+} |
-+ |
-+AVBitStreamFilter vc1_asftorcv_bsf = { |
-+ "vc1_asftorcv", |
-+ sizeof(ASFTORCVBSFContext), |
-+ asftorcv_filter, |
-+}; |
-Index: patched-ffmpeg-mt/libavcodec/vc1_asftoannexg_bsf.c |
-=================================================================== |
---- patched-ffmpeg-mt/libavcodec/vc1_asftoannexg_bsf.c (revision 0) |
-+++ patched-ffmpeg-mt/libavcodec/vc1_asftoannexg_bsf.c (revision 0) |
-@@ -0,0 +1,182 @@ |
-+/* |
-+ * copyright (c) 2010 Google Inc. |
-+ * |
-+ * This file is part of FFmpeg. |
-+ * |
-+ * FFmpeg is free software; you can redistribute it and/or |
-+ * modify it under the terms of the GNU Lesser General Public |
-+ * License as published by the Free Software Foundation; either |
-+ * version 2.1 of the License, or (at your option) any later version. |
-+ * |
-+ * FFmpeg is distributed in the hope that it will be useful, |
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
-+ * Lesser General Public License for more details. |
-+ * |
-+ * You should have received a copy of the GNU Lesser General Public |
-+ * License along with FFmpeg; if not, write to the Free Software |
-+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
-+ */ |
-+ |
-+#include "avcodec.h" |
-+#include "bytestream.h" |
-+#include "vc1.h" |
-+ |
-+// An arbitrary limit in bytes greater than the current bytes used. |
-+#define MAX_SEQ_HEADER_SIZE 50 |
-+ |
-+typedef struct ASFTOANNEXGBSFContext { |
-+ int frames; |
-+ uint8_t *seq_header; |
-+ int seq_header_size; |
-+ uint8_t *ep_header; |
-+ int ep_header_size; |
-+} ASFTOANNEXGBSFContext; |
-+ |
-+static int generate_sequence_header(VC1Context *v, ASFTOANNEXGBSFContext *ctx) |
-+{ |
-+ PutBitContext pb; |
-+ ctx->seq_header = av_mallocz(MAX_SEQ_HEADER_SIZE); |
-+ init_put_bits(&pb, ctx->seq_header, MAX_SEQ_HEADER_SIZE); |
-+ |
-+ put_bits(&pb, 32, VC1_CODE_SEQHDR); // start code |
-+ put_bits(&pb, 2, PROFILE_ADVANCED); // profile |
-+ put_bits(&pb, 3, v->level); // level |
-+ put_bits(&pb, 2, v->chromaformat); // chromaformat |
-+ put_bits(&pb, 3, v->frmrtq_postproc); // frmrtq postproc |
-+ put_bits(&pb, 5, v->bitrtq_postproc); // bitrtq postproc |
-+ put_bits(&pb, 1, v->postprocflag); // post proc flag |
-+ put_bits(&pb, 12, (v->s.avctx->coded_width >> 1) - 1); // codec width |
-+ put_bits(&pb, 12, (v->s.avctx->coded_height >> 1) - 1); // codec height |
-+ put_bits(&pb, 1, v->broadcast); // broadcast |
-+ put_bits(&pb, 1, v->interlace); // interlace |
-+ put_bits(&pb, 1, v->tfcntrflag); // tfcntrflag |
-+ put_bits(&pb, 1, v->finterpflag); // finterpflag |
-+ put_bits(&pb, 1, 1); // reserved |
-+ put_bits(&pb, 1, v->psf); // progressive segmented frame mode |
-+ put_bits(&pb, 1, 1); // has display info |
-+ put_bits(&pb, 14, v->s.avctx->width - 1); // width |
-+ put_bits(&pb, 14, v->s.avctx->height - 1); // height |
-+ put_bits(&pb, 1, 0); // no aspect ratio |
-+ put_bits(&pb, 1, 1); // frame rate |
-+ put_bits(&pb, 8, 3); // fake it to be 30fps, see vc1.c and vc1data.c |
-+ put_bits(&pb, 4, 1); // fake dr to be 1000, see vc1.c and vc1data.c |
-+ put_bits(&pb, 1, 0); // no color info |
-+ put_bits(&pb, 1, 0); // no hrd param |
-+ |
-+ align_put_bits(&pb); |
-+ ctx->seq_header_size = (put_bits_count(&pb) + 7) >> 3; |
-+ return 0; |
-+} |
-+ |
-+static int decode_sequence_header(AVCodecContext *avctx, VC1Context *v, uint8_t *header, int header_size) { |
-+ GetBitContext gb; |
-+ uint8_t *buf = av_mallocz(header_size + FF_INPUT_BUFFER_PADDING_SIZE); |
-+ int buf_size = vc1_unescape_buffer(header + 4, header_size - 4, buf); |
-+ int ret; |
-+ init_get_bits(&gb, buf, buf_size * 8); |
-+ ret = vc1_decode_sequence_header(avctx, v, &gb); |
-+ av_free(buf); |
-+ return ret; |
-+} |
-+ |
-+static int parse_extradata(AVCodecContext *avctx, ASFTOANNEXGBSFContext *ctx, uint8_t *extradata, int extradata_size) { |
-+ const uint8_t *start = extradata; |
-+ const uint8_t *end = extradata + extradata_size; |
-+ const uint8_t *next; |
-+ VC1Context vc1ctx; |
-+ int size; |
-+ int seq_ret; |
-+ |
-+ if(extradata_size < 16) { |
-+ av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", extradata_size); |
-+ return -1; |
-+ } |
-+ |
-+ start = find_next_marker(start, end); |
-+ next = start; |
-+ for(; next < end; start = next){ |
-+ next = find_next_marker(start + 4, end); |
-+ size = next - start; |
-+ if(size <= 0) continue; |
-+ switch(AV_RB32(start)){ |
-+ case VC1_CODE_SEQHDR: |
-+ memset(&vc1ctx, 0, sizeof(VC1Context)); |
-+ vc1ctx.profile = PROFILE_ADVANCED; |
-+ vc1ctx.s.avctx = avctx; |
-+ |
-+ seq_ret = decode_sequence_header(avctx, &vc1ctx, start, size) < 0 || |
-+ generate_sequence_header(&vc1ctx, ctx) < 0; |
-+ if (seq_ret) { |
-+ av_log(avctx, AV_LOG_ERROR, "Cannot regenerate sequence header\n"); |
-+ return -1; |
-+ } |
-+ break; |
-+ case VC1_CODE_ENTRYPOINT: |
-+ ctx->ep_header = av_malloc(size); |
-+ ctx->ep_header_size = size; |
-+ memcpy(ctx->ep_header, start, size); |
-+ break; |
-+ default: |
-+ break; |
-+ } |
-+ } |
-+ |
-+ if(!ctx->seq_header || !ctx->ep_header) { |
-+ av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n"); |
-+ return -1; |
-+ } |
-+ return 0; |
-+} |
-+ |
-+static int asftoannexg_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, |
-+ uint8_t **poutbuf, int *poutbuf_size, |
-+ const uint8_t *buf, int buf_size, int keyframe){ |
-+ ASFTOANNEXGBSFContext* ctx = (ASFTOANNEXGBSFContext*)bsfc->priv_data; |
-+ |
-+ if (avctx->codec_id != CODEC_ID_VC1) { |
-+ av_log(avctx, AV_LOG_ERROR, "Only VC1 Advanced profile is accepted!\n"); |
-+ return -1; |
-+ } |
-+ |
-+ if (!ctx->frames && parse_extradata(avctx, ctx, avctx->extradata, avctx->extradata_size) < 0) { |
-+ av_log(avctx, AV_LOG_ERROR, "Cannot parse extra data!\n"); |
-+ return -1; |
-+ } |
-+ |
-+ uint8_t* bs; |
-+ if (keyframe) { |
-+ // If this is the keyframe, need to put sequence header and entry point header. |
-+ *poutbuf_size = ctx->seq_header_size + ctx->ep_header_size + 4 + buf_size; |
-+ *poutbuf = av_malloc(*poutbuf_size); |
-+ bs = *poutbuf; |
-+ |
-+ memcpy(bs, ctx->seq_header, ctx->seq_header_size); |
-+ bs += ctx->seq_header_size; |
-+ memcpy(bs, ctx->ep_header, ctx->ep_header_size); |
-+ bs += ctx->ep_header_size; |
-+ } else { |
-+ *poutbuf_size = 4 + buf_size; |
-+ *poutbuf = av_malloc(*poutbuf_size); |
-+ bs = *poutbuf; |
-+ } |
-+ |
-+ // Put the frame start code and frame data. |
-+ bytestream_put_be32(&bs, VC1_CODE_FRAME); |
-+ memcpy(bs, buf, buf_size); |
-+ ++ctx->frames; |
-+ return 0; |
-+} |
-+ |
-+static void asftoannexg_close(AVBitStreamFilterContext *bsfc) { |
-+ ASFTOANNEXGBSFContext *ctx = bsfc->priv_data; |
-+ av_freep(&ctx->seq_header); |
-+ av_freep(&ctx->ep_header); |
-+} |
-+ |
-+AVBitStreamFilter vc1_asftoannexg_bsf = { |
-+ "vc1_asftoannexg", |
-+ sizeof(ASFTOANNEXGBSFContext), |
-+ asftoannexg_filter, |
-+ asftoannexg_close, |
-+}; |
-Index: patched-ffmpeg-mt/libavcodec/Makefile |
-=================================================================== |
---- patched-ffmpeg-mt/libavcodec/Makefile (revision 39951) |
-+++ patched-ffmpeg-mt/libavcodec/Makefile (working copy) |
-@@ -536,6 +536,9 @@ |
- OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o |
- OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o |
- OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o |
-+OBJS-$(CONFIG_VC1_ASFTORCV_BSF) += vc1_asftorcv_bsf.o |
-+OBJS-$(CONFIG_VC1_ASFTOANNEXG_BSF) += vc1_asftoannexg_bsf.o vc1.o \ |
-+ vc1data.o |
+Only in ffmpeg-mt/libavcodec: allcodecs.c~ |
+diff -rpu unpatched_ffmpeg-mt/libavcodec/mpeg4video.h ffmpeg-mt/libavcodec/mpeg4video.h |
+--- unpatched_ffmpeg-mt/libavcodec/mpeg4video.h 2010-03-11 17:46:30 -0800 |
++++ ffmpeg-mt/libavcodec/mpeg4video.h 2010-03-11 19:12:02 -0800 |
+@@ -91,6 +91,9 @@ void mpeg4_encode_mb(MpegEncContext *s, |
+ void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n, |
+ int dir); |
+ void ff_set_mpeg4_time(MpegEncContext * s); |
++void mpeg4_encode_gop_header(MpegEncContext * s); |
++void mpeg4_encode_visual_object_header(MpegEncContext * s); |
++void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number); |
+ void mpeg4_encode_picture_header(MpegEncContext *s, int picture_number); |
- # thread libraries |
- OBJS-$(HAVE_BEOSTHREADS) += beosthread.o |
+ int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb); |
+Only in ffmpeg-mt/libavcodec: mpeg4video.h~ |
+Only in ffmpeg-mt/libavcodec: mpeg4video_es_bsf.c |
+diff -rpu unpatched_ffmpeg-mt/libavcodec/mpeg4videoenc.c ffmpeg-mt/libavcodec/mpeg4videoenc.c |
+--- unpatched_ffmpeg-mt/libavcodec/mpeg4videoenc.c 2010-03-11 17:46:30 -0800 |
++++ ffmpeg-mt/libavcodec/mpeg4videoenc.c 2010-03-11 19:12:02 -0800 |
+@@ -872,7 +872,7 @@ void ff_set_mpeg4_time(MpegEncContext * |
+ } |
+ } |
+ |
+-static void mpeg4_encode_gop_header(MpegEncContext * s){ |
++void mpeg4_encode_gop_header(MpegEncContext * s){ |
+ int hours, minutes, seconds; |
+ int64_t time; |
+ |
+@@ -902,7 +902,7 @@ static void mpeg4_encode_gop_header(Mpeg |
+ ff_mpeg4_stuffing(&s->pb); |
+ } |
+ |
+-static void mpeg4_encode_visual_object_header(MpegEncContext * s){ |
++void mpeg4_encode_visual_object_header(MpegEncContext * s){ |
+ int profile_and_level_indication; |
+ int vo_ver_id; |
+ |
+@@ -947,7 +947,7 @@ static void mpeg4_encode_visual_object_h |
+ ff_mpeg4_stuffing(&s->pb); |
+ } |
+ |
+-static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number) |
++void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number) |
+ { |
+ int vo_ver_id; |
+ |
+Only in ffmpeg-mt/libavcodec: vc1_asftoannexg_bsf.c |
+Only in ffmpeg-mt/libavcodec: vc1_asftorcv_bsf.c |
+diff -rpu unpatched_ffmpeg-mt/libavformat/mov.c ffmpeg-mt/libavformat/mov.c |
+--- unpatched_ffmpeg-mt/libavformat/mov.c 2010-03-11 17:46:31 -0800 |
++++ ffmpeg-mt/libavformat/mov.c 2010-03-11 19:08:40 -0800 |
+@@ -312,6 +312,8 @@ static int mov_read_dref(MOVContext *c, |
+ MOVDref *dref = &sc->drefs[i]; |
+ uint32_t size = get_be32(pb); |
+ int64_t next = url_ftell(pb) + size - 4; |
++ if (size < 8) |
++ return -1; |
+ |
+ dref->type = get_le32(pb); |
+ get_be32(pb); // version + flags |
+Only in ffmpeg-mt/libavformat: mov.c~ |