fixing msmpeg4 decoding if fps < 16 (i thought it was a indicator for the ext header, its the fps indeed)
Originally committed as revision 313 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
81b7c056ee
commit
2b9ab1d54a
@ -214,7 +214,7 @@ static int h263_decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->h263_msmpeg4)
|
if (s->h263_msmpeg4 && s->pict_type==I_TYPE)
|
||||||
if(msmpeg4_decode_ext_header(s, buf_size) < 0) return -1;
|
if(msmpeg4_decode_ext_header(s, buf_size) < 0) return -1;
|
||||||
|
|
||||||
MPV_frame_end(s);
|
MPV_frame_end(s);
|
||||||
|
@ -1128,7 +1128,7 @@ static void encode_picture(MpegEncContext *s, int picture_number)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->h263_msmpeg4)
|
if (s->h263_msmpeg4 && s->pict_type == I_TYPE)
|
||||||
msmpeg4_encode_ext_header(s);
|
msmpeg4_encode_ext_header(s);
|
||||||
|
|
||||||
//if (s->gob_number)
|
//if (s->gob_number)
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "dsputil.h"
|
#include "dsputil.h"
|
||||||
#include "mpegvideo.h"
|
#include "mpegvideo.h"
|
||||||
|
#include "avcodec.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* You can also call this codec : MPEG4 with a twist !
|
* You can also call this codec : MPEG4 with a twist !
|
||||||
@ -212,23 +213,14 @@ void msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
|
|||||||
|
|
||||||
void msmpeg4_encode_ext_header(MpegEncContext * s)
|
void msmpeg4_encode_ext_header(MpegEncContext * s)
|
||||||
{
|
{
|
||||||
if(s->pict_type == P_TYPE)
|
|
||||||
{
|
|
||||||
return; // P-Frames dont seem to have them and not even a 0 bit
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
s->flipflop_rounding=1;
|
s->flipflop_rounding=1;
|
||||||
s->bitrate= 910;
|
s->bitrate= 910; // FIXME
|
||||||
|
|
||||||
put_bits(&s->pb, 1, 1); // ext header indicator
|
put_bits(&s->pb, 5, s->frame_rate / FRAME_RATE_BASE); //yes 29.97 -> 29
|
||||||
|
|
||||||
put_bits(&s->pb, 4, 7); // ?
|
|
||||||
|
|
||||||
put_bits(&s->pb, 11, s->bitrate);
|
put_bits(&s->pb, 11, s->bitrate);
|
||||||
|
|
||||||
put_bits(&s->pb, 1, s->flipflop_rounding);
|
put_bits(&s->pb, 1, s->flipflop_rounding);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* predict coded block */
|
/* predict coded block */
|
||||||
@ -748,33 +740,23 @@ int msmpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
|
|
||||||
int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
|
int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
|
||||||
{
|
{
|
||||||
int firstBit=0;
|
|
||||||
|
|
||||||
/* the alt_bitstream reader could read over the end so we need to check it */
|
/* the alt_bitstream reader could read over the end so we need to check it */
|
||||||
if(get_bits_count(&s->gb) < buf_size*8) firstBit= get_bits1(&s->gb);
|
if(get_bits_count(&s->gb) + 16 < buf_size*8)
|
||||||
|
|
||||||
if(s->pict_type == P_TYPE)
|
|
||||||
{
|
{
|
||||||
if(firstBit) return -1; // havnt seen ext headers in P-Frames yet ;)
|
int fps;
|
||||||
|
|
||||||
|
fps= get_bits(&s->gb, 5);
|
||||||
|
s->bitrate= get_bits(&s->gb, 11);
|
||||||
|
s->flipflop_rounding= get_bits1(&s->gb);
|
||||||
|
|
||||||
|
// printf("fps:%2d bps:%2d roundingType:%1d\n", fps, s->bitrate, s->flipflop_rounding);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int unk;
|
s->flipflop_rounding= 0;
|
||||||
if(!firstBit) // no header found
|
s->bitrate= 0;
|
||||||
{
|
|
||||||
s->flipflop_rounding= 0;
|
|
||||||
s->bitrate= 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unk= get_bits(&s->gb, 4);
|
|
||||||
s->bitrate= get_bits(&s->gb, 11);
|
|
||||||
|
|
||||||
// printf("%2d %4d ;; %1X\n", unk,s->bitrate, unk);
|
|
||||||
|
|
||||||
s->flipflop_rounding= get_bits1(&s->gb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user