[FFmpeg-devel] [PATCH v1 01/13] lavc/hevc_ps: remove profile limitation of pps_range_extensions()

2022-12-01 Thread Fei Wang
Follow spec 7.3.2.3.1.

Signed-off-by: Fei Wang 
---
 libavcodec/hevc_ps.c |  2 +-
 tests/ref/fate/hevc-conformance-PS_A_VIDYO_3 | 50 ++--
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index f665d8053c..b7ba24a72d 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1715,7 +1715,7 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, 
AVCodecContext *avctx,
 if (get_bits1(gb)) { // pps_extension_present_flag
 pps->pps_range_extensions_flag = get_bits1(gb);
 skip_bits(gb, 7); // pps_extension_7bits
-if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && 
pps->pps_range_extensions_flag) {
+if (pps->pps_range_extensions_flag) {
 if ((ret = pps_range_extensions(gb, avctx, pps, sps)) < 0)
 goto err;
 }
diff --git a/tests/ref/fate/hevc-conformance-PS_A_VIDYO_3 
b/tests/ref/fate/hevc-conformance-PS_A_VIDYO_3
index 59b82b72bb..d1d86b2dc9 100644
--- a/tests/ref/fate/hevc-conformance-PS_A_VIDYO_3
+++ b/tests/ref/fate/hevc-conformance-PS_A_VIDYO_3
@@ -3,28 +3,28 @@
 #codec_id 0: rawvideo
 #dimensions 0: 416x240
 #sar 0: 0/1
-0,  0,  0,1,   149760, 0x88619f80
-0,  1,  1,1,   149760, 0x550bdaf0
-0,  2,  2,1,   149760, 0x4121f7a2
-0,  3,  3,1,   149760, 0x210b1d07
-0,  4,  4,1,   149760, 0x731b7758
-0,  5,  5,1,   149760, 0x17adb789
-0,  6,  6,1,   149760, 0x98b2f080
-0,  7,  7,1,   149760, 0xc0be1f2a
-0,  8,  8,1,   149760, 0xc01e387a
-0,  9,  9,1,   149760, 0xd932822b
-0, 10, 10,1,   149760, 0x16c0a1df
-0, 11, 11,1,   149760, 0x5aa6c005
-0, 12, 12,1,   149760, 0xd3aab602
-0, 13, 13,1,   149760, 0x4e6ecab1
-0, 14, 14,1,   149760, 0x8a86f1f2
-0, 15, 15,1,   149760, 0x2ed21e1b
-0, 16, 16,1,   149760, 0x80892f24
-0, 17, 17,1,   149760, 0xb8a952ef
-0, 18, 18,1,   149760, 0x557e57fb
-0, 19, 19,1,   149760, 0x2b825b2c
-0, 20, 20,1,   149760, 0x30b69b5e
-0, 21, 21,1,   149760, 0x802ebf08
-0, 22, 22,1,   149760, 0x95aadc8e
-0, 23, 23,1,   149760, 0x4d4c02b7
-0, 24, 24,1,   149760, 0x3fdd1762
+0,  0,  0,1,   149760, 0x5c4f70f4
+0,  1,  1,1,   149760, 0xf4628e59
+0,  2,  2,1,   149760, 0xa28e5bdc
+0,  3,  3,1,   149760, 0xda0e53d7
+0,  4,  4,1,   149760, 0x42dd334a
+0,  5,  5,1,   149760, 0x25ba9dfe
+0,  6,  6,1,   149760, 0x8854d8ca
+0,  7,  7,1,   149760, 0xc04505d4
+0,  8,  8,1,   149760, 0xd3fce146
+0,  9,  9,1,   149760, 0x8bfd88bd
+0, 10, 10,1,   149760, 0x33d965b2
+0, 11, 11,1,   149760, 0x12746b7a
+0, 12, 12,1,   149760, 0xb7642694
+0, 13, 13,1,   149760, 0x32b5035f
+0, 14, 14,1,   149760, 0x7bea0af1
+0, 15, 15,1,   149760, 0x577d4fc8
+0, 16, 16,1,   149760, 0x023a9c66
+0, 17, 17,1,   149760, 0x9abe76c4
+0, 18, 18,1,   149760, 0x2b14dba5
+0, 19, 19,1,   149760, 0x7b8affcf
+0, 20, 20,1,   149760, 0x21e4c323
+0, 21, 21,1,   149760, 0xf0b7d9cd
+0, 22, 22,1,   149760, 0x4db0c5bc
+0, 23, 23,1,   149760, 0xf455f752
+0, 24, 24,1,   149760, 0x569fec99
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 02/13] lavc/avcodec: Add HEVC Screen Content Coding Extensions profile

2022-12-01 Thread Fei Wang
From: Linjie Fu 

Described in HEVC spec A.3.7.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/avcodec.h  | 1 +
 libavcodec/hevc_ps.c  | 2 ++
 libavcodec/profiles.c | 1 +
 3 files changed, 4 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3edd8e2636..79fad674df 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1639,6 +1639,7 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_HEVC_MAIN_10 2
 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
 #define FF_PROFILE_HEVC_REXT4
+#define FF_PROFILE_HEVC_SCC 9
 
 #define FF_PROFILE_VVC_MAIN_10  1
 #define FF_PROFILE_VVC_MAIN_10_444 33
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index b7ba24a72d..3052f58779 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -278,6 +278,8 @@ static int decode_profile_tier_level(GetBitContext *gb, 
AVCodecContext *avctx,
 av_log(avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n");
 else if (ptl->profile_idc == FF_PROFILE_HEVC_REXT)
 av_log(avctx, AV_LOG_DEBUG, "Range Extension profile bitstream\n");
+else if (ptl->profile_idc == FF_PROFILE_HEVC_SCC)
+av_log(avctx, AV_LOG_DEBUG, "Screen Content Coding Extension profile 
bitstream\n");
 else
 av_log(avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", 
ptl->profile_idc);
 
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..2230fc5415 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -85,6 +85,7 @@ const AVProfile ff_hevc_profiles[] = {
 { FF_PROFILE_HEVC_MAIN_10,  "Main 10" },
 { FF_PROFILE_HEVC_MAIN_STILL_PICTURE,   "Main Still Picture"  },
 { FF_PROFILE_HEVC_REXT, "Rext"},
+{ FF_PROFILE_HEVC_SCC,  "Scc" },
 { FF_PROFILE_UNKNOWN },
 };
 
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 03/13] lavc/hevc_ps: Add SPS/PPS parse support for HEVC extension syntax

2022-12-01 Thread Fei Wang
From: Linjie Fu 

1. Add extension syntax according to 7.3.2.2.3/7.3.2.3.3 in T-REC-H.265-201911.
2. Keep using parsed PPS when bitstream overread for compatibility. For
example, the clip PS_A_VIDYO_3.bit in FATE test has incomplete extension
syntax which will be overread and un-decodable if without this change.
3. Format brace in pps_range_extensions().

Signed-off-by: Linjie Fu 
Signed-off-by: Haihao Xiang 
Signed-off-by: Fei Wang 
---
 libavcodec/hevc.h|   3 +
 libavcodec/hevc_ps.c | 293 +--
 libavcodec/hevc_ps.h |  69 ++
 3 files changed, 357 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 1804755327..6b454a75c1 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -154,6 +154,9 @@ enum {
 // get near that, though, so set a lower limit here with the maximum
 // possible value for 4K video (at most 135 16x16 Ctb rows).
 HEVC_MAX_ENTRY_POINT_OFFSETS = HEVC_MAX_TILE_COLUMNS * 135,
+
+// A.3.7: Screen content coding extensions
+HEVC_MAX_PALETTE_PREDICTOR_SIZE = 128,
 };
 
 
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 3052f58779..086b1d4002 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -910,7 +910,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 HEVCWindow *ow;
 int ret = 0;
 int log2_diff_max_min_transform_block_size;
-int bit_depth_chroma, start, vui_present, sublayer_ordering_info;
+int bit_depth_chroma, start, vui_present, sublayer_ordering_info, 
num_comps;
 int i;
 
 // Coded parameters
@@ -1131,8 +1131,12 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 decode_vui(gb, avctx, apply_defdispwin, sps);
 
 if (get_bits1(gb)) { // sps_extension_flag
-sps->sps_range_extension_flag = get_bits1(gb);
-skip_bits(gb, 7); //sps_extension_7bits = get_bits(gb, 7);
+sps->sps_range_extension_flag  = get_bits1(gb);
+sps->sps_multilayer_extension_flag = get_bits1(gb);
+sps->sps_3d_extension_flag = get_bits1(gb);
+sps->sps_scc_extension_flag= get_bits1(gb);
+skip_bits(gb, 4); // sps_extension_4bits
+
 if (sps->sps_range_extension_flag) {
 sps->transform_skip_rotation_enabled_flag = get_bits1(gb);
 sps->transform_skip_context_enabled_flag  = get_bits1(gb);
@@ -1158,6 +1162,57 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 av_log(avctx, AV_LOG_WARNING,
"cabac_bypass_alignment_enabled_flag not yet 
implemented\n");
 }
+
+if (sps->sps_multilayer_extension_flag) {
+skip_bits1(gb); // inter_view_mv_vert_constraint_flag
+av_log(avctx, AV_LOG_WARNING,
+   "sps_multilayer_extension_flag not yet implemented\n");
+}
+
+if (sps->sps_3d_extension_flag) {
+for (i = 0; i <= 1; i++) {
+skip_bits1(gb); // iv_di_mc_enabled_flag
+skip_bits1(gb); // iv_mv_scal_enabled_flag
+if (i == 0) {
+get_ue_golomb_long(gb); // log2_ivmc_sub_pb_size_minus3
+skip_bits1(gb); // iv_res_pred_enabled_flag
+skip_bits1(gb); // depth_ref_enabled_flag
+skip_bits1(gb); // vsp_mc_enabled_flag
+skip_bits1(gb); // dbbp_enabled_flag
+} else {
+skip_bits1(gb); // tex_mc_enabled_flag
+get_ue_golomb_long(gb); // log2_ivmc_sub_pb_size_minus3
+skip_bits1(gb); // intra_contour_enabled_flag
+skip_bits1(gb); // intra_dc_only_wedge_enabled_flag
+skip_bits1(gb); // cqt_cu_part_pred_enabled_flag
+skip_bits1(gb); // inter_dc_only_enabled_flag
+skip_bits1(gb); // skip_intra_enabled_flag
+}
+}
+av_log(avctx, AV_LOG_WARNING,
+   "sps_3d_extension_flag not yet implemented\n");
+}
+
+if (sps->sps_scc_extension_flag) {
+sps->sps_curr_pic_ref_enabled_flag = get_bits1(gb);
+sps->palette_mode_enabled_flag = get_bits1(gb);
+if (sps->palette_mode_enabled_flag) {
+sps->palette_max_size = get_ue_golomb_long(gb);
+sps->delta_palette_max_predictor_size = get_ue_golomb_long(gb);
+sps->sps_palette_predictor_initializers_present_flag = 
get_bits1(gb);
+
+if (sps->sps_palette_predictor_initializers_present_flag) {
+sps->sps_num_palette_predictor_initializers_minus1 = 
get_ue_golomb_long(gb);
+num_comps = !sps->chroma_format_idc ? 1 : 3;
+for (int comp = 0; comp < num_comps; comp++)
+for (i = 0; i <= 
sps->sps_num_palette_predicto

[FFmpeg-devel] [PATCH v1 04/13] lavc/hevcdec: Add slice parse support for HEVC SCC extension

2022-12-01 Thread Fei Wang
From: Linjie Fu 

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/hevcdec.c | 6 ++
 libavcodec/hevcdec.h | 4 
 2 files changed, 10 insertions(+)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index fb44d8d3f2..edf3a2b134 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -857,6 +857,12 @@ static int hls_slice_header(HEVCContext *s)
 sh->slice_cr_qp_offset = 0;
 }
 
+if (s->ps.pps->pps_slice_act_qp_offsets_present_flag) {
+sh->slice_act_y_qp_offset  = get_se_golomb(gb);
+sh->slice_act_cb_qp_offset = get_se_golomb(gb);
+sh->slice_act_cr_qp_offset = get_se_golomb(gb);
+}
+
 if (s->ps.pps->chroma_qp_offset_list_enabled_flag)
 sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);
 else
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 9d3f4adbb3..7841ba8565 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -295,6 +295,10 @@ typedef struct SliceHeader {
 int slice_cb_qp_offset;
 int slice_cr_qp_offset;
 
+int slice_act_y_qp_offset;
+int slice_act_cb_qp_offset;
+int slice_act_cr_qp_offset;
+
 uint8_t cu_chroma_qp_offset_enabled_flag;
 
 int beta_offset;///< beta_offset_div2 * 2
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 05/13] lavc/hevcdec: Fix the parsing for use_integer_mv_flag

2022-12-01 Thread Fei Wang
From: Linjie Fu 

According to 7.3.6.1, use_integer_mv_flag should be parsed if
motion_vector_resolution_control_idc equals to 2. If not present, it
equals to motion_vector_resolution_control_idc.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/hevcdec.c | 8 
 libavcodec/hevcdec.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index edf3a2b134..50e7fd4465 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -840,6 +840,14 @@ static int hls_slice_header(HEVCContext *s)
sh->max_num_merge_cand);
 return AVERROR_INVALIDDATA;
 }
+
+// Syntax in 7.3.6.1
+if (s->ps.sps->motion_vector_resolution_control_idc == 2)
+sh->use_integer_mv_flag = get_bits1(gb);
+else
+// Inferred to be equal to 
motion_vector_resolution_control_idc if not present
+sh->use_integer_mv_flag = 
s->ps.sps->motion_vector_resolution_control_idc;
+
 }
 
 sh->slice_qp_delta = get_se_golomb(gb);
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 7841ba8565..a7fc669bcb 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -305,6 +305,7 @@ typedef struct SliceHeader {
 int tc_offset;  ///< tc_offset_div2 * 2
 
 unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
+uint8_t use_integer_mv_flag;
 
 unsigned *entry_point_offset;
 int * offset;
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 06/13] lavc/hevcdec: Set max_num_merge_cand to uint8_t

2022-12-01 Thread Fei Wang
From: Linjie Fu 

uint8_t is big enough and keep consistent with the definition in
cbs_h265.h.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/hevcdec.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index a7fc669bcb..aab816791e 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -304,7 +304,7 @@ typedef struct SliceHeader {
 int beta_offset;///< beta_offset_div2 * 2
 int tc_offset;  ///< tc_offset_div2 * 2
 
-unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
+uint8_t max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
 uint8_t use_integer_mv_flag;
 
 unsigned *entry_point_offset;
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 07/13] lavc/hevc: Update reference list for SCC

2022-12-01 Thread Fei Wang
From: Linjie Fu 

Screen Content Coding allows non-intra slice in an IRAP frame which can
reference the frame itself, and would mark the current decoded picture
as "used for long-term reference", no matter TwoVersionsOfCurrDecPicFlag(8.1.3),
hence some previous restricts are not suitable any more.

Constructe RefPicListTemp and RefPicList according to 8-8/9/10. Disable
slice decoding for SCC profile to avoid unexpected error in hevc native
decoder and patch welcome.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/hevc_refs.c | 21 -
 libavcodec/hevcdec.c   | 10 +-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 811e8feff8..96153a2459 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -322,7 +322,7 @@ int ff_hevc_slice_rpl(HEVCContext *s)
 return ret;
 
 if (!(s->rps[ST_CURR_BEF].nb_refs + s->rps[ST_CURR_AFT].nb_refs +
-  s->rps[LT_CURR].nb_refs)) {
+  s->rps[LT_CURR].nb_refs) && 
!s->ps.pps->pps_curr_pic_ref_enabled_flag) {
 av_log(s->avctx, AV_LOG_ERROR, "Zero refs in the frame RPS.\n");
 return AVERROR_INVALIDDATA;
 }
@@ -349,6 +349,13 @@ int ff_hevc_slice_rpl(HEVCContext *s)
 rpl_tmp.nb_refs++;
 }
 }
+// Construct RefPicList0, RefPicList1 (8-8, 8-10)
+if (s->ps.pps->pps_curr_pic_ref_enabled_flag) {
+rpl_tmp.list[rpl_tmp.nb_refs]   = s->ref->poc;
+rpl_tmp.ref[rpl_tmp.nb_refs]= s->ref;
+rpl_tmp.isLongTerm[rpl_tmp.nb_refs] = 1;
+rpl_tmp.nb_refs++;
+}
 }
 
 /* reorder the references if necessary */
@@ -371,6 +378,14 @@ int ff_hevc_slice_rpl(HEVCContext *s)
 rpl->nb_refs = FFMIN(rpl->nb_refs, sh->nb_refs[list_idx]);
 }
 
+// 8-9
+if (s->ps.pps->pps_curr_pic_ref_enabled_flag &&
+!sh->rpl_modification_flag[list_idx] &&
+rpl_tmp.nb_refs > sh->nb_refs[L0]) {
+rpl->list[sh->nb_refs[L0] - 1] = s->ref->poc;
+rpl->ref[sh->nb_refs[L0] - 1]  = s->ref;
+}
+
 if (sh->collocated_list == list_idx &&
 sh->collocated_ref_idx < rpl->nb_refs)
 s->ref->collocated_ref = rpl->ref[sh->collocated_ref_idx];
@@ -541,5 +556,9 @@ int ff_hevc_frame_nb_refs(const HEVCContext *s)
 for (i = 0; i < long_rps->nb_refs; i++)
 ret += !!long_rps->used[i];
 }
+
+if (s->ps.pps->pps_curr_pic_ref_enabled_flag)
+ret++;
+
 return ret;
 }
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 50e7fd4465..bd8199d1dd 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -669,7 +669,8 @@ static int hls_slice_header(HEVCContext *s)
sh->slice_type);
 return AVERROR_INVALIDDATA;
 }
-if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I) {
+if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I &&
+!s->ps.pps->pps_curr_pic_ref_enabled_flag) {
 av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
 return AVERROR_INVALIDDATA;
 }
@@ -3256,6 +3257,13 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 if (ret < 0)
 goto fail;
 } else {
+if (s->avctx->profile == FF_PROFILE_HEVC_SCC) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "SCC profile is not yet implemented in hevc native 
decoder.\n");
+ret = AVERROR_PATCHWELCOME;
+goto fail;
+}
+
 if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0)
 ctb_addr_ts = hls_slice_data_wpp(s, nal);
 else
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 09/13] lavc/vaapi_hevc: Add vaapi profile parse support for SCC

2022-12-01 Thread Fei Wang
From: Linjie Fu 

Note that Screen-Extended Main 4:4:4 and 4:4:4 10 supports
chroma_format_idc from 0, 1 or 3, hence both 420 and 444 are
supported.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_decode.c |  4 +++-
 libavcodec/vaapi_hevc.c   | 14 --
 libavcodec/vaapi_hevc.h   |  2 +-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 134f10eca5..29ac439b36 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -410,7 +410,9 @@ static const struct {
 #endif
 #if VA_CHECK_VERSION(1, 2, 0) && CONFIG_HEVC_VAAPI_HWACCEL
 MAP(HEVC,HEVC_REXT,   None,
- ff_vaapi_parse_hevc_rext_profile ),
+ ff_vaapi_parse_hevc_profile ),
+MAP(HEVC,HEVC_SCC,None,
+ ff_vaapi_parse_hevc_profile ),
 #endif
 MAP(MJPEG,   MJPEG_HUFFMAN_BASELINE_DCT,
   JPEGBaseline),
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 750738d36e..6ce1e17fa8 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -586,9 +586,9 @@ static int ptl_convert(const PTLCommon *general_ptl, 
H265RawProfileTierLevel *h2
 }
 
 /*
- * Find exact va_profile for HEVC Range Extension
+ * Find exact va_profile for HEVC Range Extension and Screen Content Coding 
Extension
  */
-VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext *avctx)
+VAProfile ff_vaapi_parse_hevc_profile(AVCodecContext *avctx)
 {
 const HEVCContext *h = avctx->priv_data;
 const HEVCSPS *sps = h->ps.sps;
@@ -627,6 +627,16 @@ VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext 
*avctx)
 else if (!strcmp(profile->name, "Main 4:4:4 12") ||
  !strcmp(profile->name, "Main 4:4:4 12 Intra"))
 return VAProfileHEVCMain444_12;
+else if (!strcmp(profile->name, "Screen-Extended Main"))
+return VAProfileHEVCSccMain;
+else if (!strcmp(profile->name, "Screen-Extended Main 10"))
+return VAProfileHEVCSccMain10;
+else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4"))
+return VAProfileHEVCSccMain444;
+#if VA_CHECK_VERSION(1, 8, 0)
+else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4 10"))
+return VAProfileHEVCSccMain444_10;
+#endif
 #else
 av_log(avctx, AV_LOG_WARNING, "HEVC profile %s is "
"not supported with this VA version.\n", profile->name);
diff --git a/libavcodec/vaapi_hevc.h b/libavcodec/vaapi_hevc.h
index b3b0e6fc1e..7662dca510 100644
--- a/libavcodec/vaapi_hevc.h
+++ b/libavcodec/vaapi_hevc.h
@@ -22,6 +22,6 @@
 #include 
 #include "avcodec.h"
 
-VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext *avctx);
+VAProfile ff_vaapi_parse_hevc_profile(AVCodecContext *avctx);
 
 #endif /* AVCODEC_VAAPI_HEVC_H */
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 10/13] lavc/vaapi_hevc: Set correct rps type for scc

2022-12-01 Thread Fei Wang
From: Linjie Fu 

According to 8.1.3 and 8.3.2.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_hevc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 6ce1e17fa8..005d782819 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -71,6 +71,7 @@ static void fill_vaapi_pic(VAPictureHEVC *va_pic, const 
HEVCFrame *pic, int rps_
 static int find_frame_rps_type(const HEVCContext *h, const HEVCFrame *pic)
 {
 VASurfaceID pic_surf = ff_vaapi_get_surface_id(pic->frame);
+const HEVCFrame *current_picture = h->ref;
 int i;
 
 for (i = 0; i < h->rps[ST_CURR_BEF].nb_refs; i++) {
@@ -88,6 +89,9 @@ static int find_frame_rps_type(const HEVCContext *h, const 
HEVCFrame *pic)
 return VA_PICTURE_HEVC_RPS_LT_CURR;
 }
 
+if (h->ps.pps->pps_curr_pic_ref_enabled_flag && current_picture->poc == 
pic->poc)
+return VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
+
 return 0;
 }
 
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 11/13] lavc/vaapi_hevc: Loose the restricts for SCC decoding

2022-12-01 Thread Fei Wang
From: Linjie Fu 

Allow current picture as the reference picture.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_hevc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 005d782819..ca14052d56 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -104,7 +104,8 @@ static void fill_vaapi_reference_frames(const HEVCContext 
*h, VAPictureParameter
 const HEVCFrame *frame = NULL;
 
 while (!frame && j < FF_ARRAY_ELEMS(h->DPB)) {
-if (&h->DPB[j] != current_picture && (h->DPB[j].flags & 
(HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF)))
+if ((&h->DPB[j] != current_picture || 
h->ps.pps->pps_curr_pic_ref_enabled_flag) &&
+(h->DPB[j].flags & (HEVC_FRAME_FLAG_LONG_REF | 
HEVC_FRAME_FLAG_SHORT_REF)))
 frame = &h->DPB[j];
 j++;
 }
@@ -222,7 +223,8 @@ static int vaapi_hevc_start_frame(AVCodecContext  
*avctx,
 }
 
 #if VA_CHECK_VERSION(1, 2, 0)
-if (avctx->profile == FF_PROFILE_HEVC_REXT) {
+if (avctx->profile == FF_PROFILE_HEVC_REXT ||
+avctx->profile == FF_PROFILE_HEVC_SCC) {
 pic->pic_param.rext = (VAPictureParameterBufferHEVCRext) {
 .range_extension_pic_fields.bits  = {
 .transform_skip_rotation_enabled_flag   = 
sps->transform_skip_rotation_enabled_flag,
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 08/13] lavc/vaapi_hevc: Pass SCC parameters Through VA-API

2022-12-01 Thread Fei Wang
From: Linjie Fu 

Including sps/pps/slice parameters.

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_hevc.c | 52 +
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 20fb36adfa..750738d36e 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -124,7 +124,7 @@ static int vaapi_hevc_start_frame(AVCodecContext  
*avctx,
 const HEVCPPS  *pps = h->ps.pps;
 
 const ScalingList *scaling_list = NULL;
-int pic_param_size, err, i;
+int pic_param_size, num_comps, pre_palette_size, err, i;
 
 VAPictureParameterBufferHEVC *pic_param = (VAPictureParameterBufferHEVC 
*)&pic->pic_param;
 
@@ -245,8 +245,46 @@ static int vaapi_hevc_start_frame(AVCodecContext  
*avctx,
 for (i = 0; i < 6; i++)
 pic->pic_param.rext.cr_qp_offset_list[i]= 
pps->cr_qp_offset_list[i];
 }
+
+pre_palette_size = pps->pps_palette_predictor_initializers_present_flag ?
+   pps->pps_num_palette_predictor_initializers :
+   (sps->sps_palette_predictor_initializers_present_flag ?
+   sps->sps_num_palette_predictor_initializers_minus1 + 1 :
+   0);
+
+if (avctx->profile == FF_PROFILE_HEVC_SCC) {
+pic->pic_param.scc = (VAPictureParameterBufferHEVCScc) {
+.screen_content_pic_fields.bits = {
+.pps_curr_pic_ref_enabled_flag  = 
pps->pps_curr_pic_ref_enabled_flag,
+.palette_mode_enabled_flag  = 
sps->palette_mode_enabled_flag,
+.motion_vector_resolution_control_idc   = 
sps->motion_vector_resolution_control_idc,
+.intra_boundary_filtering_disabled_flag = 
sps->intra_boundary_filtering_disabled_flag,
+.residual_adaptive_colour_transform_enabled_flag
+= 
pps->residual_adaptive_colour_transform_enabled_flag,
+.pps_slice_act_qp_offsets_present_flag  = 
pps->pps_slice_act_qp_offsets_present_flag,
+},
+.palette_max_size   = 
sps->palette_max_size,
+.delta_palette_max_predictor_size   = 
sps->delta_palette_max_predictor_size,
+.predictor_palette_size = pre_palette_size,
+.pps_act_y_qp_offset_plus5  = 
pps->residual_adaptive_colour_transform_enabled_flag ?
+  
pps->pps_act_y_qp_offset + 5 : 0,
+.pps_act_cb_qp_offset_plus5 = 
pps->residual_adaptive_colour_transform_enabled_flag ?
+  
pps->pps_act_cb_qp_offset + 5 : 0,
+.pps_act_cr_qp_offset_plus3 = 
pps->residual_adaptive_colour_transform_enabled_flag ?
+  
pps->pps_act_cr_qp_offset + 3 : 0,
+};
+
+num_comps = pps->monochrome_palette_flag ? 1 : 3;
+for (int comp = 0; comp < num_comps; comp++)
+for (i = 0; i < pre_palette_size; i++)
+pic->pic_param.scc.predictor_palette_entries[comp][i] =
+pps->pps_palette_predictor_initializers_present_flag ?
+pps->pps_palette_predictor_initializer[comp][i]:
+sps->sps_palette_predictor_initializer[comp][i];
+}
+
 #endif
-pic_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ?
+pic_param_size = avctx->profile >= FF_PROFILE_HEVC_REXT ?
 sizeof(pic->pic_param) : 
sizeof(VAPictureParameterBufferHEVC);
 
 err = ff_vaapi_decode_make_param_buffer(avctx, &pic->pic,
@@ -299,7 +337,7 @@ static int vaapi_hevc_end_frame(AVCodecContext *avctx)
 VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC 
*)&pic->last_slice_param;
 int ret;
 
-int slice_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ?
+int slice_param_size = avctx->profile >= FF_PROFILE_HEVC_REXT ?
 sizeof(pic->last_slice_param) : 
sizeof(VASliceParameterBufferHEVC);
 
 if (pic->last_size) {
@@ -413,7 +451,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private;
 VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC 
*)&pic->last_slice_param;
 
-int slice_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ?
+int slice_param_size = avctx->profile >= FF_PROFILE_HEVC_REXT ?
 sizeof(pic->last_slice_param) : 
sizeof(VASliceParameterBufferHEVC);
 
 int nb_list = (sh->slice_type == HEVC_SLICE_B) ?
@@ -478,11 +516,15 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
  

[FFmpeg-devel] [PATCH v1 12/13] avcodec/hevcdec: Replace number with enum

2022-12-01 Thread Fei Wang
Keep same style with IS_IDR()/IS_BLA().

Signed-off-by: Fei Wang 
---
 libavcodec/hevcdec.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index aab816791e..94609e4699 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -75,7 +75,7 @@
 #define IS_IDR(s) ((s)->nal_unit_type == HEVC_NAL_IDR_W_RADL || 
(s)->nal_unit_type == HEVC_NAL_IDR_N_LP)
 #define IS_BLA(s) ((s)->nal_unit_type == HEVC_NAL_BLA_W_RADL || 
(s)->nal_unit_type == HEVC_NAL_BLA_W_LP || \
(s)->nal_unit_type == HEVC_NAL_BLA_N_LP)
-#define IS_IRAP(s) ((s)->nal_unit_type >= 16 && (s)->nal_unit_type <= 23)
+#define IS_IRAP(s) ((s)->nal_unit_type >= HEVC_NAL_BLA_W_LP && 
(s)->nal_unit_type <= HEVC_NAL_RSV_IRAP_VCL23)
 
 enum RPSType {
 ST_CURR_BEF = 0,
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 13/13] lavc/vaapi_hevc: Remove duplicate code

2022-12-01 Thread Fei Wang
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_hevc.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index ca14052d56..b3ff2f7344 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -538,12 +538,6 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 pic->last_slice_param.rext.ChromaOffsetL0[i][1] = 
sh->chroma_offset_l0[i][1];
 }
 
-for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
-pic->last_slice_param.rext.luma_offset_l0[i] = 
sh->luma_offset_l0[i];
-pic->last_slice_param.rext.ChromaOffsetL0[i][0] = 
sh->chroma_offset_l0[i][0];
-pic->last_slice_param.rext.ChromaOffsetL0[i][1] = 
sh->chroma_offset_l0[i][1];
-}
-
 if (sh->slice_type == HEVC_SLICE_B) {
 for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
 pic->last_slice_param.rext.luma_offset_l1[i] = 
sh->luma_offset_l1[i];
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avcodec/mathops: Optimize generic mid_pred function

2022-12-01 Thread Michael Niedermayer
On Thu, Dec 01, 2022 at 02:42:20PM +0800, Junxian Zhu wrote:
> From: Junxian Zhu 
> 
> Rewrite mid_pred function in generic mathops.h, reduce branch jump to improve 
> performance. And because nowadays new version compiler can compile enough 
> short asmbbely code as handwritting in these function, so remove specified 
> optimized mips inline asmbbely mathops.h.
> 
> Signed-off-by: Junxian Zhu 
> ---
>  libavcodec/mathops.h  | 20 
>  libavcodec/mips/mathops.h | 67 ---
>  2 files changed, 6 insertions(+), 81 deletions(-)
>  delete mode 100644 libavcodec/mips/mathops.h
> 
> diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
> index c89054d6ed..526ffe0eec 100644
> --- a/libavcodec/mathops.h
> +++ b/libavcodec/mathops.h
> @@ -41,8 +41,6 @@ extern const uint8_t ff_zigzag_scan[16+1];
>  #   include "arm/mathops.h"
>  #elif ARCH_AVR32
>  #   include "avr32/mathops.h"
> -#elif ARCH_MIPS
> -#   include "mips/mathops.h"
>  #elif ARCH_PPC
>  #   include "ppc/mathops.h"
>  #elif ARCH_X86
> @@ -98,18 +96,12 @@ static av_always_inline unsigned UMULH(unsigned a, 
> unsigned b){
>  #define mid_pred mid_pred
>  static inline av_const int mid_pred(int a, int b, int c)
>  {
> -if(a>b){
> -if(c>b){
> -if(c>a) b=a;
> -elseb=c;
> -}
> -}else{
> -if(b>c){
> -if(c>a) b=c;
> -elseb=a;
> -}
> -}
> -return b;
> +int t0,t1,t2,t3;
> +t0 = (a > b) ? b : a ;
> +t1 = (a > b) ? a : b ;
> +t2 = (t0 > c) ? t0 : c;

> +t3 = (t1 > t2) ? t2 : t1;
> +return t3; 

t3 intermediate is unneeded
return (t1 > t2) ? t2 : t1;

also benchmarks would be usefull

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 0/3] Some small ASS conversion fixes

2022-12-01 Thread Paul B Mahol
On 12/1/22, Oneric  wrote:
> On Sun, Nov 20, 2022 at 01:15:33 +0100, Oneric wrote:
>> On Sun, Nov 13, 2022 at 20:57:15 +0100, Oneric wrote:
>> > This fixes colours and font selection for files converted to ASS
>>
>> Ping.

Will apply if nobody is against.


Please ping me directly if I do not apply this.


>>
>> As a reminder v1 and v2 are equivalent and patchwork is buggy and can
>> thus neither apply v1 or v2 and its results can be ignored and its patch
>> or diff downloads should not be used, because they are corrupted.
>>
>> v1 can be applied from the mails received from the list, v2 can be
>> applied
>> the same way for patch one and two, but you may need to use --keep-cr and
>> because it turns out not only patchwork but also the mailinglist software
>> mangles the transfer encoding, patch three of v2 cannot applied from the
>> Mail received by the list.
>> As an alternative I previously attached an archive (so the list won’t
>> mangle it again) containing the three format-patch files, see:
>>   https://ffmpeg.org/pipermail/ffmpeg-devel/2022-November/303904.html
>>
>> As before, if you’d prefer to get a v3 where all mails can be applied
>> from
>> the list directly and no binary diff is used, tell me and I’ll send a v3
>> forcing base64-encoding from git send-email and including some non-ASCII
>> characters in the patch comment, since this appeared to make the list
>> keep
>> the base64 transfer-encoding for patch 2 v2.
>
> Ping #2
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v7 0/3] 32bps FLAC patches

2022-12-01 Thread Paul B Mahol
On 11/25/22, Paul B Mahol  wrote:
> On 10/11/22, Martijn van Beurden  wrote:
>> Recently libFLAC gained the ability (first released in FLAC 1.4.0)
>> to create FLAC files containing 32-bit int PCM samples. To
>> keep complexity reasonable, the choice was made to limit residuals
>> to 32-bit integers, which the encoder must make sure of. In case
>> the encoder cannot find any predictor of which the residuals fit
>> this limit, it must default to using a verbatim subframe. Tests have
>> shown that this does not happen often (<0.1% of subframes on a
>> music corpus of various styles). See also discussion here:
>> https://github.com/ietf-wg-cellar/flac-specification/pull/148
>>
>> These two patches implement decoding and encoding following this
>> format.
>>
>> Changes since v1:
>> fix copy-paste error in encoder, several invocations of
>> lpc_encode_choose_datapath used wrong parameters, making FATE fail as
>> compression was less than it should be
>>
>> Changes since v2:
>> Rebased decoder part as it didn't apply anymore
>>
>> Changes since v3:
>> Moved put_golomb part to flacenc.c (as it is now quite specific to FLAC)
>> and renamed put_sbits64 to put_sbits63 (and changed assert accordingly)
>>
>> Changes since v4:
>> Fix check of decoded_buffer_33bps malloc. Fix reading of wasted bits
>> for 33bps subframe. Add fate test
>>
>> Changes since v5:
>> Slimmed down 32 bps fate flac test from 2 to 1 input file. Replaced
>> -strict -2 with -strict experimental in fate and encoder warning.
>>
>> Changes since v6:
>> Deduplicated function bodies with preprocessor macros in both
>> encoder and decoder, declared variables in loop body where possible
>> and changed ff_ctz to ff_ctzll where necessary
>>
>> Martijn van Beurden (3):
>>   libavcodec/flacdec: Implement decoding of 32 bit-per-sample PCM
>>   libavcodec/flacenc: Implement encoding of 32 bit-per-sample PCM
>>   fate/flac: Add test of 32 bps encoding/decoding
>>
>>  libavcodec/flac.c   |   4 +-
>>  libavcodec/flacdec.c| 218 --
>>  libavcodec/flacenc.c| 480 +++-
>>  libavcodec/get_bits.h   |  12 +
>>  libavcodec/mathops.h|   9 +
>>  libavcodec/put_bits.h   |   7 +
>>  libavcodec/put_golomb.h |  14 --
>>  tests/fate/flac.mak |   4 +
>>  8 files changed, 602 insertions(+), 146 deletions(-)
>>
>> --
>> 2.30.2
>>
>
>
>
> If this is OK, will apply soon.


Last time to say no to this patchset.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [RFC PATCH] fftools/ffmpeg: make main function actually return

2022-12-01 Thread Zhao Zhili
From: Zhao Zhili 

---
When working on mediacodec encoder, I test it by making fftools/ffmpeg
into a lib, since JNI requires a JVM environment. There are three steps
mostly:
1. Rename main() function
2. Reset global variables
3. Make main() function actuall return

There is no point for this patch, except making fftools/ffmpeg a little
"lib friendly". And I understand fftools/ffmpeg isn't a lib by design.
But sometimes it's quick and easier to hack it.

 fftools/ffmpeg.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 771219f7df..4b12ad1ef8 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -100,6 +100,7 @@
 #include 
 #endif
 
+#include 
 #include 
 
 #include "ffmpeg.h"
@@ -491,10 +492,13 @@ static int decode_interrupt_cb(void *ctx)
 
 const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
 
+static jmp_buf exit_buf;
+
 static void ffmpeg_cleanup(int ret)
 {
 int i, j;
 
+main_return_code = ret;
 if (do_benchmark) {
 int maxrss = getmaxrss() / 1024;
 av_log(NULL, AV_LOG_INFO, "bench: maxrss=%ikB\n", maxrss);
@@ -571,6 +575,7 @@ static void ffmpeg_cleanup(int ret)
 }
 term_exit();
 ffmpeg_exited = 1;
+longjmp(exit_buf, 1);
 }
 
 /* iterate over all output streams in all output files;
@@ -3868,6 +3873,11 @@ int main(int argc, char **argv)
 int ret;
 BenchmarkTimeStamps ti;
 
+if (setjmp(exit_buf)) {
+// longjmp from ffmpeg_cleanup
+return main_return_code;
+}
+
 init_dynload();
 
 register_exit(ffmpeg_cleanup);
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/5] avcodec/wavpack: Fix overflow in k=31

2022-12-01 Thread Michael Niedermayer
On Wed, Nov 30, 2022 at 09:39:44PM +0100, Paul B Mahol wrote:
> On 9/11/22, Michael Niedermayer  wrote:
> > Untested with "non fuzzed" samples as i have no such file
> >
> 
> Then create it.

the official WavPack-5.6.0 decoder has 2 alternative optimized codepathes
#ifdef USE_BITMASK_TABLES
extras = bitset [bitcount] - maxcode - 1;
#else
extras = (1 << bitcount) - maxcode - 1;
#endif

The 2nd path would result in the same 1<<32 which is undefined but luckily
the first seems hardcoded to be used it uses this table:

const uint32_t bitset [] = {
1L << 0, 1L << 1, 1L << 2, 1L << 3,
1L << 4, 1L << 5, 1L << 6, 1L << 7,
1L << 8, 1L << 9, 1L << 10, 1L << 11,
1L << 12, 1L << 13, 1L << 14, 1L << 15,
1L << 16, 1L << 17, 1L << 18, 1L << 19,
1L << 20, 1L << 21, 1L << 22, 1L << 23,
1L << 24, 1L << 25, 1L << 26, 1L << 27,
1L << 28, 1L << 29, 1L << 30, 1L << 31
};

here bitset[32] is out of array

Given above i suspect no valid file should use this. Otherwise something
seriously odd is going on.

also the subject has a typo its p=31 not k=31

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] Revert "avformat/mov: disallow a zero sample size in trun atoms"

2022-12-01 Thread Chris Ribble
This reverts commit 03d81a044ad587ea83567f75dc36bc3d64278199.

This change broke the ability to read mp4 files which contain a trun
atom with a sample of size zero (FFmpeg exits while parsing the moof).

Signed-off-by: Chris Ribble 
---
 libavformat/mov.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 29bd3103e3..b67b7cd9d2 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5293,8 +5293,6 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 distance++;
 if (av_sat_add64(dts, sample_duration) != dts + 
(uint64_t)sample_duration)
 return AVERROR_INVALIDDATA;
-if (!sample_size)
-return AVERROR_INVALIDDATA;
 dts += sample_duration;
 offset += sample_size;
 sc->data_size += sample_size;
-- 
2.37.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] Revert "avformat/mov: disallow a zero sample size in trun atoms"

2022-12-01 Thread Marton Balint




On Thu, 1 Dec 2022, Chris Ribble wrote:


This reverts commit 03d81a044ad587ea83567f75dc36bc3d64278199.

This change broke the ability to read mp4 files which contain a trun
atom with a sample of size zero (FFmpeg exits while parsing the moof).


Can you explain why those files are considered valid, or why it makes 
sense to generate such files?


Thanks,
Marton



Signed-off-by: Chris Ribble 
---
libavformat/mov.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 29bd3103e3..b67b7cd9d2 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5293,8 +5293,6 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
distance++;
if (av_sat_add64(dts, sample_duration) != dts + 
(uint64_t)sample_duration)
return AVERROR_INVALIDDATA;
-if (!sample_size)
-return AVERROR_INVALIDDATA;
dts += sample_duration;
offset += sample_size;
sc->data_size += sample_size;
--
2.37.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] Developer online meeting tomorrow Dec 2 16:00

2022-12-01 Thread Jean-Baptiste Kempf
Yo,

As a few of us will be in Barcelona, we'll do a short meeting to discuss about 
technical things at 16:00 (Barcelona/Berlin time) on Dec 2.
This will happen on Jitsi, of course, and discussion on IRC.

Currently, there is no specific agenda, but please bring your own topics :)

C U soon

jb

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 03/13] lavc/hevc_ps: Add SPS/PPS parse support for HEVC extension syntax

2022-12-01 Thread Michael Niedermayer
On Thu, Dec 01, 2022 at 04:13:58PM +0800, Fei Wang wrote:
> From: Linjie Fu 
> 
> 1. Add extension syntax according to 7.3.2.2.3/7.3.2.3.3 in 
> T-REC-H.265-201911.
> 2. Keep using parsed PPS when bitstream overread for compatibility. For
> example, the clip PS_A_VIDYO_3.bit in FATE test has incomplete extension
> syntax which will be overread and un-decodable if without this change.
> 3. Format brace in pps_range_extensions().
> 
> Signed-off-by: Linjie Fu 
> Signed-off-by: Haihao Xiang 
> Signed-off-by: Fei Wang 
> ---
>  libavcodec/hevc.h|   3 +
>  libavcodec/hevc_ps.c | 293 +--
>  libavcodec/hevc_ps.h |  69 ++
>  3 files changed, 357 insertions(+), 8 deletions(-)

This causes segfaults

shortened stack trace looks like this, 
seems like classic stack overflow from infinite recursion

#0  0x56403d10 in colour_mapping_octants ()
#1  0x56403d15 in colour_mapping_octants ()
#2  0x56403d15 in colour_mapping_octants ()
#3  0x56403d15 in colour_mapping_octants ()
#4  0x56403d15 in colour_mapping_octants ()
#5  0x56403d15 in colour_mapping_octants ()
#6  0x56403d15 in colour_mapping_octants ()
#7  0x56403d15 in colour_mapping_octants ()
#8  0x56403d15 in colour_mapping_octants ()
#9  0x56403d15 in colour_mapping_octants ()
#10 0x56403d15 in colour_mapping_octants ()
#11 0x56403d15 in colour_mapping_octants ()
#12 0x56403d15 in colour_mapping_octants ()
...


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] Revert "avformat/mov: disallow a zero sample size in trun atoms"

2022-12-01 Thread Chris Ribble
On Thu, Dec 1, 2022 at 4:51 PM Marton Balint  wrote:
>
> Can you explain why those files are considered valid, or why it makes
> sense to generate such files?
>
> Thanks,
> Marton
>

As far as I can tell, the file that a user provided with this problem
was generated by an encoder (running FFmpeg 3.4) that started writing
zero-sized samples when their video switcher + capture card stopped
receiving audio input. I'm not arguing that it's good for files to be
generated like this, but it's nice for FFmpeg to be able to process
them all the same (i.e. the robustness principle).

With this patch reverted, FFmpeg can accept an input file that is
partially broken (with playback anomalies due to the presence of
zero-sized samples) and produce a valid, working output mp4 (or DASH
stream), just like it could in release 5.0 and older.

One of the best things about FFmpeg is that it can fix invalid
container metadata. I feel like losing that capability for this
scenario is a regression.

Thanks,
Chris
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 03/13] lavc/hevc_ps: Add SPS/PPS parse support for HEVC extension syntax

2022-12-01 Thread Wang, Fei W
On Fri, 2022-12-02 at 01:21 +0100, Michael Niedermayer wrote:
> On Thu, Dec 01, 2022 at 04:13:58PM +0800, Fei Wang wrote:
> > From: Linjie Fu 
> > 
> > 1. Add extension syntax according to 7.3.2.2.3/7.3.2.3.3 in T-REC-
> > H.265-201911.
> > 2. Keep using parsed PPS when bitstream overread for compatibility.
> > For
> > example, the clip PS_A_VIDYO_3.bit in FATE test has incomplete
> > extension
> > syntax which will be overread and un-decodable if without this
> > change.
> > 3. Format brace in pps_range_extensions().
> > 
> > Signed-off-by: Linjie Fu 
> > Signed-off-by: Haihao Xiang 
> > Signed-off-by: Fei Wang 
> > ---
> >  libavcodec/hevc.h|   3 +
> >  libavcodec/hevc_ps.c | 293
> > +--
> >  libavcodec/hevc_ps.h |  69 ++
> >  3 files changed, 357 insertions(+), 8 deletions(-)
> 
> This causes segfaults
> 
> shortened stack trace looks like this, 
> seems like classic stack overflow from infinite recursion

Thanks Michael, Could you send me the clip caused this issue?

Fei

> 
> #0  0x56403d10 in colour_mapping_octants ()
> #1  0x56403d15 in colour_mapping_octants ()
> #2  0x56403d15 in colour_mapping_octants ()
> #3  0x56403d15 in colour_mapping_octants ()
> #4  0x56403d15 in colour_mapping_octants ()
> #5  0x56403d15 in colour_mapping_octants ()
> #6  0x56403d15 in colour_mapping_octants ()
> #7  0x56403d15 in colour_mapping_octants ()
> #8  0x56403d15 in colour_mapping_octants ()
> #9  0x56403d15 in colour_mapping_octants ()
> #10 0x56403d15 in colour_mapping_octants ()
> #11 0x56403d15 in colour_mapping_octants ()
> #12 0x56403d15 in colour_mapping_octants ()
> ...
> 
> 
> [...]
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 03/13] lavc/hevc_ps: Add SPS/PPS parse support for HEVC extension syntax

2022-12-01 Thread James Almer

On 12/1/2022 5:13 AM, Fei Wang wrote:

+static void colour_mapping_octants(GetBitContext *gb, HEVCPPS *pps, int 
inp_depth,
+   int idx_y, int idx_cb, int idx_cr, int 
inp_length)
+{
+uint8_t split_octant_flag, coded_res_flag;
+uint16_t part_num_y, res_coeff_q, res_coeff_r;
+int bit_depth_cm_input_y, bit_depth_cm_output_y, cm_res_bits;
+int k, m, n, c, i, j;
+
+part_num_y = 1 << pps->cm_y_part_num_log2;
+
+if (inp_depth < pps->cm_octant_depth)
+split_octant_flag = get_bits1(gb);
+
+if (split_octant_flag)
+for (k = 0; k < 2; k++)
+for (m = 0; m < 2; m++)
+for (n = 0; n < 2; n++)
+colour_mapping_octants(gb, pps, inp_depth + 1,
+   idx_y + part_num_y * k * inp_length 
/ 2,
+   idx_cb + m * inp_length / 2,
+   idx_cr + n * inp_length / 2,
+   inp_length / 2);
+else
+for (i = 0; i < part_num_y; i++) {
+for (j = 0; j < 4; j++) {
+coded_res_flag = get_bits1(gb);
+if (coded_res_flag)
+for (c = 0; c < 3; c++) {
+res_coeff_q = get_ue_golomb_long(gb);
+bit_depth_cm_input_y = 8 + 
pps->luma_bit_depth_cm_input_minus8;
+bit_depth_cm_output_y = 8 + 
pps->luma_bit_depth_cm_output_minus8;
+cm_res_bits = FFMAX(0, 10 + bit_depth_cm_input_y - 
bit_depth_cm_output_y -
+pps->cm_res_quant_bits - 
(pps->cm_delta_flc_bits_minus1 + 1));
+res_coeff_r = get_bits(gb, cm_res_bits);


cm_res_bits can be zero, and you can't call get_bits() to read zero bits.
I can't say if that will fix the issue Michael mentioned, but it still 
needs to be fixed.



+if (res_coeff_q || res_coeff_r)
+skip_bits1(gb);
+}
+}
+}
+}

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 03/13] lavc/hevc_ps: Add SPS/PPS parse support for HEVC extension syntax

2022-12-01 Thread James Almer

On 12/1/2022 5:13 AM, Fei Wang wrote:

+static void colour_mapping_octants(GetBitContext *gb, HEVCPPS *pps, int 
inp_depth,
+   int idx_y, int idx_cb, int idx_cr, int 
inp_length)
+{
+uint8_t split_octant_flag, coded_res_flag;
+uint16_t part_num_y, res_coeff_q, res_coeff_r;


Use int or unsigned for scalar values in stack.


+int bit_depth_cm_input_y, bit_depth_cm_output_y, cm_res_bits;
+int k, m, n, c, i, j;


You can reduce the scope of almost all the above variables.


+
+part_num_y = 1 << pps->cm_y_part_num_log2;
+
+if (inp_depth < pps->cm_octant_depth)
+split_octant_flag = get_bits1(gb);
+
+if (split_octant_flag)


split_octant_flag may be undefined here. It should be initialized to 0.
This is probably the source of the issue Michael reported.


+for (k = 0; k < 2; k++)


for (int k = 0...)

Same for the rest.


+for (m = 0; m < 2; m++)
+for (n = 0; n < 2; n++)
+colour_mapping_octants(gb, pps, inp_depth + 1,
+   idx_y + part_num_y * k * inp_length 
/ 2,
+   idx_cb + m * inp_length / 2,
+   idx_cr + n * inp_length / 2,
+   inp_length / 2);
+else
+for (i = 0; i < part_num_y; i++) {
+for (j = 0; j < 4; j++) {
+coded_res_flag = get_bits1(gb);
+if (coded_res_flag)
+for (c = 0; c < 3; c++) {
+res_coeff_q = get_ue_golomb_long(gb);
+bit_depth_cm_input_y = 8 + 
pps->luma_bit_depth_cm_input_minus8;
+bit_depth_cm_output_y = 8 + 
pps->luma_bit_depth_cm_output_minus8;
+cm_res_bits = FFMAX(0, 10 + bit_depth_cm_input_y - 
bit_depth_cm_output_y -
+pps->cm_res_quant_bits - 
(pps->cm_delta_flc_bits_minus1 + 1));
+res_coeff_r = get_bits(gb, cm_res_bits);
+if (res_coeff_q || res_coeff_r)
+skip_bits1(gb);
+}
+}
+}
+}

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] Revert "avformat/mov: disallow a zero sample size in trun atoms"

2022-12-01 Thread Gyan Doshi




On 2022-12-02 06:16 am, Chris Ribble wrote:

On Thu, Dec 1, 2022 at 4:51 PM Marton Balint  wrote:

Can you explain why those files are considered valid, or why it makes
sense to generate such files?

Thanks,
Marton


As far as I can tell, the file that a user provided with this problem
was generated by an encoder (running FFmpeg 3.4) that started writing
zero-sized samples when their video switcher + capture card stopped
receiving audio input. I'm not arguing that it's good for files to be
generated like this, but it's nice for FFmpeg to be able to process
them all the same (i.e. the robustness principle).

With this patch reverted, FFmpeg can accept an input file that is
partially broken (with playback anomalies due to the presence of
zero-sized samples) and produce a valid, working output mp4 (or DASH
stream), just like it could in release 5.0 and older.

One of the best things about FFmpeg is that it can fix invalid
container metadata. I feel like losing that capability for this
scenario is a regression.


FWIW, we don't discard regular MP4s with sample entries of 0 in stts, 
which is only permitted for the last solo sample in a track. So, I agree.


Regards,
Gyan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 03/13] lavc/hevc_ps: Add SPS/PPS parse support for HEVC extension syntax

2022-12-01 Thread Michael Niedermayer
On Fri, Dec 02, 2022 at 12:58:48AM +, Wang, Fei W wrote:
> On Fri, 2022-12-02 at 01:21 +0100, Michael Niedermayer wrote:
> > On Thu, Dec 01, 2022 at 04:13:58PM +0800, Fei Wang wrote:
> > > From: Linjie Fu 
> > > 
> > > 1. Add extension syntax according to 7.3.2.2.3/7.3.2.3.3 in T-REC-
> > > H.265-201911.
> > > 2. Keep using parsed PPS when bitstream overread for compatibility.
> > > For
> > > example, the clip PS_A_VIDYO_3.bit in FATE test has incomplete
> > > extension
> > > syntax which will be overread and un-decodable if without this
> > > change.
> > > 3. Format brace in pps_range_extensions().
> > > 
> > > Signed-off-by: Linjie Fu 
> > > Signed-off-by: Haihao Xiang 
> > > Signed-off-by: Fei Wang 
> > > ---
> > >  libavcodec/hevc.h|   3 +
> > >  libavcodec/hevc_ps.c | 293
> > > +--
> > >  libavcodec/hevc_ps.h |  69 ++
> > >  3 files changed, 357 insertions(+), 8 deletions(-)
> > 
> > This causes segfaults
> > 
> > shortened stack trace looks like this, 
> > seems like classic stack overflow from infinite recursion
> 
> Thanks Michael, Could you send me the clip caused this issue?

file sent privatly

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".