X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;ds=inline;f=contrib%2Fffmpeg%2FA00-latm.patch;h=f986d590086f4c6adbc8ab147e18e75e8a031f0e;hb=509eb41e44f2e2198fadf9ed8d7c9bc92423a90e;hp=a286f4c1950d20786d3f11a87e209634a53c9641;hpb=9f2cfdb81c9b40ea164bc25daca45c77ebe376a6;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/contrib/ffmpeg/A00-latm.patch b/contrib/ffmpeg/A00-latm.patch index a286f4c1..f986d590 100644 --- a/contrib/ffmpeg/A00-latm.patch +++ b/contrib/ffmpeg/A00-latm.patch @@ -1,28 +1,8 @@ -diff -Naur ffmpeg.orig/libavcodec/Makefile ffmpeg/libavcodec/Makefile ---- ffmpeg.orig/libavcodec/Makefile 2008-12-01 01:40:36.000000000 -0500 -+++ ffmpeg/libavcodec/Makefile 2009-02-21 08:25:13.000000000 -0500 -@@ -338,7 +338,7 @@ - OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o - OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o - OBJS-$(CONFIG_LIBFAAC) += libfaac.o --OBJS-$(CONFIG_LIBFAAD) += libfaad.o -+OBJS-$(CONFIG_LIBFAAD) += libfaad.o latmaac.o - OBJS-$(CONFIG_LIBGSM) += libgsm.o - OBJS-$(CONFIG_LIBMP3LAME) += libmp3lame.o - OBJS-$(CONFIG_LIBSCHROEDINGER_DECODER) += libschroedingerdec.o libschroedinger.o libdirac_libschro.o -@@ -350,7 +350,7 @@ - OBJS-$(CONFIG_LIBXVID) += libxvidff.o libxvid_rc.o - - # parsers --OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o mpeg4audio.o -+OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o mpeg4audio.o latm_parser.o - OBJS-$(CONFIG_AC3_PARSER) += ac3_parser.o ac3tab.o aac_ac3_parser.o - OBJS-$(CONFIG_CAVSVIDEO_PARSER) += cavs_parser.o - OBJS-$(CONFIG_DCA_PARSER) += dca_parser.o -diff -Naur ffmpeg.orig/libavcodec/allcodecs.c ffmpeg/libavcodec/allcodecs.c ---- ffmpeg.orig/libavcodec/allcodecs.c 2008-12-01 01:40:36.000000000 -0500 -+++ ffmpeg/libavcodec/allcodecs.c 2009-02-21 08:25:13.000000000 -0500 -@@ -291,6 +291,7 @@ +Index: libavcodec/allcodecs.c +=================================================================== +--- ffmpeg.orig/libavcodec/allcodecs.c (revision 20594) ++++ ffmpeg/libavcodec/allcodecs.c (working copy) +@@ -314,6 +314,7 @@ REGISTER_ENCDEC (LIBDIRAC, libdirac); REGISTER_ENCODER (LIBFAAC, libfaac); REGISTER_DECODER (LIBFAAD, libfaad); @@ -30,7 +10,7 @@ diff -Naur ffmpeg.orig/libavcodec/allcodecs.c ffmpeg/libavcodec/allcodecs.c REGISTER_ENCDEC (LIBGSM, libgsm); REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms); REGISTER_ENCODER (LIBMP3LAME, libmp3lame); -@@ -303,6 +304,7 @@ +@@ -329,6 +330,7 @@ /* parsers */ REGISTER_PARSER (AAC, aac); @@ -38,10 +18,11 @@ diff -Naur ffmpeg.orig/libavcodec/allcodecs.c ffmpeg/libavcodec/allcodecs.c REGISTER_PARSER (AC3, ac3); REGISTER_PARSER (CAVSVIDEO, cavsvideo); REGISTER_PARSER (DCA, dca); -diff -Naur ffmpeg.orig/libavcodec/avcodec.h ffmpeg/libavcodec/avcodec.h ---- ffmpeg.orig/libavcodec/avcodec.h 2008-12-01 01:40:36.000000000 -0500 -+++ ffmpeg/libavcodec/avcodec.h 2009-02-21 08:25:13.000000000 -0500 -@@ -264,6 +264,7 @@ +Index: libavcodec/avcodec.h +=================================================================== +--- ffmpeg.orig/libavcodec/avcodec.h (revision 20594) ++++ ffmpeg/libavcodec/avcodec.h (working copy) +@@ -276,6 +276,7 @@ CODEC_ID_MP2= 0x15000, CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 CODEC_ID_AAC, @@ -49,141 +30,32 @@ diff -Naur ffmpeg.orig/libavcodec/avcodec.h ffmpeg/libavcodec/avcodec.h CODEC_ID_AC3, CODEC_ID_DTS, CODEC_ID_VORBIS, -diff -Naur ffmpeg.orig/libavcodec/latm_parser.c ffmpeg/libavcodec/latm_parser.c ---- ffmpeg.orig/libavcodec/latm_parser.c 1969-12-31 19:00:00.000000000 -0500 -+++ ffmpeg/libavcodec/latm_parser.c 2009-02-21 08:25:13.000000000 -0500 -@@ -0,0 +1,128 @@ -+/* -+ * LATM parser -+ * Copyright (c) 2008 Paul Kendall -+ * -+ * 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 -+ */ -+ -+/** -+ * @file latm_parser.c -+ * LATM parser -+ */ -+ -+#include "parser.h" -+ -+#define LATM_HEADER 0x56e000 // 0x2b7 (11 bits) -+#define LATM_MASK 0xFFE000 // top 11 bits -+#define LATM_SIZE_MASK 0x001FFF // bottom 13 bits -+ -+typedef struct LATMParseContext{ -+ ParseContext pc; -+ int count; -+} LATMParseContext; -+ -+/** -+ * finds the end of the current frame in the bitstream. -+ * @return the position of the first byte of the next frame, or -1 -+ */ -+static int latm_find_frame_end(AVCodecParserContext *s1, const uint8_t *buf, -+ int buf_size) { -+ LATMParseContext *s = s1->priv_data; -+ ParseContext *pc = &s->pc; -+ int pic_found, i; -+ uint32_t state; -+ -+ pic_found = pc->frame_start_found; -+ state = pc->state; -+ -+ i = 0; -+ if(!pic_found){ -+ for(i=0; icount = - i; -+ pic_found=1; -+ break; -+ } -+ } -+ } -+ -+ if(pic_found){ -+ /* EOF considered as end of frame */ -+ if (buf_size == 0) -+ return 0; -+ if((state & LATM_SIZE_MASK) - s->count <= buf_size) { -+ pc->frame_start_found = 0; -+ pc->state = -1; -+ return (state & LATM_SIZE_MASK) - s->count; -+ } -+ } -+ -+ s->count += buf_size; -+ pc->frame_start_found = pic_found; -+ pc->state = state; -+ return END_NOT_FOUND; -+} -+ -+static int latm_parse(AVCodecParserContext *s1, -+ AVCodecContext *avctx, -+ const uint8_t **poutbuf, int *poutbuf_size, -+ const uint8_t *buf, int buf_size) -+{ -+ LATMParseContext *s = s1->priv_data; -+ ParseContext *pc = &s->pc; -+ int next; -+ -+ if(s1->flags & PARSER_FLAG_COMPLETE_FRAMES){ -+ next = buf_size; -+ }else{ -+ next = latm_find_frame_end(s1, buf, buf_size); -+ -+ if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { -+ *poutbuf = NULL; -+ *poutbuf_size = 0; -+ return buf_size; -+ } -+ } -+ *poutbuf = buf; -+ *poutbuf_size = buf_size; -+ return next; -+} -+ -+static int latm_split(AVCodecContext *avctx, -+ const uint8_t *buf, int buf_size) -+{ -+ int i; -+ uint32_t state= -1; -+ -+ for(i=0; i @@ -217,7 +89,8 @@ diff -Naur ffmpeg.orig/libavcodec/latmaac.c ffmpeg/libavcodec/latmaac.c +#include + +#include "parser.h" -+#include "bitstream.h" ++#include "get_bits.h" ++#include "put_bits.h" +#include "mpeg4audio.h" +#include "neaacdec.h" + @@ -778,13 +651,13 @@ diff -Naur ffmpeg.orig/libavcodec/latmaac.c ffmpeg/libavcodec/latmaac.c + +static int faac_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, -+ uint8_t *buf, int buf_size) ++ AVPacket *avpkt) +{ + FAACContext *s = avctx->priv_data; + int ret; + + if (s->decoder == NULL) faac_decode_init(avctx); -+ ret = aac_filter_receive(s->decoder, data, data_size, buf, buf_size); ++ ret = aac_filter_receive(s->decoder, data, data_size, avpkt->data, avpkt->size); + aac_filter_getinfo(s->decoder, &(avctx->sample_rate), &(avctx->channels)); + return ret; +} @@ -808,11 +681,178 @@ diff -Naur ffmpeg.orig/libavcodec/latmaac.c ffmpeg/libavcodec/latmaac.c + .decode = faac_decode_frame, + .long_name = "AAC over LATM", +}; +Index: libavcodec/latm_parser.c +=================================================================== +--- ffmpeg.orig/libavcodec/latm_parser.c (revision 0) ++++ ffmpeg/libavcodec/latm_parser.c (revision 0) +@@ -0,0 +1,128 @@ ++/* ++ * LATM parser ++ * Copyright (c) 2008 Paul Kendall ++ * ++ * 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 ++ */ ++ ++/** ++ * @file latm_parser.c ++ * LATM parser ++ */ ++ ++#include "parser.h" ++ ++#define LATM_HEADER 0x56e000 // 0x2b7 (11 bits) ++#define LATM_MASK 0xFFE000 // top 11 bits ++#define LATM_SIZE_MASK 0x001FFF // bottom 13 bits ++ ++typedef struct LATMParseContext{ ++ ParseContext pc; ++ int count; ++} LATMParseContext; + -diff -Naur ffmpeg.orig/libavformat/mpeg.c ffmpeg/libavformat/mpeg.c ---- ffmpeg.orig/libavformat/mpeg.c 2008-10-02 12:03:00.000000000 -0400 -+++ ffmpeg/libavformat/mpeg.c 2009-02-21 08:25:13.000000000 -0500 -@@ -281,7 +281,7 @@ ++/** ++ * finds the end of the current frame in the bitstream. ++ * @return the position of the first byte of the next frame, or -1 ++ */ ++static int latm_find_frame_end(AVCodecParserContext *s1, const uint8_t *buf, ++ int buf_size) { ++ LATMParseContext *s = s1->priv_data; ++ ParseContext *pc = &s->pc; ++ int pic_found, i; ++ uint32_t state; ++ ++ pic_found = pc->frame_start_found; ++ state = pc->state; ++ ++ i = 0; ++ if(!pic_found){ ++ for(i=0; icount = - i; ++ pic_found=1; ++ break; ++ } ++ } ++ } ++ ++ if(pic_found){ ++ /* EOF considered as end of frame */ ++ if (buf_size == 0) ++ return 0; ++ if((state & LATM_SIZE_MASK) - s->count <= buf_size) { ++ pc->frame_start_found = 0; ++ pc->state = -1; ++ return (state & LATM_SIZE_MASK) - s->count; ++ } ++ } ++ ++ s->count += buf_size; ++ pc->frame_start_found = pic_found; ++ pc->state = state; ++ return END_NOT_FOUND; ++} ++ ++static int latm_parse(AVCodecParserContext *s1, ++ AVCodecContext *avctx, ++ const uint8_t **poutbuf, int *poutbuf_size, ++ const uint8_t *buf, int buf_size) ++{ ++ LATMParseContext *s = s1->priv_data; ++ ParseContext *pc = &s->pc; ++ int next; ++ ++ if(s1->flags & PARSER_FLAG_COMPLETE_FRAMES){ ++ next = buf_size; ++ }else{ ++ next = latm_find_frame_end(s1, buf, buf_size); ++ ++ if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { ++ *poutbuf = NULL; ++ *poutbuf_size = 0; ++ return buf_size; ++ } ++ } ++ *poutbuf = buf; ++ *poutbuf_size = buf_size; ++ return next; ++} ++ ++static int latm_split(AVCodecContext *avctx, ++ const uint8_t *buf, int buf_size) ++{ ++ int i; ++ uint32_t state= -1; ++ ++ for(i=0; ist && pes->stream->nb_streams == MAX_STREAMS) || + (pes->st && pes->st->discard == AVDISCARD_ALL) || +- code == 0x1be) /* padding_stream */ ++ code == 0x1be || code == 0x1fa) /* padding_stream */ + goto skip; + + /* stream not present in PMT */ +Index: libavformat/mpegts.h +=================================================================== +--- ffmpeg.orig/libavformat/mpegts.h (revision 20594) ++++ ffmpeg/libavformat/mpegts.h (working copy) +@@ -49,6 +49,7 @@ + #define STREAM_TYPE_PRIVATE_DATA 0x06 + #define STREAM_TYPE_AUDIO_AAC 0x0f + #define STREAM_TYPE_VIDEO_MPEG4 0x10 ++#define STREAM_TYPE_AUDIO_AAC_LATM 0x11 + #define STREAM_TYPE_VIDEO_H264 0x1b + #define STREAM_TYPE_VIDEO_VC1 0xea + #define STREAM_TYPE_VIDEO_DIRAC 0xd1 +Index: libavformat/mpeg.c +=================================================================== +--- ffmpeg.orig/libavformat/mpeg.c (revision 20594) ++++ ffmpeg/libavformat/mpeg.c (working copy) +@@ -282,7 +282,7 @@ /* find matching stream */ if (!((startcode >= 0x1c0 && startcode <= 0x1df) || (startcode >= 0x1e0 && startcode <= 0x1ef) || @@ -821,7 +861,7 @@ diff -Naur ffmpeg.orig/libavformat/mpeg.c ffmpeg/libavformat/mpeg.c goto redo; if (ppos) { *ppos = url_ftell(s->pb) - 4; -@@ -441,6 +441,9 @@ +@@ -449,6 +449,9 @@ } else if(es_type == STREAM_TYPE_AUDIO_AAC){ codec_id = CODEC_ID_AAC; type = CODEC_TYPE_AUDIO; @@ -831,9 +871,10 @@ diff -Naur ffmpeg.orig/libavformat/mpeg.c ffmpeg/libavformat/mpeg.c } else if(es_type == STREAM_TYPE_VIDEO_MPEG4){ codec_id = CODEC_ID_MPEG4; type = CODEC_TYPE_VIDEO; -diff -Naur ffmpeg.orig/libavformat/mpeg.h ffmpeg/libavformat/mpeg.h ---- ffmpeg.orig/libavformat/mpeg.h 2008-08-31 03:39:47.000000000 -0400 -+++ ffmpeg/libavformat/mpeg.h 2009-02-21 08:25:13.000000000 -0500 +Index: libavformat/mpeg.h +=================================================================== +--- ffmpeg.orig/libavformat/mpeg.h (revision 20594) ++++ ffmpeg/libavformat/mpeg.h (working copy) @@ -53,6 +53,7 @@ #define STREAM_TYPE_PRIVATE_DATA 0x06 #define STREAM_TYPE_AUDIO_AAC 0x0f @@ -842,45 +883,3 @@ diff -Naur ffmpeg.orig/libavformat/mpeg.h ffmpeg/libavformat/mpeg.h #define STREAM_TYPE_VIDEO_H264 0x1b #define STREAM_TYPE_AUDIO_AC3 0x81 -diff -Naur ffmpeg.orig/libavformat/mpegts.c ffmpeg/libavformat/mpegts.c ---- ffmpeg.orig/libavformat/mpegts.c 2008-10-02 12:28:58.000000000 -0400 -+++ ffmpeg/libavformat/mpegts.c 2009-02-21 08:25:13.000000000 -0500 -@@ -625,6 +625,7 @@ - case STREAM_TYPE_VIDEO_VC1: - case STREAM_TYPE_VIDEO_DIRAC: - case STREAM_TYPE_AUDIO_AAC: -+ case STREAM_TYPE_AUDIO_AAC_LATM: - case STREAM_TYPE_AUDIO_AC3: - case STREAM_TYPE_AUDIO_DTS: - case STREAM_TYPE_AUDIO_HDMV_DTS: -@@ -847,7 +848,7 @@ - code = pes->header[3] | 0x100; - if (!((code >= 0x1c0 && code <= 0x1df) || - (code >= 0x1e0 && code <= 0x1ef) || -- (code == 0x1bd) || (code == 0x1fd))) -+ (code == 0x1bd) || (code == 0x1fa) || (code == 0x1fd))) - goto skip; - if (!pes->st) { - /* allocate stream */ -@@ -968,6 +969,10 @@ - codec_type = CODEC_TYPE_AUDIO; - codec_id = CODEC_ID_AAC; - break; -+ case STREAM_TYPE_AUDIO_AAC_LATM: -+ codec_type = CODEC_TYPE_AUDIO; -+ codec_id = CODEC_ID_AAC_LATM; -+ break; - case STREAM_TYPE_AUDIO_AC3: - codec_type = CODEC_TYPE_AUDIO; - codec_id = CODEC_ID_AC3; -diff -Naur ffmpeg.orig/libavformat/mpegts.h ffmpeg/libavformat/mpegts.h ---- ffmpeg.orig/libavformat/mpegts.h 2008-08-31 03:39:47.000000000 -0400 -+++ ffmpeg/libavformat/mpegts.h 2009-02-21 08:25:13.000000000 -0500 -@@ -50,6 +50,7 @@ - #define STREAM_TYPE_PRIVATE_DATA 0x06 - #define STREAM_TYPE_AUDIO_AAC 0x0f - #define STREAM_TYPE_VIDEO_MPEG4 0x10 -+#define STREAM_TYPE_AUDIO_AAC_LATM 0x11 - #define STREAM_TYPE_VIDEO_H264 0x1b - #define STREAM_TYPE_VIDEO_VC1 0xea - #define STREAM_TYPE_VIDEO_DIRAC 0xd1