Commit 541ae140 authored by Michael Niedermayer's avatar Michael Niedermayer

AVI stream header FCC / more reliable detection of old xvid files

Originally committed as revision 2258 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent cb0c448a
...@@ -15,8 +15,8 @@ extern "C" { ...@@ -15,8 +15,8 @@ extern "C" {
#define LIBAVCODEC_VERSION_INT 0x000408 #define LIBAVCODEC_VERSION_INT 0x000408
#define LIBAVCODEC_VERSION "0.4.8" #define LIBAVCODEC_VERSION "0.4.8"
#define LIBAVCODEC_BUILD 4678 #define LIBAVCODEC_BUILD 4679
#define LIBAVCODEC_BUILD_STR "4678" #define LIBAVCODEC_BUILD_STR "4679"
#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
...@@ -1219,6 +1219,13 @@ typedef struct AVCodecContext { ...@@ -1219,6 +1219,13 @@ typedef struct AVCodecContext {
*/ */
uint16_t *inter_matrix; uint16_t *inter_matrix;
/**
* fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
* this is used to workaround some encoder bugs
* - encoding: unused
* - decoding: set by user, will be converted to upper case by lavc during init
*/
unsigned int stream_codec_tag;
} AVCodecContext; } AVCodecContext;
......
...@@ -482,13 +482,17 @@ retry: ...@@ -482,13 +482,17 @@ retry:
avctx->has_b_frames= !s->low_delay; avctx->has_b_frames= !s->low_delay;
if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){ if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){
if(s->avctx->codec_tag == ff_get_fourcc("XVID") || s->avctx->codec_tag == ff_get_fourcc("XVIX")) if(s->avctx->stream_codec_tag == ff_get_fourcc("XVID") ||
s->avctx->codec_tag == ff_get_fourcc("XVID") || s->avctx->codec_tag == ff_get_fourcc("XVIX"))
s->xvid_build= -1; s->xvid_build= -1;
#if 0
if(s->avctx->codec_tag == ff_get_fourcc("DIVX") && s->vo_type==0 && s->vol_control_parameters==1 if(s->avctx->codec_tag == ff_get_fourcc("DIVX") && s->vo_type==0 && s->vol_control_parameters==1
&& s->padding_bug_score > 0 && s->low_delay) // XVID with modified fourcc && s->padding_bug_score > 0 && s->low_delay) // XVID with modified fourcc
s->xvid_build= -1; s->xvid_build= -1;
#endif
}
if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){
if(s->avctx->codec_tag == ff_get_fourcc("DIVX") && s->vo_type==0 && s->vol_control_parameters==0) if(s->avctx->codec_tag == ff_get_fourcc("DIVX") && s->vo_type==0 && s->vol_control_parameters==0)
s->divx_version= 400; //divx 4 s->divx_version= 400; //divx 4
} }
......
...@@ -371,6 +371,11 @@ int MPV_common_init(MpegEncContext *s) ...@@ -371,6 +371,11 @@ int MPV_common_init(MpegEncContext *s)
+ (toupper((s->avctx->codec_tag>>16)&0xFF)<<16) + (toupper((s->avctx->codec_tag>>16)&0xFF)<<16)
+ (toupper((s->avctx->codec_tag>>24)&0xFF)<<24); + (toupper((s->avctx->codec_tag>>24)&0xFF)<<24);
s->avctx->stream_codec_tag= toupper( s->avctx->stream_codec_tag &0xFF)
+ (toupper((s->avctx->stream_codec_tag>>8 )&0xFF)<<8 )
+ (toupper((s->avctx->stream_codec_tag>>16)&0xFF)<<16)
+ (toupper((s->avctx->stream_codec_tag>>24)&0xFF)<<24);
CHECKED_ALLOCZ(s->allocated_edge_emu_buffer, (s->width+64)*2*17*2); //(width + edge + align)*interlaced*MBsize*tolerance CHECKED_ALLOCZ(s->allocated_edge_emu_buffer, (s->width+64)*2*17*2); //(width + edge + align)*interlaced*MBsize*tolerance
s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*17; s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*17;
...@@ -874,7 +879,7 @@ int MPV_encode_end(AVCodecContext *avctx) ...@@ -874,7 +879,7 @@ int MPV_encode_end(AVCodecContext *avctx)
MPV_common_end(s); MPV_common_end(s);
if (s->out_format == FMT_MJPEG) if (s->out_format == FMT_MJPEG)
mjpeg_close(s); mjpeg_close(s);
av_freep(&avctx->extradata); av_freep(&avctx->extradata);
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment