diff mbox

[FFmpeg-devel,v3] avcodec/hevc_sei: Support HEVC paired fields.

Message ID 1506309191-14269-1-git-send-email-brian.matherly@yahoo.com
State Superseded
Headers show

Commit Message

Brian Matherly Sept. 25, 2017, 3:13 a.m. UTC
From: Brian Matherly <brian.matherly-at-yahoo.com@ffmpeg.org>

Correctly set the interlaced_frame and top_field_first fields when pic_struct
indicates paired fields.
---
 libavcodec/hevc_sei.c             |   4 +-
 tests/fate/hevc.mak               |   6 +-
 tests/ref/fate/hevc-paired-fields | 120 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 127 insertions(+), 3 deletions(-)
 create mode 100644 tests/ref/fate/hevc-paired-fields

Comments

Michael Niedermayer Sept. 27, 2017, 1:38 a.m. UTC | #1
On Sun, Sep 24, 2017 at 10:13:11PM -0500, Brian Matherly wrote:
> From: Brian Matherly <brian.matherly-at-yahoo.com@ffmpeg.org>
> 
> Correctly set the interlaced_frame and top_field_first fields when pic_struct
> indicates paired fields.
> ---
>  libavcodec/hevc_sei.c             |   4 +-
>  tests/fate/hevc.mak               |   6 +-
>  tests/ref/fate/hevc-paired-fields | 120 ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 127 insertions(+), 3 deletions(-)
>  create mode 100644 tests/ref/fate/hevc-paired-fields

the test seems to fail on big endian: (mips qemu)

@@ -14,7 +14,7 @@
 pkt_size=229528
 width=1920
 height=540
-pix_fmt=yuv422p10le
+pix_fmt=yuv422p10be
 sample_aspect_ratio=1:1
 pict_type=I
 coded_picture_number=0
@@ -44,7 +44,7 @@
 pkt_size=95954
 width=1920
 height=540
-pix_fmt=yuv422p10le
+pix_fmt=yuv422p10be
 sample_aspect_ratio=1:1
 pict_type=B
 coded_picture_number=0
@@ -74,7 +74,7 @@
 pkt_size=114837
 width=1920
 height=540
-pix_fmt=yuv422p10le
+pix_fmt=yuv422p10be
 sample_aspect_ratio=1:1
 pict_type=B
 coded_picture_number=0
@@ -104,7 +104,7 @@
 pkt_size=85098
 width=1920
 height=540
-pix_fmt=yuv422p10le
+pix_fmt=yuv422p10be
 sample_aspect_ratio=1:1
 pict_type=B
 coded_picture_number=0

[...]
Brian Matherly Sept. 28, 2017, 1:51 a.m. UTC | #2
On 9/26/2017 8:38 PM, Michael Niedermayer wrote:
> On Sun, Sep 24, 2017 at 10:13:11PM -0500, Brian Matherly wrote:
>> From: Brian Matherly <brian.matherly-at-yahoo.com@ffmpeg.org>
>>
>> Correctly set the interlaced_frame and top_field_first fields when pic_struct
>> indicates paired fields.
>> ---
>>   libavcodec/hevc_sei.c             |   4 +-
>>   tests/fate/hevc.mak               |   6 +-
>>   tests/ref/fate/hevc-paired-fields | 120 ++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 127 insertions(+), 3 deletions(-)
>>   create mode 100644 tests/ref/fate/hevc-paired-fields
> the test seems to fail on big endian: (mips qemu)
>
> @@ -14,7 +14,7 @@
>   pkt_size=229528
>   width=1920
>   height=540
> -pix_fmt=yuv422p10le
> +pix_fmt=yuv422p10be
>   sample_aspect_ratio=1:1
>   pict_type=I
>   coded_picture_number=0
> @@ -44,7 +44,7 @@
>   pkt_size=95954
>   width=1920
>   height=540
> -pix_fmt=yuv422p10le
> +pix_fmt=yuv422p10be
>   sample_aspect_ratio=1:1
>   pict_type=B
>   coded_picture_number=0
> @@ -74,7 +74,7 @@
>   pkt_size=114837
>   width=1920
>   height=540
> -pix_fmt=yuv422p10le
> +pix_fmt=yuv422p10be
>   sample_aspect_ratio=1:1
>   pict_type=B
>   coded_picture_number=0
> @@ -104,7 +104,7 @@
>   pkt_size=85098
>   width=1920
>   height=540
> -pix_fmt=yuv422p10le
> +pix_fmt=yuv422p10be
>   sample_aspect_ratio=1:1
>   pict_type=B
>   coded_picture_number=0
>
> [...]

The pix_fmt is not consequential to the test. In fact, most of the 
fields are not related to the test. Patch V4 reduces the test to only 
the fields relevant to the paired fields feature of the sample.

Thanks,

~Brian
diff mbox

Patch

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index cd55d50..d0f9966 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -137,10 +137,10 @@  static int decode_nal_sei_pic_timing(HEVCSEIContext *s, GetBitContext *gb, const
     if (sps->vui.frame_field_info_present_flag) {
         int pic_struct = get_bits(gb, 4);
         h->picture_struct = AV_PICTURE_STRUCTURE_UNKNOWN;
-        if (pic_struct == 2) {
+        if (pic_struct == 2 || pic_struct == 10 || pic_struct == 12) {
             av_log(logctx, AV_LOG_DEBUG, "BOTTOM Field\n");
             h->picture_struct = AV_PICTURE_STRUCTURE_BOTTOM_FIELD;
-        } else if (pic_struct == 1) {
+        } else if (pic_struct == 1 || pic_struct == 9 || pic_struct == 11) {
             av_log(logctx, AV_LOG_DEBUG, "TOP Field\n");
             h->picture_struct = AV_PICTURE_STRUCTURE_TOP_FIELD;
         }
diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index d23d1ba..8300f50 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -225,6 +225,9 @@  $(foreach N,$(HEVC_SAMPLES_444_12BIT),$(eval $(call FATE_HEVC_TEST_444_12BIT,$(N
 fate-hevc-paramchange-yuv420p-yuv420p10: CMD = framecrc -vsync 0 -i $(TARGET_SAMPLES)/hevc/paramchange_yuv420p_yuv420p10.hevc -sws_flags area+accurate_rnd+bitexact
 FATE_HEVC += fate-hevc-paramchange-yuv420p-yuv420p10
 
+fate-hevc-paired-fields: CMD = probeframes $(TARGET_SAMPLES)/hevc/paired_fields.hevc
+FATE_HEVC_FFPROBE-$(call DEMDEC, HEVC, HEVC) += fate-hevc-paired-fields
+
 tests/data/hevc-mp4.mov: TAG = GEN
 tests/data/hevc-mp4.mov: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
 	$(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
@@ -244,5 +247,6 @@  FATE_HEVC-$(call DEMDEC, MOV, HEVC) += fate-hevc-extradata-reload
 fate-hevc-extradata-reload: CMD = framemd5 -i $(TARGET_SAMPLES)/hevc/extradata-reload-multi-stsd.mov -sws_flags bitexact
 
 FATE_SAMPLES_AVCONV += $(FATE_HEVC-yes)
+FATE_SAMPLES_FFPROBE += $(FATE_HEVC_FFPROBE-yes)
 
-fate-hevc: $(FATE_HEVC-yes)
+fate-hevc: $(FATE_HEVC-yes) $(FATE_HEVC_FFPROBE-yes)
diff --git a/tests/ref/fate/hevc-paired-fields b/tests/ref/fate/hevc-paired-fields
new file mode 100644
index 0000000..53b9cf6
--- /dev/null
+++ b/tests/ref/fate/hevc-paired-fields
@@ -0,0 +1,120 @@ 
+[FRAME]
+media_type=video
+stream_index=0
+key_frame=1
+pkt_pts=N/A
+pkt_pts_time=N/A
+pkt_dts=N/A
+pkt_dts_time=N/A
+best_effort_timestamp=N/A
+best_effort_timestamp_time=N/A
+pkt_duration=20020
+pkt_duration_time=0.016683
+pkt_pos=0
+pkt_size=229528
+width=1920
+height=540
+pix_fmt=yuv422p10le
+sample_aspect_ratio=1:1
+pict_type=I
+coded_picture_number=0
+display_picture_number=0
+interlaced_frame=1
+top_field_first=1
+repeat_pict=0
+color_range=tv
+color_space=unknown
+color_primaries=unknown
+color_transfer=unknown
+chroma_location=unspecified
+[/FRAME]
+[FRAME]
+media_type=video
+stream_index=0
+key_frame=0
+pkt_pts=N/A
+pkt_pts_time=N/A
+pkt_dts=N/A
+pkt_dts_time=N/A
+best_effort_timestamp=N/A
+best_effort_timestamp_time=N/A
+pkt_duration=20020
+pkt_duration_time=0.016683
+pkt_pos=296042
+pkt_size=95954
+width=1920
+height=540
+pix_fmt=yuv422p10le
+sample_aspect_ratio=1:1
+pict_type=B
+coded_picture_number=0
+display_picture_number=0
+interlaced_frame=1
+top_field_first=0
+repeat_pict=0
+color_range=tv
+color_space=unknown
+color_primaries=unknown
+color_transfer=unknown
+chroma_location=unspecified
+[/FRAME]
+[FRAME]
+media_type=video
+stream_index=0
+key_frame=0
+pkt_pts=N/A
+pkt_pts_time=N/A
+pkt_dts=N/A
+pkt_dts_time=N/A
+best_effort_timestamp=N/A
+best_effort_timestamp_time=N/A
+pkt_duration=20020
+pkt_duration_time=0.016683
+pkt_pos=391996
+pkt_size=114837
+width=1920
+height=540
+pix_fmt=yuv422p10le
+sample_aspect_ratio=1:1
+pict_type=B
+coded_picture_number=0
+display_picture_number=0
+interlaced_frame=1
+top_field_first=1
+repeat_pict=0
+color_range=tv
+color_space=unknown
+color_primaries=unknown
+color_transfer=unknown
+chroma_location=unspecified
+[/FRAME]
+[FRAME]
+media_type=video
+stream_index=0
+key_frame=0
+pkt_pts=N/A
+pkt_pts_time=N/A
+pkt_dts=N/A
+pkt_dts_time=N/A
+best_effort_timestamp=N/A
+best_effort_timestamp_time=N/A
+pkt_duration=20020
+pkt_duration_time=0.016683
+pkt_pos=506833
+pkt_size=85098
+width=1920
+height=540
+pix_fmt=yuv422p10le
+sample_aspect_ratio=1:1
+pict_type=B
+coded_picture_number=0
+display_picture_number=0
+interlaced_frame=1
+top_field_first=0
+repeat_pict=0
+color_range=tv
+color_space=unknown
+color_primaries=unknown
+color_transfer=unknown
+chroma_location=unspecified
+[/FRAME]