Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1764)

Unified Diff: patched-ffmpeg-mt/libavcodec/mpeg4video_es_bsf.c

Issue 789004: ffmpeg roll of source to mar 9 version... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « patched-ffmpeg-mt/libavcodec/mpeg4video.h ('k') | patched-ffmpeg-mt/libavcodec/mpeg4video_parser.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: patched-ffmpeg-mt/libavcodec/mpeg4video_es_bsf.c
===================================================================
--- patched-ffmpeg-mt/libavcodec/mpeg4video_es_bsf.c (revision 41250)
+++ patched-ffmpeg-mt/libavcodec/mpeg4video_es_bsf.c (working copy)
@@ -89,3 +89,94 @@
0,
mpeg4video_es_filter,
};
+/*
Lei Zhang 2010/03/19 00:38:33 Oh this is bad merge!
+ * Copyright (c) 2009 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 "mpegvideo.h"
+
+static int mpeg4video_es_filter(AVBitStreamFilterContext *bsfc,
+ AVCodecContext *avctx, const char *args,
+ uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size,
+ int keyframe) {
+ AVCodecParserContext *cpc;
+ ParseContext1 *pc;
+ MpegEncContext *s;
+ int first_picture;
+ int ret;
+ uint8_t *frame_data;
+ int frame_size;
+ int outbuf_idx = 0;
+ int count = 0;
+
+ if (avctx->codec_id != CODEC_ID_MPEG4) {
+ av_log(NULL, AV_LOG_ERROR, "Codec is not MPEG4\n");
+ return -1;
+ }
+
+ if (!bsfc->parser) {
+ bsfc->parser = av_parser_init(CODEC_ID_MPEG4);
+ }
+ cpc = bsfc->parser;
+ pc = cpc->priv_data;
+ s = pc->enc;
+
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ while (buf_size > 0) {
+ first_picture = pc->first_picture;
+ ret = cpc->parser->parser_parse(cpc, avctx, &frame_data, &frame_size, buf, buf_size);
+
+ if (ret < 0)
+ return ret;
+
+ buf_size -= ret;
+ buf += ret;
+
+ // If the first picture is decoded, encode the header.
+ if (first_picture && !pc->first_picture) {
+ assert(!*poutbuf);
+ *poutbuf = av_malloc(1024);
+ *poutbuf_size = 1024;
+ init_put_bits(&s->pb, *poutbuf, 1024);
+ mpeg4_encode_visual_object_header(s);
+ mpeg4_encode_vol_header(s, 0, 0);
+ flush_put_bits(&s->pb);
+ outbuf_idx = (put_bits_count(&s->pb)+7)>>3;
+ }
+
+ if (!frame_size)
+ break;
+
+ *poutbuf = av_fast_realloc(*poutbuf, poutbuf_size, outbuf_idx + frame_size);
+ memcpy(*poutbuf + outbuf_idx, frame_data, frame_size);
+ outbuf_idx += frame_size;
+ }
+
+ *poutbuf_size = outbuf_idx;
+ return 0;
+}
+
+AVBitStreamFilter mpeg4video_es_bsf = {
+ "mpeg4video_es",
+ 0,
+ mpeg4video_es_filter,
+};
« no previous file with comments | « patched-ffmpeg-mt/libavcodec/mpeg4video.h ('k') | patched-ffmpeg-mt/libavcodec/mpeg4video_parser.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698