Browse code

dvdec: Fix dvsd profile[1] detection. Fixes Ticket159 If someone knows of a cleaner way to detect this, patch is welcome.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/09/02 12:21:25
Showing 3 changed files
... ...
@@ -1072,7 +1072,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
1072 1072
     const uint8_t* vsc_pack;
1073 1073
     int apt, is16_9;
1074 1074
 
1075
-    s->sys = ff_dv_frame_profile(s->sys, buf, buf_size);
1075
+    s->sys = ff_dv_frame_profile2(avctx, s->sys, buf, buf_size);
1076 1076
     if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) {
1077 1077
         av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n");
1078 1078
         return -1; /* NOTE: we only accept several full frames */
... ...
@@ -25,6 +25,7 @@
25 25
  */
26 26
 
27 27
 #include "libavutil/rational.h"
28
+#include "libavutil/intreadwrite.h"
28 29
 #include "avcodec.h"
29 30
 #include "dvdata.h"
30 31
 
... ...
@@ -245,7 +246,7 @@ static const DVprofile dv_profiles[] = {
245 245
     }
246 246
 };
247 247
 
248
-const DVprofile* ff_dv_frame_profile(const DVprofile *sys,
248
+const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys,
249 249
                                   const uint8_t* frame, unsigned buf_size)
250 250
 {
251 251
    int i;
... ...
@@ -259,6 +260,9 @@ const DVprofile* ff_dv_frame_profile(const DVprofile *sys,
259 259
        return &dv_profiles[2];
260 260
    }
261 261
 
262
+   if(codec && codec->codec_tag==AV_RL32("dvsd") &&  codec->width==720 && codec->height==576)
263
+       return &dv_profiles[1];
264
+
262 265
    for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
263 266
        if (dsf == dv_profiles[i].dsf && stype == dv_profiles[i].video_stype)
264 267
            return &dv_profiles[i];
... ...
@@ -270,6 +274,12 @@ const DVprofile* ff_dv_frame_profile(const DVprofile *sys,
270 270
    return NULL;
271 271
 }
272 272
 
273
+const DVprofile* ff_dv_frame_profile(const DVprofile *sys,
274
+                                  const uint8_t* frame, unsigned buf_size)
275
+{
276
+    return ff_dv_frame_profile2(NULL, sys, frame, buf_size);
277
+}
278
+
273 279
 const DVprofile* ff_dv_codec_profile(AVCodecContext* codec)
274 280
 {
275 281
     int i;
... ...
@@ -276,6 +276,8 @@ enum dv_pack_type {
276 276
 
277 277
 const DVprofile* ff_dv_frame_profile(const DVprofile *sys,
278 278
                                   const uint8_t* frame, unsigned buf_size);
279
+const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys,
280
+                                  const uint8_t* frame, unsigned buf_size);
279 281
 const DVprofile* ff_dv_codec_profile(AVCodecContext* codec);
280 282
 
281 283
 static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num,