diff mbox series

[FFmpeg-devel] avcodec/dv_profile: dv files with wrong dsf flag - detect via buf_size

Message ID 9017e9a3-8701-e787-7ec8-b576ed7accab@mark-plomer.de
State New
Headers show
Series [FFmpeg-devel] avcodec/dv_profile: dv files with wrong dsf flag - detect via buf_size
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Mark Plomer Jan. 16, 2021, 1:40 p.m. UTC
Trying to fix https://trac.ffmpeg.org/ticket/8333

Some of my old DV AVI files have the DSF-Flag of frames set to 0, 
although it is PAL (I think they were rendered with Ulead Media Studio 
Pro) ... this causes ffmpeg/VLC-player to produce/play corrupted video.

In other players/editors it works fine including:

- VirtualDub
- Windows Media Player
- AVCutty
- Ulead Media Studio Pro (very old)

I had a look at VirtualDub ... there the PAL/NTSC detection is based on 
the frame rate from AVISTREAMINFO header (dwRate/dwScale) - see 
https://github.com/Pavuucek/VirtualDub/blob/f47ebd2536f0034b048180d0b9cb9bde0ab10c73/src/VirtualDub/source/VideoSource.cpp#L1211

As I don't know, how to access the AVI header info inside 
dvvideo_decode_frame()/ff_dv_frame_profile(), I tried another workaround 
by checking the buf_size against the dv_profile.

It works fine now, but I don't know, if this is really the best solution ...
Subject: [PATCH] avcodec/dv_profile: dv files with wrong dsf flag - detect via
 buf_size

---
 libavcodec/dv_profile.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/dv_profile.c b/libavcodec/dv_profile.c
index 66505c886b..8f9a358032 100644
--- a/libavcodec/dv_profile.c
+++ b/libavcodec/dv_profile.c
@@ -281,6 +281,10 @@  const AVDVProfile* ff_dv_frame_profile(AVCodecContext* codec, const AVDVProfile
        && codec->coded_height==576)
         return &dv_profiles[1];
 
+    /* hack for trac issue #8333, dv files with wrong dsf flag - detect via buf_size */
+    if (dsf == 0 && stype == dv_profiles[1].video_stype && buf_size == dv_profiles[1].frame_size)
+        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];