Re: [FFmpeg-devel] [PATCH] Add A53 Closed Captions to MPEG header if they are available.

2017-06-06 Thread Brian Matherly



Indeed, multiple entries of the same type are really a bad idea and we
basically made them impossible with stream sidedata, although maybe
not with frame side data yet. We should not add API for them or
encourage their use.
If there is a real need for multiple of the same type, maybe the type
should be expanded to hold more information.



The cc_count is only 5 bits, which mean that only 31 3-byte "closed caption
constructs" will fit in a "block".Testing this with 1080i60 material, I
found that 2 or 3 blocks was often necessary to hold all of the CC data.

I tried ignoring that limit of 31 "constructs" per block, and ended up with
corrupt captions.   By preserving the 2 or 3 separate blocks I observed
from the original source, the captions are perfect.

According to CEA-708, in the case of 1080i60, the correct number for 
cc_count is 10. The highest number that cc_count is allowed to be is 30 
in the case of repeating a frame three times for film mode. Exceeding 
the correct cc_count for the frame rate would cause the CC channel data 
rate to exceed 9,600bps.


~Brian
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add A53 Closed Captions to MPEG header if they are available.

2017-06-15 Thread Brian Matherly



Indeed, multiple entries of the same type are really a bad idea and we
basically made them impossible with stream sidedata, although maybe
not with frame side data yet. We should not add API for them or
encourage their use.
If there is a real need for multiple of the same type, maybe the type
should be expanded to hold more information.



The cc_count is only 5 bits, which mean that only 31 3-byte "closed caption
constructs" will fit in a "block".Testing this with 1080i60 material, I
found that 2 or 3 blocks was often necessary to hold all of the CC data.

I tried ignoring that limit of 31 "constructs" per block, and ended up with
corrupt captions.   By preserving the 2 or 3 separate blocks I observed
from the original source, the captions are perfect.

According to CEA-708, in the case of 1080i60, the correct number for 
cc_count is 10. The highest number that cc_count is allowed to be is 30 
in the case of repeating a frame three times for film mode. Exceeding 
the correct cc_count for the frame rate would cause the CC channel data 
rate to exceed 9,600bps.


~Brian
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/scpr: optimize shift loop.

2017-09-09 Thread Brian Matherly


On 9/9/2017 1:27 PM, Michael Niedermayer wrote:

+// If the image is sufficiently aligned, compute 8 samples at once
+if (!(((uintptr_t)dst) & 7)) {
+uint64_t *dst64 = (uint64_t *)dst;
+int w = avctx->width>>1;
+for (x = 0; x < w; x++) {
+dst64[x] = (dst64[x] << 3) & 0xFCFCFCFCFCFCFCFCULL;
+}
+x *= 8;
+} else
+x = 0;
+for (; x < avctx->width * 4; x++) {
  dst[x] = dst[x] << 3;
  }


Forgive me if I'm not understanding the code correctly, but couldn't you 
always apply the optimization if you align the first (up to) 7 samples?


Pseudocode:

uint64_t *dst64 = (uint64_t *)dst;
int w = avctx->width>>1;
x=0
// compute un-aligned beginning samples
for (; x < (avctx->width * 4) && (((uintptr_t)dst) & 7); x++) {
dst[x] = dst[x] << 3;
}
// compute aligned samples
for (; x < w; x+=8) {
dst64[x] = (dst64[x] << 3) & 0xFCFCFCFCFCFCFCFCULL;
}
x -= 8;
// compute un-aligned ending samples
for (; x < avctx->width * 4; x++) {
dst[x] = dst[x] << 3;
}
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2017-09-14 Thread Brian Matherly
Correctly set frame.interlaced and frame.top_field_first when pic_struct
indicates paired fields.
---
 libavcodec/hevc_sei.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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;
 }
-- 
2.7.4


.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/hevc_sei: Support HEVC paired fields.

2017-09-21 Thread Brian Matherly


On 9/14/2017 8:39 PM, Brian Matherly wrote:

Correctly set frame.interlaced and frame.top_field_first when pic_struct
indicates paired fields.
---
  libavcodec/hevc_sei.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

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;
  }


Ping.

I think this should be an obvious change. If you look at table D.2 in 
Rec. ITU-T H.265, these four values are for fields.


~Brian

.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2] avcodec/hevc_sei: Support HEVC paired fields.

2017-09-24 Thread Brian Matherly
From: Brian Matherly 

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   |   3 +
 tests/ref/fate/hevc-paired-fields | 120 ++
 3 files changed, 125 insertions(+), 2 deletions(-)
 create mode 100644 tests/ref/fate/hevc-paired-fields

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..a763170 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 += 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)/$< \
diff --git a/tests/ref/fate/hevc-paired-fields 
b/tests/ref/fate/hevc-paired-fields
new file mode 100644
index 000..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]
-- 
2.7.4


.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2] avcodec/hevc_sei: Support HEVC paired fields.

2017-09-24 Thread Brian Matherly
From: Brian Matherly 

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   |   3 +
 tests/ref/fate/hevc-paired-fields | 120 ++
 3 files changed, 125 insertions(+), 2 deletions(-)
 create mode 100644 tests/ref/fate/hevc-paired-fields

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..a763170 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 += 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)/$< \
diff --git a/tests/ref/fate/hevc-paired-fields 
b/tests/ref/fate/hevc-paired-fields
new file mode 100644
index 000..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]
-- 
2.7.4


.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/hevc_sei: Support HEVC paired fields.

2017-09-24 Thread Brian Matherly

On 9/23/2017 5:22 PM, Michael Niedermayer wrote:

On Thu, Sep 14, 2017 at 08:39:19PM -0500, Brian Matherly wrote:

Correctly set frame.interlaced and frame.top_field_first when pic_struct
indicates paired fields.

Do you have a (small) sample that gets fixed by this ?

Can you make a fate test for this case ?

[...]



Thanks Michael,

I submitted a V2 patch (sorry about the double e-mail). V2 includes a 
fate test which uses probeframes. The reason I test probeframes is 
because the pixel data in the frame is exactly the same with/wo the 
patch - and the important part of the test is the value of the 
interlaced_frame and repeat_first_field fields.


The sample file is uploaded to the videolan uploader: paired_fields.hevc
It should be placed in: fate-suite/hevc/paired_fields.hevc

Thanks,

~Brian

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2017-09-24 Thread Brian Matherly
From: Brian Matherly 

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

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 000..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]
-- 
2.7.4


.
___

[FFmpeg-devel] [PATCH v4] avcodec/hevc_sei: Support HEVC paired fields.

2017-09-27 Thread Brian Matherly
From: Brian Matherly 

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 | 16 
 3 files changed, 23 insertions(+), 3 deletions(-)
 create mode 100644 tests/ref/fate/hevc-paired-fields

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..140fa2a 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 -show_entries 
frame=interlaced_frame,top_field_first $(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 000..f2223e7
--- /dev/null
+++ b/tests/ref/fate/hevc-paired-fields
@@ -0,0 +1,16 @@
+[FRAME]
+interlaced_frame=1
+top_field_first=1
+[/FRAME]
+[FRAME]
+interlaced_frame=1
+top_field_first=0
+[/FRAME]
+[FRAME]
+interlaced_frame=1
+top_field_first=1
+[/FRAME]
+[FRAME]
+interlaced_frame=1
+top_field_first=0
+[/FRAME]
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2017-09-27 Thread Brian Matherly


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 

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
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavfilter: constify filter list

2018-02-01 Thread Brian Matherly

On 2/1/2018 4:03 AM, Nicolas George wrote:

Regarding the efficiency of avfilter_next(), I think we should not care.
Almost nobody uses that function outside lavfi anyway. If it proves a
concern for some application, we can deal with it when it is found.


For what it's worth, I use avfilter_next() on startup in MLT to generate 
a list of valid user options:


https://github.com/mltframework/mlt/blob/master/src/modules/avformat/factory.c#L415

I would prefer some way to loop through the filters in linear time.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Add "split" mode to tinterlace filter.

2015-03-28 Thread Brian Matherly
From: Brian Matherly 

This mode is the opposite of the "merge" mode.
---
This patch adds a new mode to tinterlace which performs the opposite operation 
as the "merge" mode. 

My primary motivation is that I have been working with Derek Buitenhuis to see 
about adding interlace support to the libx265 encoder. It turns out that this is
a complex situation since libx265 requires each field to be encoded separately 
but ffmpeg stores fields together as an interlaced frame. tinterlace can be used
with this new mode to provide each field as a separate frame to libx265 - and 
therefore perform valid interlaced h.265 encoding.

At first I considered this patch a hack and planned on keeping it to myself. But
now I think that it must be generally useful since it can produce the exact 
format of data that would be the input to the tinterlace "merge" mode.
As a test, I have checked: 
ffmpeg -i input.file -vf "tinterlace=split,tinterlace=merge" output.file
And the image makes a successful round trip.
 doc/filters.texi| 24 
 libavfilter/tinterlace.h|  1 +
 libavfilter/vf_tinterlace.c | 43 +--
 3 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 15f8ed5..9b3fd02 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9197,6 +9197,30 @@ Output:
  1   1   2   2   3   3   4
 @end example
 
+@item split, 7
+Perform the inverse operation as merge. Move upper field to odd frames, lower
+field to even frames, generating a half height frame at double frame rate.
+@example
+ --> time
+Input:
+Frame 1 Frame 2
+1   3
+2   4
+1   3
+2   4
+1   3
+2   4
+1   3
+2   4
+
+Output:
+Frame 1 Frame 2 Frame 3 Frame 4
+1   2   3   4
+1   2   3   4
+1   2   3   4
+1   2   3   4
+@end example
+
 
 @end table
 
diff --git a/libavfilter/tinterlace.h b/libavfilter/tinterlace.h
index fa0a83a..ece8ce4 100644
--- a/libavfilter/tinterlace.h
+++ b/libavfilter/tinterlace.h
@@ -38,6 +38,7 @@ enum TInterlaceMode {
 MODE_INTERLEAVE_TOP,
 MODE_INTERLEAVE_BOTTOM,
 MODE_INTERLACEX2,
+MODE_SPLIT,
 MODE_NB,
 };
 
diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c
index f3411f9..2c9047b 100644
--- a/libavfilter/vf_tinterlace.c
+++ b/libavfilter/vf_tinterlace.c
@@ -46,6 +46,7 @@ static const AVOption tinterlace_options[] = {
 {"interleave_top","interleave top and bottom fields", 0, 
AV_OPT_TYPE_CONST, {.i64=MODE_INTERLEAVE_TOP},INT_MIN, INT_MAX, FLAGS, 
"mode"},
 {"interleave_bottom", "interleave bottom and top fields", 0, 
AV_OPT_TYPE_CONST, {.i64=MODE_INTERLEAVE_BOTTOM}, INT_MIN, INT_MAX, FLAGS, 
"mode"},
 {"interlacex2",   "interlace fields from two consecutive frames", 0, 
AV_OPT_TYPE_CONST, {.i64=MODE_INTERLACEX2},   INT_MIN, INT_MAX, FLAGS, 
"mode"},
+{"split", "split fields", 0, 
AV_OPT_TYPE_CONST, {.i64=MODE_SPLIT}, INT_MIN, INT_MAX, FLAGS, 
"mode"},
 
 {"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 
= 0}, 0, INT_MAX, 0, "flags" },
 {"low_pass_filter",   "enable vertical low-pass filter",  0, 
AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_VLPF}, INT_MIN, INT_MAX, FLAGS, 
"flags" },
@@ -118,7 +119,8 @@ static int config_out_props(AVFilterLink *outlink)
 outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP;
 outlink->w = inlink->w;
 outlink->h = tinterlace->mode == MODE_MERGE || tinterlace->mode == 
MODE_PAD ?
-inlink->h*2 : inlink->h;
+inlink->h*2 : tinterlace->mode == MODE_SPLIT ?
+inlink->h/2 : inlink->h;
 
 if (tinterlace->mode == MODE_PAD) {
 uint8_t black[4] = { 16, 128, 128, 16 };
@@ -145,7 +147,7 @@ static int config_out_props(AVFilterLink *outlink)
 tinterlace->flags &= ~TINTERLACE_FLAG_VLPF;
 }
 tinterlace->preout_time_base = inlink->time_base;
-if (tinterlace->mode == MODE_INTERLACEX2) {
+if (tinterlace->mode == MODE_INTERLACEX2 || tinterlace->mode == 
MODE_SPLIT) {
 tinterlace->preout_time_base.den *= 2;
 outlink->frame_rate = av_mul_q(inlink->

Re: [FFmpeg-devel] [PATCH] Add "split" mode to tinterlace filter.

2015-03-28 Thread Brian Matherly
>> This mode is the opposite of the "merge" mode.
>> ---
>> This patch adds a new mode to tinterlace which performs the opposite
operation
>> as the "merge" mode.
>>
>> My primary motivation is that I have been working with Derek Buitenhuis
to see
>> about adding interlace support to the libx265 encoder. It turns out that
this is
>> a complex situation since libx265 requires each field to be encoded
separately
>> but ffmpeg stores fields together as an interlaced frame. tinterlace can
be used
>> with this new mode to provide each field as a separate frame to libx265 -
and
>> therefore perform valid interlaced h.265 encoding.
>>
>> At first I considered this patch a hack and planned on keeping it to
myself. But
>> now I think that it must be generally useful since it can produce the
exact
>> format of data that would be the input to the tinterlace "merge" mode.
>> As a test, I have checked:
>>    ffmpeg -i input.file -vf "tinterlace=split,tinterlace=merge"
output.file
>> And the image makes a successful round trip.
>
>What about separatefields filter?

Yes. That would appear to do the same thing.
I will go test it and see if it works for my scenario.
I tentatively withdrawl my patch.

~Brian

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel