X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Frv10.c;h=e1e8287d5752753f54aecc34558777cee972af9f;hb=7ca6cc099c7e11413c4e95ca10cc2edbfe1052fd;hp=dbc7b6284710c2dfeaf2ab325fe2ad34f2299ac8;hpb=37921ffde81284f4cc8b69d99d4f39f593c65542;p=ffmpeg diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index dbc7b628471..e1e8287d575 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -3,18 +3,20 @@ * Copyright (c) 2000,2001 Fabrice Bellard. * Copyright (c) 2002-2004 Michael Niedermayer * - * This library is free software; you can redistribute it and/or + * 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 of the License, or (at your option) any later version. + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, + * 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 this library; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -383,8 +385,9 @@ static int rv20_decode_picture_header(MpegEncContext *s) av_log(s->avctx, AV_LOG_DEBUG, "\n"); #endif #if 0 + av_log(s->avctx, AV_LOG_DEBUG, "%3dx%03d/%02Xx%02X ", s->width, s->height, s->width/4, s->height/4); for(i=0; iavctx->extradata_size; i++){ - av_log(s->avctx, AV_LOG_DEBUG, "%2X ", ((uint8_t*)s->avctx->extradata)[i]); + av_log(s->avctx, AV_LOG_DEBUG, "%02X ", ((uint8_t*)s->avctx->extradata)[i]); if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " "); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); @@ -431,17 +434,34 @@ static int rv20_decode_picture_header(MpegEncContext *s) } if(s->avctx->has_b_frames){ - int f=9; - int v= s->avctx->extradata_size >= 4 ? ((uint8_t*)s->avctx->extradata)[1] : 0; + int f, new_w, new_h; + int v= s->avctx->extradata_size >= 4 ? 7&((uint8_t*)s->avctx->extradata)[1] : 0; if (get_bits(&s->gb, 1)){ av_log(s->avctx, AV_LOG_ERROR, "unknown bit3 set\n"); // return -1; } - seq= get_bits(&s->gb, 14)<<1; + seq= get_bits(&s->gb, 13)<<2; + + f= get_bits(&s->gb, av_log2(v)+1); - if(v) - f= get_bits(&s->gb, av_log2(v)); + if(f){ + new_w= 4*((uint8_t*)s->avctx->extradata)[6+2*f]; + new_h= 4*((uint8_t*)s->avctx->extradata)[7+2*f]; + }else{ + new_w= s->width; //FIXME wrong we of course must save the original in the context + new_h= s->height; + } + if(new_w != s->width || new_h != s->height){ + av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h); + if (avcodec_check_dimensions(s->avctx, new_h, new_w) < 0) + return -1; + MPV_common_end(s); + s->width = s->avctx->width = new_w; + s->height = s->avctx->height= new_h; + if (MPV_common_init(s) < 0) + return -1; + } if(s->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, v); @@ -473,6 +493,7 @@ static int rv20_decode_picture_header(MpegEncContext *s) av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible from seeking? skipping current b frame\n"); return FRAME_SKIPPED; } + ff_mpeg4_init_direct_mv(s); } } // printf("%d %d %d %d %d\n", seq, (int)s->time, (int)s->last_non_b_time, s->pp_time, s->pb_time); @@ -515,26 +536,25 @@ static int rv10_decode_init(AVCodecContext *avctx) s->width = avctx->width; s->height = avctx->height; + s->h263_long_vectors= ((uint8_t*)avctx->extradata)[3] & 1; + avctx->sub_id= AV_RB32((uint8_t*)avctx->extradata + 4); + switch(avctx->sub_id){ case 0x10000000: s->rv10_version= 0; - s->h263_long_vectors=0; s->low_delay=1; break; case 0x10002000: s->rv10_version= 3; - s->h263_long_vectors=1; s->low_delay=1; s->obmc=1; break; case 0x10003000: s->rv10_version= 3; - s->h263_long_vectors=1; s->low_delay=1; break; case 0x10003001: s->rv10_version= 3; - s->h263_long_vectors=0; s->low_delay=1; break; case 0x20001000: /* real rv20 decoder fail on this id */ @@ -594,7 +614,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, uint8_t *buf, int buf_size) { MpegEncContext *s = avctx->priv_data; - int mb_count, mb_pos, left; + int mb_count, mb_pos, left, start_mb_x; init_get_bits(&s->gb, buf, buf_size*8); if(s->codec_id ==CODEC_ID_RV10) @@ -639,8 +659,9 @@ static int rv10_decode_packet(AVCodecContext *avctx, if(s->mb_y==0) s->first_slice_line=1; }else{ s->first_slice_line=1; + s->resync_mb_x= s->mb_x; } - s->resync_mb_x= s->mb_x; + start_mb_x= s->mb_x; s->resync_mb_y= s->mb_y; if(s->h263_aic){ s->y_dc_scale_table= @@ -699,7 +720,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, if(ret == SLICE_END) break; } - ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END); + ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END); return buf_size; } @@ -737,7 +758,7 @@ static int rv10_decode_frame(AVCodecContext *avctx, rv10_decode_packet(avctx, buf, buf_size); } - if(s->mb_y>=s->mb_height){ + if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){ ff_er_frame_end(s); MPV_frame_end(s);