diff options
Diffstat (limited to 'libavcodec/dv_profile.c')
-rw-r--r-- | libavcodec/dv_profile.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/libavcodec/dv_profile.c b/libavcodec/dv_profile.c index 8b604c2ecb..4264098912 100644 --- a/libavcodec/dv_profile.c +++ b/libavcodec/dv_profile.c @@ -18,6 +18,7 @@ #include <stdint.h> +#include "libavutil/intreadwrite.h" #include "libavutil/log.h" #include "libavutil/pixdesc.h" #include "avcodec.h" @@ -279,22 +280,26 @@ static const DVprofile dv_profiles[] = { } }; -const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, +const DVprofile* avpriv_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, const uint8_t* frame, unsigned buf_size) { int i, dsf, stype; - if (buf_size < 80 * 5 + 48 + 4) + if(buf_size < DV_PROFILE_BYTES) return NULL; dsf = (frame[3] & 0x80) >> 7; stype = frame[80 * 5 + 48 + 3] & 0x1f; /* 576i50 25Mbps 4:1:1 is a special case */ - if (dsf == 1 && stype == 0 && frame[4] & 0x07 /* the APT field */) { + if ((dsf == 1 && stype == 0 && frame[4] & 0x07 /* the APT field */) || + (stype == 31 && codec && codec->codec_tag==AV_RL32("SL25") && codec->coded_width==720 && codec->coded_height==576)) { return &dv_profiles[2]; } + if(stype == 0 && codec && codec->codec_tag==AV_RL32("dvsd") && codec->coded_width==720 && codec->coded_height==576) + return &dv_profiles[1]; + for (i = 0; i < FF_ARRAY_ELEMS(dv_profiles); i++) if (dsf == dv_profiles[i].dsf && stype == dv_profiles[i].video_stype) return &dv_profiles[i]; @@ -303,17 +308,36 @@ const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, if (sys && buf_size == sys->frame_size) return sys; + /* hack for trac issue #217, dv files created with QuickTime 3 */ + if ((frame[3] & 0x7f) == 0x3f && frame[80 * 5 + 48 + 3] == 0xff) + return &dv_profiles[dsf]; + return NULL; } +const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, + const uint8_t* frame, unsigned buf_size) +{ + return avpriv_dv_frame_profile2(NULL, sys, frame, buf_size); +} + const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec) { int i; + int w, h; + + if (codec->coded_width || codec->coded_height) { + w = codec->coded_width; + h = codec->coded_height; + } else { + w = codec->width; + h = codec->height; + } for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++) - if (codec->height == dv_profiles[i].height && + if (h == dv_profiles[i].height && codec->pix_fmt == dv_profiles[i].pix_fmt && - codec->width == dv_profiles[i].width) + w == dv_profiles[i].width) return &dv_profiles[i]; return NULL; |