X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmpeg4videodec.c;h=8ed85319cb071dfd6590291a6ced551c9ab0ad20;hb=3fd3632ffeb18aeca6c0ab3fbe1034c3da75d983;hp=7dadf7e99ada7300ab778584a4d186afe3b98f25;hpb=b317567cf437a515acf75abee2a3bb7a6b047938;p=ffmpeg diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 7dadf7e99ad..8ed85319cb0 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3,20 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard * Copyright (c) 2002-2010 Michael Niedermayer * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -435,7 +435,7 @@ int mpeg4_decode_video_packet_header(MpegEncContext *s) /** * gets the average motion vector for a GMC MB. * @param n either 0 for the x component or 1 for y - * @returns the average MV for a GMC MB + * @return the average MV for a GMC MB */ static inline int get_amv(MpegEncContext *s, int n){ int x, y, mb_v, sum, dx, dy, shift; @@ -1023,12 +1023,7 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block, if(last) i+=192; } else { /* second escape */ -#if MIN_CACHE_BITS < 20 - LAST_SKIP_BITS(re, &s->gb, 2); - UPDATE_CACHE(re, &s->gb); -#else SKIP_BITS(re, &s->gb, 2); -#endif GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1); i+= run + rl->max_run[run>>7][level/qmul] +1; //FIXME opt indexing level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); @@ -1036,12 +1031,7 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block, } } else { /* first escape */ -#if MIN_CACHE_BITS < 19 - LAST_SKIP_BITS(re, &s->gb, 1); - UPDATE_CACHE(re, &s->gb); -#else SKIP_BITS(re, &s->gb, 1); -#endif GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1); i+= run; level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing @@ -1504,16 +1494,17 @@ end: static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){ int hours, minutes, seconds; - - hours= get_bits(gb, 5); - minutes= get_bits(gb, 6); - skip_bits1(gb); - seconds= get_bits(gb, 6); - - s->time_base= seconds + 60*(minutes + 60*hours); - - skip_bits1(gb); - skip_bits1(gb); + unsigned time_code = show_bits(gb, 18); + + if (time_code & 0x40) { /* marker_bit */ + hours = time_code >> 13; + minutes = time_code >> 7 & 0x3f; + seconds = time_code & 0x3f; + s->time_base = seconds + 60*(minutes + 60*hours); + skip_bits(gb, 20); /* time_code, closed_gov, broken_link */ + } else { + av_log(s->avctx, AV_LOG_WARNING, "GOP header missing marker_bit\n"); + } return 0; } @@ -1575,6 +1566,7 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){ s->avctx->time_base.den = get_bits(gb, 16); if(!s->avctx->time_base.den){ av_log(s->avctx, AV_LOG_ERROR, "time_base.den==0\n"); + s->avctx->time_base.num = 0; return -1; } @@ -2080,7 +2072,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){ /* detect buggy encoders which don't set the low_delay flag (divx4/xvid/opendivx)*/ // note we cannot detect divx5 without b-frames easily (although it's buggy too) if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==-1 && s->picture_number==0){ - av_log(s->avctx, AV_LOG_ERROR, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n"); + av_log(s->avctx, AV_LOG_WARNING, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n"); s->low_delay=1; } @@ -2119,7 +2111,7 @@ int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb) for(;;) { if(get_bits_count(gb) >= gb->size_in_bits){ if(gb->size_in_bits==8 && (s->divx_version>=0 || s->xvid_build>=0)){ - av_log(s->avctx, AV_LOG_ERROR, "frame skip %d\n", gb->size_in_bits); + av_log(s->avctx, AV_LOG_WARNING, "frame skip %d\n", gb->size_in_bits); return FRAME_SKIPPED; //divx bug }else return -1; //end of stream @@ -2234,9 +2226,9 @@ static av_cold int decode_init(AVCodecContext *avctx) return 0; } -AVCodec mpeg4_decoder = { +AVCodec ff_mpeg4_decoder = { "mpeg4", - CODEC_TYPE_VIDEO, + AVMEDIA_TYPE_VIDEO, CODEC_ID_MPEG4, sizeof(MpegEncContext), decode_init, @@ -2245,15 +2237,16 @@ AVCodec mpeg4_decoder = { ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, .flush= ff_mpeg_flush, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), .pix_fmts= ff_hwaccel_pixfmt_list_420, }; #if CONFIG_MPEG4_VDPAU_DECODER -AVCodec mpeg4_vdpau_decoder = { +AVCodec ff_mpeg4_vdpau_decoder = { "mpeg4_vdpau", - CODEC_TYPE_VIDEO, + AVMEDIA_TYPE_VIDEO, CODEC_ID_MPEG4, sizeof(MpegEncContext), decode_init,