1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

next try at fixing rv20 decoding

Originally committed as revision 3728 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2004-12-05 23:21:39 +00:00
parent 20b02bc628
commit 423962dc01
2 changed files with 40 additions and 15 deletions

View File

@ -350,6 +350,13 @@ static int rv20_decode_picture_header(MpegEncContext *s)
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
#endif
#if 0
for(i=0; i<s->avctx->extradata_size; i++){
av_log(s->avctx, AV_LOG_DEBUG, "%2X ", ((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");
#endif
if(s->avctx->sub_id == 0x30202002 || s->avctx->sub_id == 0x30203002){
if (get_bits(&s->gb, 3)){
@ -396,18 +403,21 @@ static int rv20_decode_picture_header(MpegEncContext *s)
// av_log(s->avctx, AV_LOG_ERROR, "unknown bit3 set\n");
// return -1;
}
seq= get_bits(&s->gb, 15);
if (s->avctx->sub_id == 0x20201002 && 0 && get_bits(&s->gb, 1)){
av_log(s->avctx, AV_LOG_ERROR, "unknown bit4 set\n");
// return -1;
seq= get_bits(&s->gb, 14)<<1;
if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&1){
get_bits(&s->gb, 1);
}
if(s->avctx->sub_id == 0x20201002){
mb_pos= ff_h263_decode_mba(s);
}else{
mb_pos= get_bits(&s->gb, av_log2(s->mb_num-1)+1);
s->mb_x= mb_pos % s->mb_width;
s->mb_y= mb_pos / s->mb_width;
if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&2){
get_bits(&s->gb, 1);
}
if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&4){
get_bits(&s->gb, 2);
}
mb_pos= get_bits(&s->gb, av_log2(s->mb_num-1)+1);
s->mb_x= mb_pos % s->mb_width;
s->mb_y= mb_pos / s->mb_width;
}else{
seq= get_bits(&s->gb, 8)*128;
mb_pos= ff_h263_decode_mba(s);
@ -508,7 +518,11 @@ static int rv10_decode_init(AVCodecContext *avctx)
default:
av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", avctx->sub_id);
}
//av_log(avctx, AV_LOG_DEBUG, "ver:%X\n", avctx->sub_id);
if(avctx->debug & FF_DEBUG_PICT_INFO){
av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", avctx->sub_id, avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1);
}
if (MPV_common_init(s) < 0)
return -1;

View File

@ -634,6 +634,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* ra type header */
rm_read_audio_stream_info(s, st, 0);
} else {
int fps, fps2;
if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
fail1:
av_log(&st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
@ -647,14 +648,24 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec.width = get_be16(pb);
st->codec.height = get_be16(pb);
st->codec.frame_rate_base= 1;
st->codec.frame_rate = get_be16(pb) * st->codec.frame_rate_base;
fps= get_be16(pb);
st->codec.codec_type = CODEC_TYPE_VIDEO;
get_be32(pb);
fps2= get_be16(pb);
get_be16(pb);
get_be32(pb);
get_be16(pb);
st->codec.extradata_size= codec_data_size - (url_ftell(pb) - codec_pos);
st->codec.extradata= av_malloc(st->codec.extradata_size);
get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
// av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
st->codec.frame_rate = fps * st->codec.frame_rate_base;
/* modification of h263 codec version (!) */
h263_hack_version = get_be32(pb);
#ifdef WORDS_BIGENDIAN
h263_hack_version = ((uint32_t*)st->codec.extradata)[1];
#else
h263_hack_version = bswap_32(((uint32_t*)st->codec.extradata)[1]);
#endif
st->codec.sub_id = h263_hack_version;
if((h263_hack_version>>28)==1)
st->codec.codec_id = CODEC_ID_RV10;