[FFmpeg-cvslog] av1dec: Fix RefFrameSignBias calculation
ffmpeg | branch: release/7.0 | Mark Thompson | Mon Apr 22 21:24:20 2024 +0100| [9963b9e3c9e51ae6fb5ff4df5a26a459922dc51c] | committer: Lynne av1dec: Fix RefFrameSignBias calculation (cherry picked from commit ba6b08c75b6e8394c5c53bde22623a393a2d1c47) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9963b9e3c9e51ae6fb5ff4df5a26a459922dc51c --- libavcodec/av1dec.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 2850dc96ff..1d3c5dfc9d 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -372,8 +372,13 @@ static void order_hint_info(AV1DecContext *s) int ref_order_hint = s->ref[ref_slot].order_hint; frame->order_hints[ref_name] = ref_order_hint; -frame->ref_frame_sign_bias[ref_name] = -get_relative_dist(seq, ref_order_hint, frame->order_hint); +if (!seq->enable_order_hint) { +frame->ref_frame_sign_bias[ref_name] = 0; +} else { +frame->ref_frame_sign_bias[ref_name] = +get_relative_dist(seq, ref_order_hint, + frame->order_hint) > 0; +} } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] av1dec: Fix RefFrameSignBias calculation
ffmpeg | branch: master | Mark Thompson | Mon Apr 22 21:24:20 2024 +0100| [ba6b08c75b6e8394c5c53bde22623a393a2d1c47] | committer: Mark Thompson av1dec: Fix RefFrameSignBias calculation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ba6b08c75b6e8394c5c53bde22623a393a2d1c47 --- libavcodec/av1dec.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 69da08b686..79a30a114d 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -373,8 +373,13 @@ static void order_hint_info(AV1DecContext *s) int ref_order_hint = s->ref[ref_slot].order_hint; frame->order_hints[ref_name] = ref_order_hint; -frame->ref_frame_sign_bias[ref_name] = -get_relative_dist(seq, ref_order_hint, frame->order_hint); +if (!seq->enable_order_hint) { +frame->ref_frame_sign_bias[ref_name] = 0; +} else { +frame->ref_frame_sign_bias[ref_name] = +get_relative_dist(seq, ref_order_hint, + frame->order_hint) > 0; +} } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/av1: Record reference ordering information for each frame
ffmpeg | branch: release/7.0 | Mark Thompson | Sat Apr 13 20:05:23 2024 +0100| [0d851a82dd974dcafe2f4f67ea0d72fb2e63c6bb] | committer: Lynne lavc/av1: Record reference ordering information for each frame This is needed by Vulkan. Constructing this can't be delegated to CBS because packets might contain multiple frames (when non-shown frames are present) but we need separate snapshots immediately before each frame for the decoder. (cherry picked from commit 22ced1edc6fc4100072e122d549fe379aff76954) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0d851a82dd974dcafe2f4f67ea0d72fb2e63c6bb --- libavcodec/av1dec.c | 26 ++ libavcodec/av1dec.h | 8 2 files changed, 34 insertions(+) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 32a795e758..2850dc96ff 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -358,6 +358,25 @@ static void coded_lossless_param(AV1DecContext *s) } } +static void order_hint_info(AV1DecContext *s) +{ +const AV1RawFrameHeader *header = s->raw_frame_header; +const AV1RawSequenceHeader *seq = s->raw_seq; +AV1Frame *frame = >cur_frame; + +frame->order_hint = header->order_hint; + +for (int i = 0; i < AV1_REFS_PER_FRAME; i++) { +int ref_name = i + AV1_REF_FRAME_LAST; +int ref_slot = header->ref_frame_idx[i]; +int ref_order_hint = s->ref[ref_slot].order_hint; + +frame->order_hints[ref_name] = ref_order_hint; +frame->ref_frame_sign_bias[ref_name] = +get_relative_dist(seq, ref_order_hint, frame->order_hint); +} +} + static void load_grain_params(AV1DecContext *s) { const AV1RawFrameHeader *header = s->raw_frame_header; @@ -700,6 +719,12 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s sizeof(dst->film_grain)); dst->coded_lossless = src->coded_lossless; +dst->order_hint = src->order_hint; +memcpy(dst->ref_frame_sign_bias, src->ref_frame_sign_bias, + sizeof(dst->ref_frame_sign_bias)); +memcpy(dst->order_hints, src->order_hints, + sizeof(dst->order_hints)); + return 0; fail: @@ -1255,6 +1280,7 @@ static int get_current_frame(AVCodecContext *avctx) global_motion_params(s); skip_mode_params(s); coded_lossless_param(s); +order_hint_info(s); load_grain_params(s); return ret; diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h index 336eb61359..79a0be510b 100644 --- a/libavcodec/av1dec.h +++ b/libavcodec/av1dec.h @@ -53,6 +53,14 @@ typedef struct AV1Frame { AV1RawFilmGrainParams film_grain; uint8_t coded_lossless; + +// OrderHint for this frame. +uint8_t order_hint; +// RefFrameSignBias[] used when decoding this frame. +uint8_t ref_frame_sign_bias[AV1_TOTAL_REFS_PER_FRAME]; +// OrderHints[] when this is the current frame, otherwise +// SavedOrderHints[s][] when is the reference frame in slot s. +uint8_t order_hints[AV1_TOTAL_REFS_PER_FRAME]; } AV1Frame; typedef struct TileGroupInfo { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/vulkan_av1: Use av1dec reference order hint information
ffmpeg | branch: release/7.0 | Mark Thompson | Sat Apr 13 20:06:56 2024 +0100| [48721a415a057adde61b586f2eb9815a625abbf7] | committer: Lynne lavc/vulkan_av1: Use av1dec reference order hint information (cherry picked from commit 3cca8dfbd88dfbf9c20f2e8c8da47881b4596567) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=48721a415a057adde61b586f2eb9815a625abbf7 --- libavcodec/vulkan_av1.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index c9e398eaec..fcc9a4f03b 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -76,7 +76,7 @@ static int vk_av1_fill_pict(AVCodecContext *avctx, const AV1Frame **ref_src, StdVideoDecodeAV1ReferenceInfo *vkav1_std_ref, VkVideoDecodeAV1DpbSlotInfoKHR *vkav1_ref, /* Goes in ^ */ const AV1Frame *pic, int is_current, int has_grain, -int *saved_order_hints) +const uint8_t *saved_order_hints) { FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data; AV1VulkanDecodePicture *hp = pic->hwaccel_picture_private; @@ -242,7 +242,6 @@ static int vk_av1_start_frame(AVCodecContext *avctx, const AV1RawFrameHeader *frame_header = s->raw_frame_header; const AV1RawFilmGrainParams *film_grain = >cur_frame.film_grain; -CodedBitstreamAV1Context *cbs_ctx = (CodedBitstreamAV1Context *)(s->cbc->priv_data); const int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain; @@ -272,7 +271,7 @@ static int vk_av1_start_frame(AVCodecContext *avctx, ap->ref_frame_sign_bias_mask = 0x0; for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++) -ap->ref_frame_sign_bias_mask |= cbs_ctx->ref_frame_sign_bias[i] << i; +ap->ref_frame_sign_bias_mask |= pic->ref_frame_sign_bias[i] << i; for (int i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; i++) { const int idx = pic->raw_frame_header->ref_frame_idx[i]; @@ -294,7 +293,7 @@ static int vk_av1_start_frame(AVCodecContext *avctx, err = vk_av1_fill_pict(avctx, >ref_src[ref_count], >ref_slots[ref_count], >refs[ref_count], >std_refs[ref_count], >vkav1_refs[ref_count], - ref_frame, 0, 0, cbs_ctx->ref[idx].saved_order_hints); + ref_frame, 0, 0, ref_frame->order_hints); if (err < 0) return err; @@ -491,8 +490,14 @@ static int vk_av1_start_frame(AVCodecContext *avctx, } } -for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++) +for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++) { +ap->std_pic_info.OrderHints[i] = pic->order_hints[i]; ap->loop_filter.loop_filter_ref_deltas[i] = frame_header->loop_filter_ref_deltas[i]; +ap->global_motion.GmType[i] = s->cur_frame.gm_type[i]; +for (int j = 0; j < STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS; j++) { +ap->global_motion.gm_params[i][j] = s->cur_frame.gm_params[i][j]; +} +} for (int i = 0; i < STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS; i++) { ap->cdef.cdef_y_pri_strength[i] = frame_header->cdef_y_pri_strength[i]; @@ -501,14 +506,6 @@ static int vk_av1_start_frame(AVCodecContext *avctx, ap->cdef.cdef_uv_sec_strength[i] = frame_header->cdef_uv_sec_strength[i]; } -for (int i = 0; i < STD_VIDEO_AV1_NUM_REF_FRAMES; i++) { -ap->std_pic_info.OrderHints[i] = frame_header->ref_order_hint[i]; -ap->global_motion.GmType[i] = s->cur_frame.gm_type[i]; -for (int j = 0; j < STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS; j++) { -ap->global_motion.gm_params[i][j] = s->cur_frame.gm_params[i][j]; -} -} - if (apply_grain) { for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_Y_POINTS; i++) { ap->film_grain.point_y_value[i] = film_grain->point_y_value[i]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/vulkan_av1: Use av1dec reference order hint information
ffmpeg | branch: master | Mark Thompson | Sat Apr 13 20:06:56 2024 +0100| [3cca8dfbd88dfbf9c20f2e8c8da47881b4596567] | committer: Mark Thompson lavc/vulkan_av1: Use av1dec reference order hint information > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3cca8dfbd88dfbf9c20f2e8c8da47881b4596567 --- libavcodec/vulkan_av1.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index c9e398eaec..fcc9a4f03b 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -76,7 +76,7 @@ static int vk_av1_fill_pict(AVCodecContext *avctx, const AV1Frame **ref_src, StdVideoDecodeAV1ReferenceInfo *vkav1_std_ref, VkVideoDecodeAV1DpbSlotInfoKHR *vkav1_ref, /* Goes in ^ */ const AV1Frame *pic, int is_current, int has_grain, -int *saved_order_hints) +const uint8_t *saved_order_hints) { FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data; AV1VulkanDecodePicture *hp = pic->hwaccel_picture_private; @@ -242,7 +242,6 @@ static int vk_av1_start_frame(AVCodecContext *avctx, const AV1RawFrameHeader *frame_header = s->raw_frame_header; const AV1RawFilmGrainParams *film_grain = >cur_frame.film_grain; -CodedBitstreamAV1Context *cbs_ctx = (CodedBitstreamAV1Context *)(s->cbc->priv_data); const int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain; @@ -272,7 +271,7 @@ static int vk_av1_start_frame(AVCodecContext *avctx, ap->ref_frame_sign_bias_mask = 0x0; for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++) -ap->ref_frame_sign_bias_mask |= cbs_ctx->ref_frame_sign_bias[i] << i; +ap->ref_frame_sign_bias_mask |= pic->ref_frame_sign_bias[i] << i; for (int i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; i++) { const int idx = pic->raw_frame_header->ref_frame_idx[i]; @@ -294,7 +293,7 @@ static int vk_av1_start_frame(AVCodecContext *avctx, err = vk_av1_fill_pict(avctx, >ref_src[ref_count], >ref_slots[ref_count], >refs[ref_count], >std_refs[ref_count], >vkav1_refs[ref_count], - ref_frame, 0, 0, cbs_ctx->ref[idx].saved_order_hints); + ref_frame, 0, 0, ref_frame->order_hints); if (err < 0) return err; @@ -491,8 +490,14 @@ static int vk_av1_start_frame(AVCodecContext *avctx, } } -for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++) +for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++) { +ap->std_pic_info.OrderHints[i] = pic->order_hints[i]; ap->loop_filter.loop_filter_ref_deltas[i] = frame_header->loop_filter_ref_deltas[i]; +ap->global_motion.GmType[i] = s->cur_frame.gm_type[i]; +for (int j = 0; j < STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS; j++) { +ap->global_motion.gm_params[i][j] = s->cur_frame.gm_params[i][j]; +} +} for (int i = 0; i < STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS; i++) { ap->cdef.cdef_y_pri_strength[i] = frame_header->cdef_y_pri_strength[i]; @@ -501,14 +506,6 @@ static int vk_av1_start_frame(AVCodecContext *avctx, ap->cdef.cdef_uv_sec_strength[i] = frame_header->cdef_uv_sec_strength[i]; } -for (int i = 0; i < STD_VIDEO_AV1_NUM_REF_FRAMES; i++) { -ap->std_pic_info.OrderHints[i] = frame_header->ref_order_hint[i]; -ap->global_motion.GmType[i] = s->cur_frame.gm_type[i]; -for (int j = 0; j < STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS; j++) { -ap->global_motion.gm_params[i][j] = s->cur_frame.gm_params[i][j]; -} -} - if (apply_grain) { for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_Y_POINTS; i++) { ap->film_grain.point_y_value[i] = film_grain->point_y_value[i]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/av1: Record reference ordering information for each frame
ffmpeg | branch: master | Mark Thompson | Sat Apr 13 20:05:23 2024 +0100| [22ced1edc6fc4100072e122d549fe379aff76954] | committer: Mark Thompson lavc/av1: Record reference ordering information for each frame This is needed by Vulkan. Constructing this can't be delegated to CBS because packets might contain multiple frames (when non-shown frames are present) but we need separate snapshots immediately before each frame for the decoder. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=22ced1edc6fc4100072e122d549fe379aff76954 --- libavcodec/av1dec.c | 26 ++ libavcodec/av1dec.h | 8 2 files changed, 34 insertions(+) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 824725c031..b4b741054a 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -359,6 +359,25 @@ static void coded_lossless_param(AV1DecContext *s) } } +static void order_hint_info(AV1DecContext *s) +{ +const AV1RawFrameHeader *header = s->raw_frame_header; +const AV1RawSequenceHeader *seq = s->raw_seq; +AV1Frame *frame = >cur_frame; + +frame->order_hint = header->order_hint; + +for (int i = 0; i < AV1_REFS_PER_FRAME; i++) { +int ref_name = i + AV1_REF_FRAME_LAST; +int ref_slot = header->ref_frame_idx[i]; +int ref_order_hint = s->ref[ref_slot].order_hint; + +frame->order_hints[ref_name] = ref_order_hint; +frame->ref_frame_sign_bias[ref_name] = +get_relative_dist(seq, ref_order_hint, frame->order_hint); +} +} + static void load_grain_params(AV1DecContext *s) { const AV1RawFrameHeader *header = s->raw_frame_header; @@ -701,6 +720,12 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s sizeof(dst->film_grain)); dst->coded_lossless = src->coded_lossless; +dst->order_hint = src->order_hint; +memcpy(dst->ref_frame_sign_bias, src->ref_frame_sign_bias, + sizeof(dst->ref_frame_sign_bias)); +memcpy(dst->order_hints, src->order_hints, + sizeof(dst->order_hints)); + return 0; fail: @@ -1257,6 +1282,7 @@ static int get_current_frame(AVCodecContext *avctx) global_motion_params(s); skip_mode_params(s); coded_lossless_param(s); +order_hint_info(s); load_grain_params(s); return ret; diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h index 336eb61359..79a0be510b 100644 --- a/libavcodec/av1dec.h +++ b/libavcodec/av1dec.h @@ -53,6 +53,14 @@ typedef struct AV1Frame { AV1RawFilmGrainParams film_grain; uint8_t coded_lossless; + +// OrderHint for this frame. +uint8_t order_hint; +// RefFrameSignBias[] used when decoding this frame. +uint8_t ref_frame_sign_bias[AV1_TOTAL_REFS_PER_FRAME]; +// OrderHints[] when this is the current frame, otherwise +// SavedOrderHints[s][] when is the reference frame in slot s. +uint8_t order_hints[AV1_TOTAL_REFS_PER_FRAME]; } AV1Frame; typedef struct TileGroupInfo { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/get_buffer: Add a warning on failed allocation from a fixed pool
ffmpeg | branch: master | Mark Thompson | Sun Mar 17 20:51:29 2024 +| [4743c9e87a629d6af53b508c6a36135590622c16] | committer: Mark Thompson lavc/get_buffer: Add a warning on failed allocation from a fixed pool For hardware cases where we are forced to have a fixed pool of frames allocated up-front (such as array textures on decoder output), suggest a possible workaround to the user if an allocation fails because the pool is exhausted. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4743c9e87a629d6af53b508c6a36135590622c16 --- libavcodec/get_buffer.c | 16 libavcodec/internal.h | 6 ++ 2 files changed, 22 insertions(+) diff --git a/libavcodec/get_buffer.c b/libavcodec/get_buffer.c index 46c20781af..9b35fde7c6 100644 --- a/libavcodec/get_buffer.c +++ b/libavcodec/get_buffer.c @@ -257,6 +257,22 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags if (avctx->hw_frames_ctx) { ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0); +if (ret == AVERROR(ENOMEM)) { +AVHWFramesContext *frames_ctx = +(AVHWFramesContext*)avctx->hw_frames_ctx->data; +if (frames_ctx->initial_pool_size > 0 && +!avctx->internal->warned_on_failed_allocation_from_fixed_pool) { +av_log(avctx, AV_LOG_WARNING, "Failed to allocate a %s/%s " + "frame from a fixed pool of hardware frames.\n", + av_get_pix_fmt_name(frames_ctx->format), + av_get_pix_fmt_name(frames_ctx->sw_format)); +av_log(avctx, AV_LOG_WARNING, "Consider setting " + "extra_hw_frames to a larger value " + "(currently set to %d, giving a pool size of %d).\n", + avctx->extra_hw_frames, frames_ctx->initial_pool_size); +avctx->internal->warned_on_failed_allocation_from_fixed_pool = 1; +} +} frame->width = avctx->coded_width; frame->height = avctx->coded_height; return ret; diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 04f7cebdcb..64fe0122c8 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -144,6 +144,12 @@ typedef struct AVCodecInternal { #if CONFIG_LCMS2 FFIccContext icc; /* used to read and write embedded ICC profiles */ #endif + +/** + * Set when the user has been warned about a failed allocation from + * a fixed frame pool. + */ +int warned_on_failed_allocation_from_fixed_pool; } AVCodecInternal; /** ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/cbs_av1: Save more frame ordering information
ffmpeg | branch: master | Mark Thompson | Wed Mar 20 20:35:28 2024 +| [cafb4c554845332eeb33284cf6498049997dc67e] | committer: Lynne lavc/cbs_av1: Save more frame ordering information This is wanted by the Vulkan decoder. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cafb4c554845332eeb33284cf6498049997dc67e --- libavcodec/cbs_av1.h | 5 + libavcodec/cbs_av1_syntax_template.c | 25 + 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h index a5402f069d..a027013bc7 100644 --- a/libavcodec/cbs_av1.h +++ b/libavcodec/cbs_av1.h @@ -427,6 +427,8 @@ typedef struct AV1ReferenceFrameState { int bit_depth; // RefBitDepth int order_hint; // RefOrderHint +int saved_order_hints[AV1_TOTAL_REFS_PER_FRAME]; // SavedOrderHints[ref] + int8_t loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME]; int8_t loop_filter_mode_deltas[2]; uint8_t feature_enabled[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX]; @@ -464,6 +466,9 @@ typedef struct CodedBitstreamAV1Context { int tile_rows; int tile_num; +int order_hints[AV1_TOTAL_REFS_PER_FRAME]; // OrderHints +int ref_frame_sign_bias[AV1_TOTAL_REFS_PER_FRAME]; // RefFrameSignBias + AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES]; // AVOptions diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 3be1f2d30f..2979c5d98f 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1414,6 +1414,8 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, priv->ref[i].valid = 0; priv->ref[i].order_hint = 0; } +for (i = 0; i < AV1_REFS_PER_FRAME; i++) +priv->order_hints[i + AV1_REF_FRAME_LAST] = 0; } flag(disable_cdf_update); @@ -1568,11 +1570,20 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, else flag(use_ref_frame_mvs); -infer(allow_intrabc, 0); -} +for (i = 0; i < AV1_REFS_PER_FRAME; i++) { +int ref_frame = AV1_REF_FRAME_LAST + i; +int hint = priv->ref[current->ref_frame_idx[i]].order_hint; +priv->order_hints[ref_frame] = hint; +if (!seq->enable_order_hint) { +priv->ref_frame_sign_bias[ref_frame] = 0; +} else { +priv->ref_frame_sign_bias[ref_frame] = +cbs_av1_get_relative_dist(seq, hint, + current->order_hint) > 0; +} +} -if (!frame_is_intra) { -// Derive reference frame sign biases. +infer(allow_intrabc, 0); } if (seq->reduced_still_picture_header || current->disable_cdf_update) @@ -1674,6 +1685,12 @@ update_refs: .bit_depth = priv->bit_depth, .order_hint = priv->order_hint, }; + +for (int j = 0; j < AV1_REFS_PER_FRAME; j++) { +priv->ref[i].saved_order_hints[j + AV1_REF_FRAME_LAST] = +priv->order_hints[j + AV1_REF_FRAME_LAST]; +} + memcpy(priv->ref[i].loop_filter_ref_deltas, current->loop_filter_ref_deltas, sizeof(current->loop_filter_ref_deltas)); memcpy(priv->ref[i].loop_filter_mode_deltas, current->loop_filter_mode_deltas, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] ffmpeg: set extra_hw_frames to account for frames held in queues
ffmpeg | branch: master | Mark Thompson | Sun Feb 25 11:13:24 2024 +| [7f4b8d2f5e1a780eaefff528b1dd5070c42f496f] | committer: Mark Thompson ffmpeg: set extra_hw_frames to account for frames held in queues Since e0da916b8f5b079a4865eef7f64863f50785463d the ffmpeg utility has held multiple frames output by the decoder in internal queues without telling the decoder that it is going to do so. When the decoder has a fixed-size pool of frames (common in some hardware APIs where the output frames must be stored as an array texture) this could lead to the pool being exhausted and the decoder getting stuck. Fix this by telling the decoder to allocate additional frames according to the queue size. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f4b8d2f5e1a780eaefff528b1dd5070c42f496f --- fftools/ffmpeg_dec.c | 13 + fftools/ffmpeg_sched.c | 16 +++- fftools/ffmpeg_sched.h | 12 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index c41c5748e5..ed411b6bf8 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -1207,6 +1207,19 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts, return ret; } +if (dp->dec_ctx->hw_device_ctx) { +// Update decoder extra_hw_frames option to account for the +// frames held in queues inside the ffmpeg utility. This is +// called after avcodec_open2() because the user-set value of +// extra_hw_frames becomes valid in there, and we need to add +// this on top of it. +int extra_frames = DEFAULT_FRAME_THREAD_QUEUE_SIZE; +if (dp->dec_ctx->extra_hw_frames >= 0) +dp->dec_ctx->extra_hw_frames += extra_frames; +else +dp->dec_ctx->extra_hw_frames = extra_frames; +} + ret = check_avoptions(*dec_opts); if (ret < 0) return ret; diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index f739066921..ec88017e21 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -365,7 +365,21 @@ static int queue_alloc(ThreadQueue **ptq, unsigned nb_streams, unsigned queue_si ThreadQueue *tq; ObjPool *op; -queue_size = queue_size > 0 ? queue_size : 8; +if (queue_size <= 0) { +if (type == QUEUE_FRAMES) +queue_size = DEFAULT_FRAME_THREAD_QUEUE_SIZE; +else +queue_size = DEFAULT_PACKET_THREAD_QUEUE_SIZE; +} + +if (type == QUEUE_FRAMES) { +// This queue length is used in the decoder code to ensure that +// there are enough entries in fixed-size frame pools to account +// for frames held in queues inside the ffmpeg utility. If this +// can ever dynamically change then the corresponding decode +// code needs to be updated as well. +av_assert0(queue_size == DEFAULT_FRAME_THREAD_QUEUE_SIZE); +} op = (type == QUEUE_PACKETS) ? objpool_alloc_packets() : objpool_alloc_frames(); diff --git a/fftools/ffmpeg_sched.h b/fftools/ffmpeg_sched.h index a9190bd3d1..e51c26cec9 100644 --- a/fftools/ffmpeg_sched.h +++ b/fftools/ffmpeg_sched.h @@ -233,6 +233,18 @@ int sch_add_filtergraph(Scheduler *sch, unsigned nb_inputs, unsigned nb_outputs, */ int sch_add_mux(Scheduler *sch, SchThreadFunc func, int (*init)(void *), void *ctx, int sdp_auto, unsigned thread_queue_size); + +/** + * Default size of a packet thread queue. For muxing this can be overridden by + * the thread_queue_size option as passed to a call to sch_add_mux(). + */ +#define DEFAULT_PACKET_THREAD_QUEUE_SIZE 8 + +/** + * Default size of a frame thread queue. + */ +#define DEFAULT_FRAME_THREAD_QUEUE_SIZE 8 + /** * Add a muxed stream for a previously added muxer. * ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec: Fix doxygen comment marker
ffmpeg | branch: master | Mark Thompson | Wed Mar 13 21:56:59 2024 +| [98a2ade63063265c32232fc07ba98073b184245b] | committer: Mark Thompson avcodec: Fix doxygen comment marker > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98a2ade63063265c32232fc07ba98073b184245b --- libavcodec/avcodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 21fc74707f..554501aa44 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1505,7 +1505,7 @@ typedef struct AVCodecContext { */ int hwaccel_flags; -/* +/** * Video decoding only. Sets the number of extra hardware frames which * the decoder will allocate for use by the caller. This must be set * before avcodec_open2() is called. ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/d3d12va: Improve behaviour on missing decoder support
ffmpeg | branch: master | Mark Thompson | Sun Feb 4 13:24:33 2024 +| [fa580a0f17f72a54a2effe89bf10b00b28203d87] | committer: Mark Thompson lavc/d3d12va: Improve behaviour on missing decoder support Distinguish between a decoder being entirely missing and a decoder which requires features which are not present in the incomplete implementation in libavcodec and therefore can't be used. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fa580a0f17f72a54a2effe89bf10b00b28203d87 --- libavcodec/d3d12va_decode.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c index f678b6f483..9bb8db1690 100644 --- a/libavcodec/d3d12va_decode.c +++ b/libavcodec/d3d12va_decode.c @@ -239,10 +239,14 @@ static int d3d12va_create_decoder(AVCodecContext *avctx) DX_CHECK(ID3D12VideoDevice_CheckFeatureSupport(device_hwctx->video_device, D3D12_FEATURE_VIDEO_DECODE_SUPPORT, , sizeof(feature))); -if (!(feature.SupportFlags & D3D12_VIDEO_DECODE_SUPPORT_FLAG_SUPPORTED) || -!(feature.DecodeTier >= D3D12_VIDEO_DECODE_TIER_2)) { -av_log(avctx, AV_LOG_ERROR, "D3D12 decoder doesn't support on this device\n"); -return AVERROR(EINVAL); +if (!(feature.SupportFlags & D3D12_VIDEO_DECODE_SUPPORT_FLAG_SUPPORTED)) { +av_log(avctx, AV_LOG_ERROR, "D3D12 video decode is not supported on this device.\n"); +return AVERROR(ENOSYS); +} +if (!(feature.DecodeTier >= D3D12_VIDEO_DECODE_TIER_2)) { +av_log(avctx, AV_LOG_ERROR, "D3D12 video decode on this device requires tier %d support, " + "but it is not implemented.\n", feature.DecodeTier); +return AVERROR_PATCHWELCOME; } desc = (D3D12_VIDEO_DECODER_DESC) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter: Temporary hack to fix format negotiation for hw formats
ffmpeg | branch: master | Mark Thompson | Wed Jan 3 20:40:19 2024 +| [8b76bae8961c3045fa73aa2da47345c70a93d599] | committer: Mark Thompson avfilter: Temporary hack to fix format negotiation for hw formats hw_frames_ctx on the input link is only set when the input link is configured, which hasn't happened yet. This temporarily hacks around the problem (in a way no worse than before the format negotiation changes) until a proper fix can be applied. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8b76bae8961c3045fa73aa2da47345c70a93d599 --- libavfilter/avfiltergraph.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 727eff81ee..96aa137e6d 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -667,8 +667,12 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) if (link->type == AVMEDIA_TYPE_VIDEO) { enum AVPixelFormat swfmt = link->format; if (av_pix_fmt_desc_get(swfmt)->flags & AV_PIX_FMT_FLAG_HWACCEL) { -av_assert1(link->hw_frames_ctx); -swfmt = ((AVHWFramesContext *) link->hw_frames_ctx->data)->sw_format; +// FIXME: this is a hack - we'd like to use the sw_format of +// link->hw_frames_ctx here, but it is not yet available. +// To make this work properly we will need to either reorder +// things so that it is available here or somehow negotiate +// sw_format separately. +swfmt = AV_PIX_FMT_YUV420P; } if (!ff_fmt_is_regular_yuv(swfmt)) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_av1: Make fake OBU size length field a write option
ffmpeg | branch: master | Mark Thompson | Mon Sep 25 12:44:58 2023 +0100| [014c13863327519418ca8bd15d21c4e8a58d9227] | committer: Mark Thompson cbs_av1: Make fake OBU size length field a write option This is an option to modify the behaviour of the writer, not a syntax field. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=014c13863327519418ca8bd15d21c4e8a58d9227 --- libavcodec/cbs_av1.c | 31 +-- libavcodec/cbs_av1.h | 5 - libavcodec/vaapi_encode_av1.c | 4 +++- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index 4e687ace79..ed9a7b80d4 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -138,19 +138,25 @@ static int cbs_av1_read_leb128(CodedBitstreamContext *ctx, GetBitContext *gbc, return 0; } -/** Minimum byte length will be used to indicate the len128 of value if byte_len is 0. */ static int cbs_av1_write_leb128(CodedBitstreamContext *ctx, PutBitContext *pbc, -const char *name, uint64_t value, uint8_t byte_len) +const char *name, uint64_t value, int fixed_length) { int len, i; uint8_t byte; CBS_TRACE_WRITE_START(); -if (byte_len) -av_assert0(byte_len >= (av_log2(value) + 7) / 7); +len = (av_log2(value) + 7) / 7; -len = byte_len ? byte_len : (av_log2(value) + 7) / 7; +if (fixed_length) { +if (fixed_length < len) { +av_log(ctx->log_ctx, AV_LOG_ERROR, "OBU is too large for " + "fixed length size field (%d > %d).\n", + len, fixed_length); +return AVERROR(EINVAL); +} +len = fixed_length; +} for (i = 0; i < len; i++) { if (put_bits_left(pbc) < 8) @@ -1006,8 +1012,8 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, if (obu->header.obu_has_size_field) { pbc_tmp = *pbc; -if (obu->obu_size_byte_len) { -for (int i = 0; i < obu->obu_size_byte_len; i++) +if (priv->fixed_obu_size_length) { +for (int i = 0; i < priv->fixed_obu_size_length; i++) put_bits(pbc, 8, 0); } else { // Add space for the size field to fill later. @@ -1133,7 +1139,8 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, end_pos /= 8; *pbc = pbc_tmp; -err = cbs_av1_write_leb128(ctx, pbc, "obu_size", obu->obu_size, obu->obu_size_byte_len); +err = cbs_av1_write_leb128(ctx, pbc, "obu_size", obu->obu_size, + priv->fixed_obu_size_length); if (err < 0) goto error; @@ -1150,10 +1157,12 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, } if (obu->obu_size > 0) { -if (!obu->obu_size_byte_len) { -obu->obu_size_byte_len = start_pos - data_pos; +if (!priv->fixed_obu_size_length) { memmove(pbc->buf + data_pos, pbc->buf + start_pos, header_size); +} else { +// The size was fixed so the following data was +// already written in the correct place. } skip_put_bytes(pbc, header_size); @@ -1273,6 +1282,8 @@ static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = { static const AVOption cbs_av1_options[] = { { "operating_point", "Set operating point to select layers to parse from a scalable bitstream", OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, AV1_MAX_OPERATING_POINTS - 1, 0 }, +{ "fixed_obu_size_length", "Set fixed length of the obu_size field", + OFFSET(fixed_obu_size_length), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 8, 0 }, { NULL } }; diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h index a9e2d2284f..7924257164 100644 --- a/libavcodec/cbs_av1.h +++ b/libavcodec/cbs_av1.h @@ -401,7 +401,6 @@ typedef struct AV1RawOBU { AV1RawOBUHeader header; size_t obu_size; -uint8_t obu_size_byte_len; union { AV1RawSequenceHeader sequence_header; @@ -468,6 +467,10 @@ typedef struct CodedBitstreamAV1Context { // AVOptions int operating_point; +// When writing, fix the length in bytes of the obu_size field. +// Writing will fail with an error if an OBU larger than can be +// represented by the fixed size is encountered. +int fixed_obu_size_length; } CodedBitstreamAV1Context; diff --git a/libavcodec/vaapi_encode_av1.c b/libavcodec/vaapi_encode_av1.c index 3ff1c47b53..5a9ff0f798 100644 --- a/libavcodec/vaapi_encode_av1.c +++ b/libavcodec/vaapi_encode_av1.c @@ -634,7 +634,6 @@ static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx, } } -fh_obu->obu_size_byte_l
[FFmpeg-cvslog] cbs: Make tracing more general
ffmpeg | branch: master | Mark Thompson | Mon Sep 11 15:52:26 2023 +0800| [abe16daea1b72323e3544cb6ec12bec010b6ba54] | committer: Haihao Xiang cbs: Make tracing more general Turn tracing into callbacks for each syntax element, with default callbacks to match current trace_headers behaviour for debug. Move the construction of bit strings into the trace callback, which simplifies all of the read and write functions. Signed-off-by: Fei Wang Reviewed-by: Neal Gompa > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=abe16daea1b72323e3544cb6ec12bec010b6ba54 --- libavcodec/cbs.c | 121 libavcodec/cbs.h | 88 +- libavcodec/cbs_av1.c | 206 +++-- libavcodec/cbs_bsf.c | 5 + libavcodec/cbs_h2645.c | 134 +++ libavcodec/cbs_internal.h | 85 - libavcodec/cbs_vp9.c | 108 ++--- libavcodec/trace_headers_bsf.c | 2 + 8 files changed, 373 insertions(+), 376 deletions(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 3ec8285e21..daf7f66427 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -117,8 +117,9 @@ av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr, ctx->decompose_unit_types = NULL; -ctx->trace_enable = 0; -ctx->trace_level = AV_LOG_TRACE; +ctx->trace_enable = 0; +ctx->trace_level = AV_LOG_TRACE; +ctx->trace_context = ctx; *ctx_ptr = ctx; return 0; @@ -496,19 +497,27 @@ void ff_cbs_trace_header(CodedBitstreamContext *ctx, av_log(ctx->log_ctx, ctx->trace_level, "%s\n", name); } -void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, - const char *str, const int *subscripts, - const char *bits, int64_t value) +void ff_cbs_trace_read_log(void *trace_context, + GetBitContext *gbc, int length, + const char *str, const int *subscripts, + int64_t value) { +CodedBitstreamContext *ctx = trace_context; char name[256]; +char bits[256]; size_t name_len, bits_len; int pad, subs, i, j, k, n; - -if (!ctx->trace_enable) -return; +int position; av_assert0(value >= INT_MIN && value <= UINT32_MAX); +position = get_bits_count(gbc); + +av_assert0(length < 256); +for (i = 0; i < length; i++) +bits[i] = get_bits1(gbc) ? '1' : '0'; +bits[length] = 0; + subs = subscripts ? subscripts[0] : 0; n = 0; for (i = j = 0; str[i];) { @@ -535,7 +544,7 @@ void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, av_assert0(n == subs); name_len = strlen(name); -bits_len = strlen(bits); +bits_len = length; if (name_len + bits_len > 60) pad = bits_len + 2; @@ -546,6 +555,36 @@ void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, position, name, pad, bits, value); } +void ff_cbs_trace_write_log(void *trace_context, +PutBitContext *pbc, int length, +const char *str, const int *subscripts, +int64_t value) +{ +CodedBitstreamContext *ctx = trace_context; + +// Ensure that the syntax element is written to the output buffer, +// make a GetBitContext pointed at the start position, then call the +// read log function which can read the bits back to log them. + +GetBitContext gbc; +int position; + +if (length > 0) { +PutBitContext flush; +flush = *pbc; +flush_put_bits(); +} + +position = put_bits_count(pbc); +av_assert0(position >= length); + +init_get_bits(, pbc->buf, position); + +skip_bits_long(, position - length); + +ff_cbs_trace_read_log(ctx, , length, str, subscripts, value); +} + static av_always_inline int cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, @@ -555,7 +594,8 @@ static av_always_inline int cbs_read_unsigned(CodedBitstreamContext *ctx, uint32_t range_max) { uint32_t value; -int position; + +CBS_TRACE_READ_START(); av_assert0(width > 0 && width <= 32); @@ -565,21 +605,9 @@ static av_always_inline int cbs_read_unsigned(CodedBitstreamContext *ctx, return AVERROR_INVALIDDATA; } -if (ctx->trace_enable) -position = get_bits_count(gbc); - value = get_bits_long(gbc, width); -if (ctx->trace_enable) { -char bits[33]; -int i; -for (i = 0; i < width; i++) -bits[i] = value >> (width
[FFmpeg-cvslog] cbs_av1: Remove constraint on MDCV luminance values
ffmpeg | branch: master | Mark Thompson | Wed Jan 18 20:30:50 2023 +| [aaa49a7a425ce3dc6ca8edc0e17ed16c98f699a6] | committer: Mark Thompson cbs_av1: Remove constraint on MDCV luminance values While desiring min to be less than max feels entirely sensible, unfortunately the standard does not actually have this requirement. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aaa49a7a425ce3dc6ca8edc0e17ed16c98f699a6 --- libavcodec/cbs_av1_syntax_template.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index d98d3d42de..e95925a493 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1862,11 +1862,8 @@ static int FUNC(metadata_hdr_mdcv)(CodedBitstreamContext *ctx, RWContext *rw, fb(16, white_point_chromaticity_x); fb(16, white_point_chromaticity_y); -fc(32, luminance_max, 1, MAX_UINT_BITS(32)); -// luminance_min must be lower than luminance_max. Convert luminance_max from -// 24.8 fixed point to 18.14 fixed point in order to compare them. -fc(32, luminance_min, 0, FFMIN(((uint64_t)current->luminance_max << 6) - 1, - MAX_UINT_BITS(32))); +fb(32, luminance_max); +fb(32, luminance_min); return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode_h265: Query encoding block sizes and features
ffmpeg | branch: master | Mark Thompson | Thu Mar 17 14:41:52 2022 +0800| [9f02e033875185409c861846f209b04a3be339d2] | committer: Haihao Xiang vaapi_encode_h265: Query encoding block sizes and features Signed-off-by: Fei Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9f02e033875185409c861846f209b04a3be339d2 --- libavcodec/vaapi_encode_h265.c | 114 ++--- 1 file changed, 108 insertions(+), 6 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 5b19381c5a..456307d570 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -56,6 +56,9 @@ typedef struct VAAPIEncodeH265Context { VAAPIEncodeContext common; // Encoder features. +uint32_t va_features; +// Block size info. +uint32_t va_bs; uint32_t ctu_size; uint32_t min_cb_size; @@ -427,9 +430,9 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) vps->vps_max_latency_increase_plus1[i]; } -// These have to come from the capabilities of the encoder. We have no -// way to query them, so just hardcode parameters which work on the Intel -// driver. +// These values come from the capabilities of the first encoder +// implementation in the i965 driver on Intel Skylake. They may +// fail badly with other platforms or drivers. // CTB size from 8x8 to 32x32. sps->log2_min_luma_coding_block_size_minus3 = 0; sps->log2_diff_max_min_luma_coding_block_size = 2; @@ -447,6 +450,42 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) sps->pcm_enabled_flag = 0; +// update sps setting according to queried result +#if VA_CHECK_VERSION(1, 13, 0) +if (priv->va_features) { +VAConfigAttribValEncHEVCFeatures features = { .value = priv->va_features }; + +// Enable feature if get queried result is VA_FEATURE_SUPPORTED | VA_FEATURE_REQUIRED +sps->amp_enabled_flag = +!!features.bits.amp; +sps->sample_adaptive_offset_enabled_flag = +!!features.bits.sao; +sps->sps_temporal_mvp_enabled_flag = +!!features.bits.temporal_mvp; +sps->pcm_enabled_flag = +!!features.bits.pcm; +} + +if (priv->va_bs) { +VAConfigAttribValEncHEVCBlockSizes bs = { .value = priv->va_bs }; +sps->log2_min_luma_coding_block_size_minus3 = +ff_ctz(priv->min_cb_size) - 3; +sps->log2_diff_max_min_luma_coding_block_size = +ff_ctz(priv->ctu_size) - ff_ctz(priv->min_cb_size); + +sps->log2_min_luma_transform_block_size_minus2 = +bs.bits.log2_min_luma_transform_block_size_minus2; +sps->log2_diff_max_min_luma_transform_block_size = +bs.bits.log2_max_luma_transform_block_size_minus2 - +bs.bits.log2_min_luma_transform_block_size_minus2; + +sps->max_transform_hierarchy_depth_inter = +bs.bits.max_max_transform_hierarchy_depth_inter; +sps->max_transform_hierarchy_depth_intra = +bs.bits.max_max_transform_hierarchy_depth_intra; +} +#endif + // STRPSs should ideally be here rather than defined individually in // each slice, but the structure isn't completely fixed so for now // don't bother. @@ -539,6 +578,23 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) pps->cu_qp_delta_enabled_flag = (ctx->va_rc_mode != VA_RC_CQP); pps->diff_cu_qp_delta_depth = 0; +// update pps setting according to queried result +#if VA_CHECK_VERSION(1, 13, 0) +if (priv->va_features) { +VAConfigAttribValEncHEVCFeatures features = { .value = priv->va_features }; +if (ctx->va_rc_mode != VA_RC_CQP) +pps->cu_qp_delta_enabled_flag = +!!features.bits.cu_qp_delta; + +pps->transform_skip_enabled_flag = +!!features.bits.transform_skip; +// set diff_cu_qp_delta_depth as its max value if cu_qp_delta enabled. Otherwise +// 0 will make cu_qp_delta invalid. +if (pps->cu_qp_delta_enabled_flag) +pps->diff_cu_qp_delta_depth = sps->log2_diff_max_min_luma_coding_block_size; +} +#endif + if (ctx->tile_rows && ctx->tile_cols) { int uniform_spacing; @@ -640,8 +696,8 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) .coded_buf = VA_INVALID_ID, -.collocated_ref_pic_index = 0xff, - +.collocated_ref_pic_index = sps->sps_temporal_mvp_enabled_flag ? +0 : 0xff, .last_picture = 0, .pic_init_qp= pps->init_qp_minus26 + 26, @@ -674,6 +730,8 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) .entropy
[FFmpeg-cvslog] vaapi_encode: Move block size calculation after entrypoint selection
ffmpeg | branch: master | Mark Thompson | Thu Mar 17 14:41:50 2022 +0800| [99b333e5ff5a91de2a5d740bbc9fa344154511c1] | committer: Haihao Xiang vaapi_encode: Move block size calculation after entrypoint selection The block size can be dependent on the profile and entrypoint selected. It defaults to 16x16, with codecs able to override this choice with their own function. Signed-off-by: Fei Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=99b333e5ff5a91de2a5d740bbc9fa344154511c1 --- libavcodec/vaapi_encode.c | 16 libavcodec/vaapi_encode.h | 7 +++ libavcodec/vaapi_encode_h265.c | 32 ++-- libavcodec/vaapi_encode_mjpeg.c | 18 +++--- libavcodec/vaapi_encode_mpeg2.c | 3 --- libavcodec/vaapi_encode_vp8.c | 3 --- libavcodec/vaapi_encode_vp9.c | 16 7 files changed, 76 insertions(+), 19 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 21a0ed0827..0e2f5ed447 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -2117,6 +2117,8 @@ static av_cold int vaapi_encode_init_slice_structure(AVCodecContext *avctx) return 0; } +av_assert0(ctx->slice_block_height > 0 && ctx->slice_block_width > 0); + ctx->slice_block_rows = (avctx->height + ctx->slice_block_height - 1) / ctx->slice_block_height; ctx->slice_block_cols = (avctx->width + ctx->slice_block_width - 1) / @@ -2506,6 +2508,20 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx) if (err < 0) goto fail; +if (ctx->codec->get_encoder_caps) { +err = ctx->codec->get_encoder_caps(avctx); +if (err < 0) +goto fail; +} else { +// Assume 16x16 blocks. +ctx->surface_width = FFALIGN(avctx->width, 16); +ctx->surface_height = FFALIGN(avctx->height, 16); +if (ctx->codec->flags & FLAG_SLICE_CONTROL) { +ctx->slice_block_width = 16; +ctx->slice_block_height = 16; +} +} + err = vaapi_encode_init_rate_control(avctx); if (err < 0) goto fail; diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 4596e49ba9..af0588c30b 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -386,6 +386,13 @@ typedef struct VAAPIEncodeType { // factor depending on RC mode. int default_quality; +// Determine encode parameters like block sizes for surface alignment +// and slices. This may need to query the profile and entrypoint, +// which will be available when this function is called. If not set, +// assume that all blocks are 16x16 and that surfaces should be +// aligned to match this. +int (*get_encoder_caps)(AVCodecContext *avctx); + // Perform any extra codec-specific configuration after the // codec context is initialised (set up the private data and // add any necessary global parameters). diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 76d67237d2..3fa1336bb0 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -55,6 +55,10 @@ typedef struct VAAPIEncodeH265Picture { typedef struct VAAPIEncodeH265Context { VAAPIEncodeContext common; +// Encoder features. +uint32_t ctu_size; +uint32_t min_cb_size; + // User options. int qp; int aud; @@ -1091,6 +1095,27 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, return 0; } +static av_cold int vaapi_encode_h265_get_encoder_caps(AVCodecContext *avctx) +{ +VAAPIEncodeContext *ctx = avctx->priv_data; +VAAPIEncodeH265Context *priv = avctx->priv_data; + +if (!priv->ctu_size) { +priv->ctu_size = 32; +priv->min_cb_size = 16; +} +av_log(avctx, AV_LOG_VERBOSE, "Using CTU size %dx%d, " + "min CB size %dx%d.\n", priv->ctu_size, priv->ctu_size, + priv->min_cb_size, priv->min_cb_size); + +ctx->surface_width = FFALIGN(avctx->width, priv->min_cb_size); +ctx->surface_height = FFALIGN(avctx->height, priv->min_cb_size); + +ctx->slice_block_width = ctx->slice_block_height = priv->ctu_size; + +return 0; +} + static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; @@ -1160,6 +1185,7 @@ static const VAAPIEncodeType vaapi_encode_type_h265 = { .default_quality = 25, +.get_encoder_caps = _encode_h265_get_encoder_caps, .configure = _encode_h265_configure, .picture_priv_data_size = sizeof(VAAPIEncodeH265Picture), @@ -1205,12 +1231,6 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx) VA_ENC_PA
[FFmpeg-cvslog] vaapi_encode_h265: Explicitly set and correct some flags
ffmpeg | branch: master | Mark Thompson | Thu Mar 17 14:41:51 2022 +0800| [77fd2f9c7c5c82e5991225a005f4f724ea5a207b] | committer: Haihao Xiang vaapi_encode_h265: Explicitly set and correct some flags max_14bit_constraint_flag should be set if the bit depth is not greater than 14 (currently always true). one_picture_only_flag should not be set because we don't support the still picture profiles. general_profile_compatibility_flag should be set according to general_profile_idc instead of bit depth. Signed-off-by: Fei Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=77fd2f9c7c5c82e5991225a005f4f724ea5a207b --- libavcodec/vaapi_encode_h265.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 3fa1336bb0..5b19381c5a 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -303,17 +303,21 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) ptl->general_profile_idc = avctx->profile; ptl->general_tier_flag = priv->tier; -if (chroma_format == 1) { -ptl->general_profile_compatibility_flag[1] = bit_depth == 8; -ptl->general_profile_compatibility_flag[2] = bit_depth <= 10; +ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1; + +if (ptl->general_profile_compatibility_flag[1]) +ptl->general_profile_compatibility_flag[2] = 1; +if (ptl->general_profile_compatibility_flag[3]) { +ptl->general_profile_compatibility_flag[1] = 1; +ptl->general_profile_compatibility_flag[2] = 1; } -ptl->general_profile_compatibility_flag[4] = 1; ptl->general_progressive_source_flag= 1; ptl->general_interlaced_source_flag = 0; ptl->general_non_packed_constraint_flag = 1; ptl->general_frame_only_constraint_flag = 1; +ptl->general_max_14bit_constraint_flag = bit_depth <= 14; ptl->general_max_12bit_constraint_flag = bit_depth <= 12; ptl->general_max_10bit_constraint_flag = bit_depth <= 10; ptl->general_max_8bit_constraint_flag = bit_depth == 8; @@ -323,6 +327,7 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) ptl->general_max_monochrome_constraint_flag = chroma_format == 0; ptl->general_intra_constraint_flag = ctx->gop_size == 1; +ptl->general_one_picture_only_constraint_flag = 0; ptl->general_lower_bit_rate_constraint_flag = 1; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_sei: Detect payload overflows when reading SEI messages
ffmpeg | branch: master | Mark Thompson | Tue Feb 2 20:58:11 2021 +| [2c96e6cb955af3062e78c5b0f9fb907cfb2e59e3] | committer: Mark Thompson cbs_sei: Detect payload overflows when reading SEI messages The top-level GetBitContext is sized for the whole NAL unit, so it fails to detect overflows where a payload continues into the following message. To fix that, we make a new context on the stack for reading each payload. Fixes: 29892/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_REDUNDANT_PPS_fuzzer-6310830956216320 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Tested-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2c96e6cb955af3062e78c5b0f9fb907cfb2e59e3 --- libavcodec/cbs_sei_syntax_template.c | 17 - 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libavcodec/cbs_sei_syntax_template.c b/libavcodec/cbs_sei_syntax_template.c index 9114e61ff6..0ef7b42ed9 100644 --- a/libavcodec/cbs_sei_syntax_template.c +++ b/libavcodec/cbs_sei_syntax_template.c @@ -238,6 +238,7 @@ static int FUNC(message_list)(CodedBitstreamContext *ctx, RWContext *rw, uint32_t payload_type = 0; uint32_t payload_size = 0; uint32_t tmp; +GetBitContext payload_gbc; while (show_bits(rw, 8) == 0xff) { fixed(8, ff_byte, 0xff); @@ -253,13 +254,27 @@ static int FUNC(message_list)(CodedBitstreamContext *ctx, RWContext *rw, xu(8, last_payload_size_byte, tmp, 0, 254, 0); payload_size += tmp; +// There must be space remaining for both the payload and +// the trailing bits on the SEI NAL unit. +if (payload_size + 1 > get_bits_left(rw) / 8) { +av_log(ctx->log_ctx, AV_LOG_ERROR, + "Invalid SEI message: payload_size too large " + "(%"PRIu32" bytes).\n", payload_size); +return AVERROR_INVALIDDATA; +} +CHECK(init_get_bits(_gbc, rw->buffer, +get_bits_count(rw) + 8 * payload_size)); +skip_bits_long(_gbc, get_bits_count(rw)); + CHECK(ff_cbs_sei_list_add(current)); message = >messages[k]; message->payload_type = payload_type; message->payload_size = payload_size; -CHECK(FUNC(message)(ctx, rw, message)); +CHECK(FUNC(message)(ctx, _gbc, message)); + +skip_bits_long(rw, 8 * payload_size); if (!cbs_h2645_read_more_rbsp_data(rw)) break; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h265: Detect more reference combinations which would overflow the DPB
ffmpeg | branch: master | Mark Thompson | Wed Feb 3 21:34:07 2021 +| [b128b0ce2203f96ff86969f6d0039827a7f00378] | committer: Mark Thompson cbs_h265: Detect more reference combinations which would overflow the DPB In total, the number of short term references (from the selected short term ref pic set), the number of long term references (combining both the used candidates from the SPS and those defined in the slice header) and the number of instances of the current picture (usually one, but can be two if current picture reference is enabled) must never exceed the size of the DPB. This is a generalisation of the condition associated with num_long_term_pics in 7.4.7.1. We use this to apply tighter bounds to the number of long term pictures referred to in the slice header, and also to detect the invalid case where the second reference to the current picture would not fit in the DPB (this case can't be detected earlier because an STRPS with 15 pictures can still be valid in the same stream when used with a different PPS which does not require two DPB slots for the current picture). Fixes: 24913/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6261760693370880 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Tested-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b128b0ce2203f96ff86969f6d0039827a7f00378 --- libavcodec/cbs_h265_syntax_template.c | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index d09934cfeb..5d216aad36 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -1369,6 +1369,7 @@ static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw, if (current->nal_unit_header.nal_unit_type != HEVC_NAL_IDR_W_RADL && current->nal_unit_header.nal_unit_type != HEVC_NAL_IDR_N_LP) { const H265RawSTRefPicSet *rps; +int dpb_slots_remaining; ub(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, slice_pic_order_cnt_lsb); @@ -1387,6 +1388,22 @@ static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw, rps = >st_ref_pic_set[0]; } +dpb_slots_remaining = HEVC_MAX_DPB_SIZE - 1 - +rps->num_negative_pics - rps->num_positive_pics; +if (pps->pps_curr_pic_ref_enabled_flag && +(sps->sample_adaptive_offset_enabled_flag || + !pps->pps_deblocking_filter_disabled_flag || + pps->deblocking_filter_override_enabled_flag)) { +// This picture will occupy two DPB slots. +if (dpb_slots_remaining == 0) { +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: " + "short-term ref pic set contains too many pictures " + "to use with current picture reference enabled.\n"); +return AVERROR_INVALIDDATA; +} +--dpb_slots_remaining; +} + num_pic_total_curr = 0; for (i = 0; i < rps->num_negative_pics; i++) if (rps->used_by_curr_pic_s0_flag[i]) @@ -1399,13 +1416,15 @@ static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw, unsigned int idx_size; if (sps->num_long_term_ref_pics_sps > 0) { -ue(num_long_term_sps, 0, sps->num_long_term_ref_pics_sps); +ue(num_long_term_sps, 0, FFMIN(sps->num_long_term_ref_pics_sps, + dpb_slots_remaining)); idx_size = av_log2(sps->num_long_term_ref_pics_sps - 1) + 1; +dpb_slots_remaining -= current->num_long_term_sps; } else { infer(num_long_term_sps, 0); idx_size = 0; } -ue(num_long_term_pics, 0, HEVC_MAX_REFS - current->num_long_term_sps); +ue(num_long_term_pics, 0, dpb_slots_remaining); for (i = 0; i < current->num_long_term_sps + current->num_long_term_pics; i++) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/vf_pseudocolor: Add missing braces
ffmpeg | branch: master | Mark Thompson | Tue Feb 2 21:50:37 2021 +| [5a9aebac91e225440fd5f30897b88d6bdf265813] | committer: Mark Thompson avfilter/vf_pseudocolor: Add missing braces The array inside a structure needs two levels of braces. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5a9aebac91e225440fd5f30897b88d6bdf265813 --- libavfilter/vf_pseudocolor.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_pseudocolor.c b/libavfilter/vf_pseudocolor.c index fad7be600c..6f67c02eb7 100644 --- a/libavfilter/vf_pseudocolor.c +++ b/libavfilter/vf_pseudocolor.c @@ -108,10 +108,10 @@ static const Range spec2_range[] = {{0, 16}, {16, 22}, {22, 226}, {226, 236}, {2 static const Range shadows_range[] = {{0, 32}, {32, 256}}; static const Range highlights_range[] = {{0, 214}, {214, 224}, {224, 256}}; -static const Fill spec1_fills[] = {{0.5f, 0.f, .5f, 1.f}, {-1.f, -1.f, -1.f, 1.f}, {1.f, 0.f, 0.f, 1.f}}; -static const Fill spec2_fills[] = {{0.5f, 0.f, .5f, 1.f}, {0.f, 1.f, 1.f, 1.f}, {-1.f, -1.f, -1.f, 1.f}, {1.f, 1.f, 0.f, 1.f}, {1.f, 0.f, 0.f, 1.f}}; -static const Fill shadows_fills[] = {{0.8f, 0.4f, .8f, 1.f}, {-1.f, -1.f, -1.f, 1.f}}; -static const Fill highlights_fills[] = {{-1.f, -1.f, -1.f, 1.f}, {1.f, 0.3f, 0.6f, 1.f}, {1.f, 0.2f, .5f, 1.f}}; +static const Fill spec1_fills[] = {{{0.5f, 0.f, .5f, 1.f}}, {{-1.f, -1.f, -1.f, 1.f}}, {{1.f, 0.f, 0.f, 1.f}}}; +static const Fill spec2_fills[] = {{{0.5f, 0.f, .5f, 1.f}}, {{0.f, 1.f, 1.f, 1.f}}, {{-1.f, -1.f, -1.f, 1.f}}, {{1.f, 1.f, 0.f, 1.f}}, {{1.f, 0.f, 0.f, 1.f}}}; +static const Fill shadows_fills[] = {{{0.8f, 0.4f, .8f, 1.f}}, {{-1.f, -1.f, -1.f, 1.f}}}; +static const Fill highlights_fills[] = {{{-1.f, -1.f, -1.f, 1.f}}, {{1.f, 0.3f, 0.6f, 1.f}}, {{1.f, 0.2f, .5f, 1.f}}}; static const Curve curves[] = { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vc2enc: Add missing static to local variables
ffmpeg | branch: master | Mark Thompson | Mon Jan 25 22:07:01 2021 +| [ac05413dfbd9acae0e6b0a169c22aeafbd34b73a] | committer: Mark Thompson vc2enc: Add missing static to local variables > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ac05413dfbd9acae0e6b0a169c22aeafbd34b73a --- libavcodec/vc2enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index bab9d0f3d5..7bd2e4c2ab 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -423,7 +423,7 @@ static void encode_slice_params(VC2EncContext *s) } /* 1st idx = LL, second - vertical, third - horizontal, fourth - total */ -const uint8_t vc2_qm_col_tab[][4] = { +static const uint8_t vc2_qm_col_tab[][4] = { {20, 9, 15, 4}, { 0, 6, 6, 4}, { 0, 3, 3, 5}, @@ -431,7 +431,7 @@ const uint8_t vc2_qm_col_tab[][4] = { { 0, 11, 10, 11} }; -const uint8_t vc2_qm_flat_tab[][4] = { +static const uint8_t vc2_qm_flat_tab[][4] = { { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] dnn: Add ff_ prefix to unnamespaced globals
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 21:39:55 2021 +| [bb96824510aad2ac4cf0bff545c85af7a256ff92] | committer: Guo, Yejun dnn: Add ff_ prefix to unnamespaced globals Reviewed-By: Guo, Yejun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bb96824510aad2ac4cf0bff545c85af7a256ff92 --- libavfilter/dnn/dnn_backend_native.c | 10 +- libavfilter/dnn/dnn_backend_native.h | 4 ++-- libavfilter/dnn/dnn_backend_native_layer_avgpool.c | 8 libavfilter/dnn/dnn_backend_native_layer_avgpool.h | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 8 libavfilter/dnn/dnn_backend_native_layer_conv2d.h | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_dense.c | 8 libavfilter/dnn/dnn_backend_native_layer_dense.h | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_depth2space.c | 8 libavfilter/dnn/dnn_backend_native_layer_depth2space.h | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_mathbinary.c | 12 ++-- libavfilter/dnn/dnn_backend_native_layer_mathbinary.h | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_mathunary.c | 10 +- libavfilter/dnn/dnn_backend_native_layer_mathunary.h | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_maximum.c | 10 +- libavfilter/dnn/dnn_backend_native_layer_maximum.h | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_pad.c | 8 libavfilter/dnn/dnn_backend_native_layer_pad.h | 6 +++--- libavfilter/dnn/dnn_backend_native_layers.c| 18 +- libavfilter/dnn/dnn_backend_native_layers.h| 2 +- 20 files changed, 77 insertions(+), 77 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c index be43081170..1f89ee4110 100644 --- a/libavfilter/dnn/dnn_backend_native.c +++ b/libavfilter/dnn/dnn_backend_native.c @@ -208,7 +208,7 @@ DNNModel *ff_dnn_load_model_native(const char *model_filename, const char *optio } native_model->layers[layer].type = layer_type; -parsed_size = layer_funcs[layer_type].pf_load(_model->layers[layer], model_file_context, file_size, native_model->operands_num); +parsed_size = ff_layer_funcs[layer_type].pf_load(_model->layers[layer], model_file_context, file_size, native_model->operands_num); if (!parsed_size) { goto fail; } @@ -300,7 +300,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp oprd->dims[2] = in_frame->width; av_freep(>data); -oprd->length = calculate_operand_data_length(oprd); +oprd->length = ff_calculate_operand_data_length(oprd); if (oprd->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The input data length overflow\n"); return DNN_ERROR; @@ -333,7 +333,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp for (layer = 0; layer < native_model->layers_num; ++layer){ DNNLayerType layer_type = native_model->layers[layer].type; -if (layer_funcs[layer_type].pf_exec(native_model->operands, +if (ff_layer_funcs[layer_type].pf_exec(native_model->operands, native_model->layers[layer].input_operand_indexes, native_model->layers[layer].output_operand_index, native_model->layers[layer].params, @@ -398,7 +398,7 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char *inp return execute_model_native(model, input_name, in_frame, output_names, nb_output, out_frame, 1); } -int32_t calculate_operand_dims_count(const DnnOperand *oprd) +int32_t ff_calculate_operand_dims_count(const DnnOperand *oprd) { int32_t result = 1; for (int i = 0; i < 4; ++i) @@ -407,7 +407,7 @@ int32_t calculate_operand_dims_count(const DnnOperand *oprd) return result; } -int32_t calculate_operand_data_length(const DnnOperand* oprd) +int32_t ff_calculate_operand_data_length(const DnnOperand* oprd) { // currently, we just support DNN_FLOAT uint64_t len = sizeof(float); diff --git a/libavfilter/dnn/dnn_backend_native.h b/libavfilter/dnn/dnn_backend_native.h index 5acdbe0da7..5c8ce82b35 100644 --- a/libavfilter/dnn/dnn_backend_native.h +++ b/libavfilter/dnn/dnn_backend_native.h @@ -137,6 +137,6 @@ void ff_dnn_free_model_native(DNNModel **model); // NOTE: User must check for error (return value <= 0) to handle // case like integer overflow. -int32_t calculate_operand_data_length(const DnnOperand *oprd); -int32_t calculate_operand_dims_count(const DnnOperand *oprd); +int32_t ff_calculate_operand_data_length(const DnnOperand *oprd); +int32_t ff_calculate_operand_dims_count(const DnnOperand *op
[FFmpeg-cvslog] dnn_backend_native.c: Add missing static to local variable
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 21:39:53 2021 +| [2c424d963039a7d50b5b93f0db5efd70101d8e44] | committer: Guo, Yejun dnn_backend_native.c: Add missing static to local variable > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2c424d963039a7d50b5b93f0db5efd70101d8e44 --- libavfilter/dnn/dnn_backend_native.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c index 2c0b938839..be43081170 100644 --- a/libavfilter/dnn/dnn_backend_native.c +++ b/libavfilter/dnn/dnn_backend_native.c @@ -36,7 +36,7 @@ static const AVOption dnn_native_options[] = { { NULL }, }; -const AVClass dnn_native_class = { +static const AVClass dnn_native_class = { .class_name = "dnn_native", .item_name = av_default_item_name, .option = dnn_native_options, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] dnn_backend_native_layer_mathbinary.c: Delete unused global variable
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 21:39:52 2021 +| [c6a3ca2db491a66af9b1f5b12cbe3058713caf0b] | committer: Guo, Yejun dnn_backend_native_layer_mathbinary.c: Delete unused global variable > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c6a3ca2db491a66af9b1f5b12cbe3058713caf0b --- libavfilter/dnn/dnn_backend_native_layer_mathbinary.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c index 998a75245c..fc48242093 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c @@ -28,7 +28,6 @@ #include "dnn_backend_native_layer_mathbinary.h" typedef float (*FunType)(float src0, float src1); -FunType pfun; static float sub(float src0, float src1) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavd/dshow: Add namespace prefix to global functions
ffmpeg | branch: master | Mark Thompson | Mon Jun 25 19:47:03 2018 +0100| [c154aada45588a01cfa2adb5e56ed197eb3e4bfd] | committer: James Almer lavd/dshow: Add namespace prefix to global functions > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c154aada45588a01cfa2adb5e56ed197eb3e4bfd --- libavdevice/dshow.c | 6 +++--- libavdevice/dshow_capture.h | 4 ++-- libavdevice/dshow_crossbar.c | 8 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index d7f5bd7069..1b9e5be399 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -510,7 +510,7 @@ end: * Pops up a user dialog allowing them to adjust properties for the given filter, if possible. */ void -dshow_show_filter_properties(IBaseFilter *device_filter, AVFormatContext *avctx) { +ff_dshow_show_filter_properties(IBaseFilter *device_filter, AVFormatContext *avctx) { ISpecifyPropertyPages *property_pages = NULL; IUnknown *device_filter_iunknown = NULL; HRESULT hr; @@ -582,7 +582,7 @@ dshow_cycle_pins(AVFormatContext *avctx, enum dshowDeviceType devtype, int should_show_properties = (devtype == VideoDevice) ? ctx->show_video_device_dialog : ctx->show_audio_device_dialog; if (should_show_properties) -dshow_show_filter_properties(device_filter, avctx); +ff_dshow_show_filter_properties(device_filter, avctx); r = IBaseFilter_EnumPins(device_filter, ); if (r != S_OK) { @@ -887,7 +887,7 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, goto error; } -r = dshow_try_setup_crossbar_options(graph_builder2, device_filter, devtype, avctx); +r = ff_dshow_try_setup_crossbar_options(graph_builder2, device_filter, devtype, avctx); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not setup CrossBar\n"); diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h index 475d62ba99..79c004a87f 100644 --- a/libavdevice/dshow_capture.h +++ b/libavdevice/dshow_capture.h @@ -346,9 +346,9 @@ struct dshow_ctx { /* * CrossBar / -HRESULT dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, +HRESULT ff_dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormatContext *avctx); -void dshow_show_filter_properties(IBaseFilter *pFilter, AVFormatContext *avctx); +void ff_dshow_show_filter_properties(IBaseFilter *pFilter, AVFormatContext *avctx); #endif /* AVDEVICE_DSHOW_CAPTURE_H */ diff --git a/libavdevice/dshow_crossbar.c b/libavdevice/dshow_crossbar.c index 95fb466f4e..2438683cde 100644 --- a/libavdevice/dshow_crossbar.c +++ b/libavdevice/dshow_crossbar.c @@ -137,7 +137,7 @@ setup_crossbar_options(IAMCrossbar *cross_bar, enum dshowDeviceType devtype, AVF * Given a fully constructed graph, check if there is a cross bar filter, and configure its pins if so. */ HRESULT -dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, +ff_dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormatContext *avctx) { struct dshow_ctx *ctx = avctx->priv_data; @@ -163,7 +163,7 @@ dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, hr = IAMCrossbar_QueryInterface(cross_bar, _IBaseFilter, (void **) _bar_base_filter); if (hr != S_OK) goto end; -dshow_show_filter_properties(cross_bar_base_filter, avctx); +ff_dshow_show_filter_properties(cross_bar_base_filter, avctx); } if (devtype == VideoDevice && ctx->show_analog_tv_tuner_dialog) { @@ -173,7 +173,7 @@ dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, hr = IAMCrossbar_QueryInterface(tv_tuner_filter, _IBaseFilter, (void **) _tuner_base_filter); if (hr != S_OK) goto end; -dshow_show_filter_properties(tv_tuner_base_filter, avctx); +ff_dshow_show_filter_properties(tv_tuner_base_filter, avctx); } else { av_log(avctx, AV_LOG_WARNING, "unable to find a tv tuner to display dialog for!"); } @@ -185,7 +185,7 @@ dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, hr = IAMCrossbar_QueryInterface(tv_audio_filter, _IBaseFilter, (void **) _audio_base_filter); if (hr != S_OK) goto end; -dshow_show_filter_properties(tv_audio_base_filter, avctx); +ff_dshow_show_filter_properties(tv_audio_base_filter, avctx); } else { av_log(avctx, AV_LOG_WARNING, "un
[FFmpeg-cvslog] h264_redundant_pps_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:23 2021 +| [fa75e438756f159a667080dcba58ea2e3b190001] | committer: Mark Thompson h264_redundant_pps_bsf: Use common cbs bsf implementation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fa75e438756f159a667080dcba58ea2e3b190001 --- libavcodec/h264_redundant_pps_bsf.c | 99 - 1 file changed, 21 insertions(+), 78 deletions(-) diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c index cf41abe96c..6ba40291d5 100644 --- a/libavcodec/h264_redundant_pps_bsf.c +++ b/libavcodec/h264_redundant_pps_bsf.c @@ -24,15 +24,13 @@ #include "bsf.h" #include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_h264.h" #include "h264.h" typedef struct H264RedundantPPSContext { -CodedBitstreamContext *input; -CodedBitstreamContext *output; - -CodedBitstreamFragment access_unit; +CBSBSFContext common; int global_pic_init_qp; int current_pic_init_qp; @@ -49,7 +47,7 @@ static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx, // The changes we are about to perform affect the parsing process, // so we must make sure that the PPS is writable, otherwise the // parsing of future slices will be incorrect and even raise errors. -err = ff_cbs_make_unit_writable(ctx->input, unit); +err = ff_cbs_make_unit_writable(ctx->common.input, unit); if (err < 0) return err; pps = unit->content; @@ -78,21 +76,14 @@ static int h264_redundant_pps_fixup_slice(H264RedundantPPSContext *ctx, return 0; } -static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *pkt) +static int h264_redundant_pps_update_fragment(AVBSFContext *bsf, + AVPacket *pkt, + CodedBitstreamFragment *au) { H264RedundantPPSContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = >access_unit; int au_has_sps; int err, i; -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = ff_cbs_read_packet(ctx->input, au, pkt); -if (err < 0) -goto fail; - au_has_sps = 0; for (i = 0; i < au->nb_units; i++) { CodedBitstreamUnit *nal = >units[i]; @@ -102,7 +93,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *pkt) if (nal->type == H264_NAL_PPS) { err = h264_redundant_pps_fixup_pps(ctx, nal); if (err < 0) -goto fail; +return err; if (!au_has_sps) { av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS " "at %"PRId64".\n", pkt->pts); @@ -118,62 +109,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *pkt) } } -err = ff_cbs_write_packet(ctx->output, pkt, au); -if (err < 0) -goto fail; - -err = 0; -fail: -ff_cbs_fragment_reset(au); -if (err < 0) -av_packet_unref(pkt); - -return err; -} - -static int h264_redundant_pps_init(AVBSFContext *bsf) -{ -H264RedundantPPSContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = >access_unit; -int err, i; - -err = ff_cbs_init(>input, AV_CODEC_ID_H264, bsf); -if (err < 0) -return err; - -err = ff_cbs_init(>output, AV_CODEC_ID_H264, bsf); -if (err < 0) -return err; - -ctx->global_pic_init_qp = 26; - -if (bsf->par_in->extradata) { -err = ff_cbs_read_extradata(ctx->input, au, bsf->par_in); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n"); -goto fail; -} - -for (i = 0; i < au->nb_units; i++) { -if (au->units[i].type == H264_NAL_PPS) { -err = h264_redundant_pps_fixup_pps(ctx, >units[i]); -if (err < 0) -goto fail; -} -} - -ctx->extradata_pic_init_qp = ctx->current_pic_init_qp; -err = ff_cbs_write_extradata(ctx->output, bsf->par_out, au); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n"); -goto fail; -} -} - -err = 0; -fail: -ff_cbs_fragment_reset(au); -return err; +return 0; } static void h264_redundant_pps_flush(AVBSFContext *bsf) @@ -182,13 +118,20 @@ static void h264_redundant_pps_flush(AVBSFContext *bsf) ctx->current_pic_init_qp = ctx->extradata_pic_init_qp; } -static void h264_redundant_pps_close(AVBSFContext *bsf) +static const CBSBSFType h264_redundant_pps_type = { +.codec_id= AV_CODEC_ID_H264, +.
[FFmpeg-cvslog] av1_metadata_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:22 2021 +| [375176a540121959a2dd37e910934e77c71eb78a] | committer: Mark Thompson av1_metadata_bsf: Use common cbs bsf implementation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=375176a540121959a2dd37e910934e77c71eb78a --- libavcodec/av1_metadata_bsf.c | 176 +- 1 file changed, 21 insertions(+), 155 deletions(-) diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c index 3158ba995b..8cafe461d1 100644 --- a/libavcodec/av1_metadata_bsf.c +++ b/libavcodec/av1_metadata_bsf.c @@ -20,22 +20,12 @@ #include "libavutil/opt.h" #include "bsf.h" -#include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_av1.h" -enum { -PASS, -INSERT, -REMOVE, -}; - typedef struct AV1MetadataContext { -const AVClass *class; - -CodedBitstreamContext *input; -CodedBitstreamContext *output; -CodedBitstreamFragment access_unit; +CBSBSFContext common; int td; @@ -113,91 +103,27 @@ static int av1_metadata_update_sequence_header(AVBSFContext *bsf, return 0; } -static int av1_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) +static int av1_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, +CodedBitstreamFragment *frag) { AV1MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *frag = >access_unit; -uint8_t *side_data; -int side_data_size; -int err, i; - -side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, -_data_size); -if (!side_data_size) -return 0; - -err = ff_cbs_read(ctx->input, frag, side_data, side_data_size); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); -return err; -} - -for (i = 0; i < frag->nb_units; i++) { -if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) { -AV1RawOBU *obu = frag->units[i].content; -err = av1_metadata_update_sequence_header(bsf, >obu.sequence_header); -if (err < 0) -return err; -} -} - -err = ff_cbs_write_fragment_data(ctx->output, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); -return err; -} - -side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, frag->data_size); -if (!side_data) -return AVERROR(ENOMEM); -memcpy(side_data, frag->data, frag->data_size); - -ff_cbs_fragment_reset(frag); - -return 0; -} - -static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) -{ -AV1MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *frag = >access_unit; AV1RawOBU td, *obu; int err, i; -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = av1_metadata_update_side_data(bsf, pkt); -if (err < 0) -goto fail; - -err = ff_cbs_read_packet(ctx->input, frag, pkt); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); -goto fail; -} - -if (frag->nb_units == 0) { -av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n"); -err = AVERROR_INVALIDDATA; -goto fail; -} - for (i = 0; i < frag->nb_units; i++) { if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) { obu = frag->units[i].content; err = av1_metadata_update_sequence_header(bsf, >obu.sequence_header); if (err < 0) -goto fail; +return err; } } // If a Temporal Delimiter is present, it must be the first OBU. if (frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) { -if (ctx->td == REMOVE) +if (ctx->td == BSF_ELEMENT_REMOVE) ff_cbs_delete_unit(frag, 0); -} else if (ctx->td == INSERT) { +} else if (pkt && ctx->td == BSF_ELEMENT_INSERT) { td = (AV1RawOBU) { .header.obu_type = AV1_OBU_TEMPORAL_DELIMITER, }; @@ -206,7 +132,7 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) , NULL); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to insert Temporal Delimiter.\n"); -goto fail; +return err; } } @@ -217,86 +143,26 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) } } -err = ff_cbs_write_packet(ctx->output, pkt, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write
[FFmpeg-cvslog] vp9_metadata_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:21 2021 +| [e46aa5a894f8b3dcf44a4028af726a5882ed27df] | committer: Mark Thompson vp9_metadata_bsf: Use common cbs bsf implementation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e46aa5a894f8b3dcf44a4028af726a5882ed27df --- libavcodec/vp9_metadata_bsf.c | 61 --- 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/libavcodec/vp9_metadata_bsf.c b/libavcodec/vp9_metadata_bsf.c index 00a5580c4d..d904a0088d 100644 --- a/libavcodec/vp9_metadata_bsf.c +++ b/libavcodec/vp9_metadata_bsf.c @@ -21,15 +21,12 @@ #include "libavutil/opt.h" #include "bsf.h" -#include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_vp9.h" typedef struct VP9MetadataContext { -const AVClass *class; - -CodedBitstreamContext *cbc; -CodedBitstreamFragment fragment; +CBSBSFContext common; int color_space; int color_range; @@ -38,21 +35,11 @@ typedef struct VP9MetadataContext { } VP9MetadataContext; -static int vp9_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) +static int vp9_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, +CodedBitstreamFragment *frag) { VP9MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *frag = >fragment; -int err, i; - -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = ff_cbs_read_packet(ctx->cbc, frag, pkt); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); -goto fail; -} +int i; for (i = 0; i < frag->nb_units; i++) { VP9RawFrame *frame = frag->units[i].content; @@ -90,35 +77,19 @@ static int vp9_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) } } -err = ff_cbs_write_packet(ctx->cbc, pkt, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); -goto fail; -} - -err = 0; -fail: -ff_cbs_fragment_reset(frag); - -if (err < 0) -av_packet_unref(pkt); - -return err; +return 0; } -static int vp9_metadata_init(AVBSFContext *bsf) -{ -VP9MetadataContext *ctx = bsf->priv_data; - -return ff_cbs_init(>cbc, AV_CODEC_ID_VP9, bsf); -} +static const CBSBSFType vp9_metadata_type = { +.codec_id= AV_CODEC_ID_VP9, +.fragment_name = "superframe", +.unit_name = "frame", +.update_fragment = _metadata_update_fragment, +}; -static void vp9_metadata_close(AVBSFContext *bsf) +static int vp9_metadata_init(AVBSFContext *bsf) { -VP9MetadataContext *ctx = bsf->priv_data; - -ff_cbs_fragment_free(>fragment); -ff_cbs_close(>cbc); +return ff_cbs_bsf_generic_init(bsf, _metadata_type); } #define OFFSET(x) offsetof(VP9MetadataContext, x) @@ -169,7 +140,7 @@ const AVBitStreamFilter ff_vp9_metadata_bsf = { .priv_data_size = sizeof(VP9MetadataContext), .priv_class = _metadata_class, .init = _metadata_init, -.close = _metadata_close, -.filter = _metadata_filter, +.close = _cbs_bsf_generic_close, +.filter = _cbs_bsf_generic_filter, .codec_ids = vp9_metadata_codec_ids, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] mpeg2_metadata_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:20 2021 +| [f35b2683275aeea8c4967877267d7376d3741a42] | committer: Mark Thompson mpeg2_metadata_bsf: Use common cbs bsf implementation This also adds support for updating new extradata. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f35b2683275aeea8c4967877267d7376d3741a42 --- libavcodec/mpeg2_metadata_bsf.c | 94 ++--- 1 file changed, 12 insertions(+), 82 deletions(-) diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c index d0048c0e25..11b46c0ae3 100644 --- a/libavcodec/mpeg2_metadata_bsf.c +++ b/libavcodec/mpeg2_metadata_bsf.c @@ -21,16 +21,13 @@ #include "libavutil/opt.h" #include "bsf.h" -#include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_mpeg2.h" #include "mpeg12.h" typedef struct MPEG2MetadataContext { -const AVClass *class; - -CodedBitstreamContext *cbc; -CodedBitstreamFragment fragment; +CBSBSFContext common; MPEG2RawExtensionData sequence_display_extension; @@ -48,6 +45,7 @@ typedef struct MPEG2MetadataContext { static int mpeg2_metadata_update_fragment(AVBSFContext *bsf, + AVPacket *pkt, CodedBitstreamFragment *frag) { MPEG2MetadataContext *ctx = bsf->priv_data; @@ -170,49 +168,16 @@ static int mpeg2_metadata_update_fragment(AVBSFContext *bsf, return 0; } -static int mpeg2_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) -{ -MPEG2MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *frag = >fragment; -int err; - -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = ff_cbs_read_packet(ctx->cbc, frag, pkt); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); -goto fail; -} - -err = mpeg2_metadata_update_fragment(bsf, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to update frame fragment.\n"); -goto fail; -} - -err = ff_cbs_write_packet(ctx->cbc, pkt, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); -goto fail; -} - -err = 0; -fail: -ff_cbs_fragment_reset(frag); - -if (err < 0) -av_packet_unref(pkt); - -return err; -} +static const CBSBSFType mpeg2_metadata_type = { +.codec_id= AV_CODEC_ID_MPEG2VIDEO, +.fragment_name = "frame", +.unit_name = "start code", +.update_fragment = _metadata_update_fragment, +}; static int mpeg2_metadata_init(AVBSFContext *bsf) { MPEG2MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *frag = >fragment; -int err; #define VALIDITY_CHECK(name) do { \ if (!ctx->name) { \ @@ -226,42 +191,7 @@ static int mpeg2_metadata_init(AVBSFContext *bsf) VALIDITY_CHECK(matrix_coefficients); #undef VALIDITY_CHECK -err = ff_cbs_init(>cbc, AV_CODEC_ID_MPEG2VIDEO, bsf); -if (err < 0) -return err; - -if (bsf->par_in->extradata) { -err = ff_cbs_read_extradata(ctx->cbc, frag, bsf->par_in); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n"); -goto fail; -} - -err = mpeg2_metadata_update_fragment(bsf, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to update metadata fragment.\n"); -goto fail; -} - -err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, frag); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n"); -goto fail; -} -} - -err = 0; -fail: -ff_cbs_fragment_reset(frag); -return err; -} - -static void mpeg2_metadata_close(AVBSFContext *bsf) -{ -MPEG2MetadataContext *ctx = bsf->priv_data; - -ff_cbs_fragment_free(>fragment); -ff_cbs_close(>cbc); +return ff_cbs_bsf_generic_init(bsf, _metadata_type); } #define OFFSET(x) offsetof(MPEG2MetadataContext, x) @@ -307,7 +237,7 @@ const AVBitStreamFilter ff_mpeg2_metadata_bsf = { .priv_data_size = sizeof(MPEG2MetadataContext), .priv_class = _metadata_class, .init = _metadata_init, -.close = _metadata_close, -.filter = _metadata_filter, +.close = _cbs_bsf_generic_close, +.filter = _cbs_bsf_generic_filter, .codec_ids = mpeg2_metadata_codec_ids, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] h265_metadata_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:19 2021 +| [b95f901c7ff5758a31df4d897cc82613b3caf99d] | committer: Mark Thompson h265_metadata_bsf: Use common cbs bsf implementation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b95f901c7ff5758a31df4d897cc82613b3caf99d --- libavcodec/h265_metadata_bsf.c | 191 + 1 file changed, 22 insertions(+), 169 deletions(-) diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c index 504a75dac2..59325c0471 100644 --- a/libavcodec/h265_metadata_bsf.c +++ b/libavcodec/h265_metadata_bsf.c @@ -20,29 +20,19 @@ #include "libavutil/opt.h" #include "bsf.h" -#include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_h265.h" #include "hevc.h" #include "h265_profile_level.h" -enum { -PASS, -INSERT, -REMOVE, -}; - enum { LEVEL_UNSET = -2, LEVEL_AUTO = -1, }; typedef struct H265MetadataContext { -const AVClass *class; - -CodedBitstreamContext *input; -CodedBitstreamContext *output; -CodedBitstreamFragment access_unit; +CBSBSFContext common; H265RawAUD aud_nal; @@ -338,89 +328,18 @@ static int h265_metadata_update_sps(AVBSFContext *bsf, return 0; } -static int h265_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) -{ -H265MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = >access_unit; -uint8_t *side_data; -int side_data_size; -int err, i; - -side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, -_data_size); -if (!side_data_size) -return 0; - -err = ff_cbs_read(ctx->input, au, side_data, side_data_size); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); -return err; -} - -if (ctx->level == LEVEL_AUTO && !ctx->level_guess) -h265_metadata_guess_level(bsf, au); - -for (i = 0; i < au->nb_units; i++) { -if (au->units[i].type == HEVC_NAL_VPS) { -err = h265_metadata_update_vps(bsf, au->units[i].content); -if (err < 0) -return err; -} -if (au->units[i].type == HEVC_NAL_SPS) { -err = h265_metadata_update_sps(bsf, au->units[i].content); -if (err < 0) -return err; -} -} - -err = ff_cbs_write_fragment_data(ctx->output, au); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); -return err; -} - -side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, au->data_size); -if (!side_data) -return AVERROR(ENOMEM); -memcpy(side_data, au->data, au->data_size); - -ff_cbs_fragment_reset(au); - -return 0; -} - -static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) +static int h265_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, + CodedBitstreamFragment *au) { H265MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = >access_unit; int err, i; -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = h265_metadata_update_side_data(bsf, pkt); -if (err < 0) -goto fail; - -err = ff_cbs_read_packet(ctx->input, au, pkt); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); -goto fail; -} - -if (au->nb_units == 0) { -av_log(bsf, AV_LOG_ERROR, "No NAL units in packet.\n"); -err = AVERROR_INVALIDDATA; -goto fail; -} - // If an AUD is present, it must be the first NAL unit. if (au->units[0].type == HEVC_NAL_AUD) { -if (ctx->aud == REMOVE) +if (ctx->aud == BSF_ELEMENT_REMOVE) ff_cbs_delete_unit(au, 0); } else { -if (ctx->aud == INSERT) { +if (pkt && ctx->aud == BSF_ELEMENT_INSERT) { H265RawAUD *aud = >aud_nal; int pic_type = 0, temporal_id = 8, layer_id = 0; @@ -453,7 +372,7 @@ static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) err = ff_cbs_insert_unit_content(au, 0, HEVC_NAL_AUD, aud, NULL); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n"); -goto fail; +return err; } } } @@ -465,101 +384,35 @@ static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) if (au->units[i].type == HEVC_NAL_VPS) { err = h265_metadata_update_vps(bsf, au->units[i].content); i
[FFmpeg-cvslog] h264_metadata_bsf: Use common cbs bsf implementation
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:18 2021 +| [c837d9481a0035f3b547a5b417e5341e6e0d6128] | committer: Mark Thompson h264_metadata_bsf: Use common cbs bsf implementation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c837d9481a0035f3b547a5b417e5341e6e0d6128 --- libavcodec/h264_metadata_bsf.c | 232 + 1 file changed, 49 insertions(+), 183 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index d0089b0eb4..30c0aa80d9 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -22,20 +22,13 @@ #include "libavutil/opt.h" #include "bsf.h" -#include "bsf_internal.h" #include "cbs.h" +#include "cbs_bsf.h" #include "cbs_h264.h" #include "h264.h" #include "h264_levels.h" #include "h264_sei.h" -enum { -PASS, -INSERT, -REMOVE, -EXTRACT, -}; - enum { FLIP_HORIZONTAL = 1, FLIP_VERTICAL = 2, @@ -47,11 +40,7 @@ enum { }; typedef struct H264MetadataContext { -const AVClass *class; - -CodedBitstreamContext *input; -CodedBitstreamContext *output; -CodedBitstreamFragment access_unit; +CBSBSFContext common; int done_first_au; @@ -333,49 +322,6 @@ static int h264_metadata_update_sps(AVBSFContext *bsf, return 0; } -static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) -{ -H264MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = >access_unit; -uint8_t *side_data; -int side_data_size; -int err, i; - -side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, -_data_size); -if (!side_data_size) -return 0; - -err = ff_cbs_read(ctx->input, au, side_data, side_data_size); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); -return err; -} - -for (i = 0; i < au->nb_units; i++) { -if (au->units[i].type == H264_NAL_SPS) { -err = h264_metadata_update_sps(bsf, au->units[i].content); -if (err < 0) -return err; -} -} - -err = ff_cbs_write_fragment_data(ctx->output, au); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); -return err; -} - -side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, au->data_size); -if (!side_data) -return AVERROR(ENOMEM); -memcpy(side_data, au->data, au->data_size); - -ff_cbs_fragment_reset(au); - -return 0; -} - static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, AVPacket *pkt, CodedBitstreamFragment *au, @@ -386,7 +332,7 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, int err; message = NULL; -while (ff_cbs_sei_find_message(ctx->output, au, +while (ff_cbs_sei_find_message(ctx->common.output, au, SEI_TYPE_DISPLAY_ORIENTATION, ) == 0) { H264RawSEIDisplayOrientation *disp = message->payload; @@ -415,13 +361,13 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, } } -if (ctx->display_orientation == REMOVE || -ctx->display_orientation == INSERT) { -ff_cbs_sei_delete_message_type(ctx->output, au, +if (ctx->display_orientation == BSF_ELEMENT_REMOVE || +ctx->display_orientation == BSF_ELEMENT_INSERT) { +ff_cbs_sei_delete_message_type(ctx->common.output, au, SEI_TYPE_DISPLAY_ORIENTATION); } -if (ctx->display_orientation == INSERT) { +if (ctx->display_orientation == BSF_ELEMENT_INSERT) { H264RawSEIDisplayOrientation *disp = >display_orientation_payload; uint8_t *data; @@ -495,7 +441,7 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, if (write) { disp->display_orientation_repetition_period = 1; -err = ff_cbs_sei_add_message(ctx->output, au, 1, +err = ff_cbs_sei_add_message(ctx->common.output, au, 1, SEI_TYPE_DISPLAY_ORIENTATION, disp, NULL); if (err < 0) { @@ -509,41 +455,21 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, return 0; } -static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) +static int h264_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, +
[FFmpeg-cvslog] h264_metadata_bsf: Refactor the filter function into smaller parts
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:15 2021 +| [8a14d51b8bab63d23fac2ac05aead590b4178408] | committer: Mark Thompson h264_metadata_bsf: Refactor the filter function into smaller parts > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a14d51b8bab63d23fac2ac05aead590b4178408 --- libavcodec/h264_metadata_bsf.c | 326 +++-- 1 file changed, 180 insertions(+), 146 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 6badb97b9e..34f032624e 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -56,6 +56,7 @@ typedef struct H264MetadataContext { int done_first_au; int aud; +H264RawAUD aud_nal; AVRational sample_aspect_ratio; @@ -91,6 +92,59 @@ typedef struct H264MetadataContext { } H264MetadataContext; +static int h264_metadata_insert_aud(AVBSFContext *bsf, +CodedBitstreamFragment *au) +{ +H264MetadataContext *ctx = bsf->priv_data; +int primary_pic_type_mask = 0xff; +int err, i, j; + +static const int primary_pic_type_table[] = { +0x084, // 2, 7 +0x0a5, // 0, 2, 5, 7 +0x0e7, // 0, 1, 2, 5, 6, 7 +0x210, // 4, 9 +0x318, // 3, 4, 8, 9 +0x294, // 2, 4, 7, 9 +0x3bd, // 0, 2, 3, 4, 5, 7, 8, 9 +0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 +}; + +for (i = 0; i < au->nb_units; i++) { +if (au->units[i].type == H264_NAL_SLICE || +au->units[i].type == H264_NAL_IDR_SLICE) { +H264RawSlice *slice = au->units[i].content; +for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++) { +if (!(primary_pic_type_table[j] & + (1 << slice->header.slice_type))) +primary_pic_type_mask &= ~(1 << j); +} +} +} +for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++) +if (primary_pic_type_mask & (1 << j)) +break; +if (j >= FF_ARRAY_ELEMS(primary_pic_type_table)) { +av_log(bsf, AV_LOG_ERROR, "No usable primary_pic_type: " + "invalid slice types?\n"); +return AVERROR_INVALIDDATA; +} + +ctx->aud_nal = (H264RawAUD) { +.nal_unit_header.nal_unit_type = H264_NAL_AUD, +.primary_pic_type = j, +}; + +err = ff_cbs_insert_unit_content(au, 0, H264_NAL_AUD, + >aud_nal, NULL); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n"); +return err; +} + +return 0; +} + static int h264_metadata_update_sps(AVBSFContext *bsf, H264RawSPS *sps) { @@ -322,160 +376,51 @@ static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) return 0; } -static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) +static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, +AVPacket *pkt, +CodedBitstreamFragment *au, +int seek_point) { H264MetadataContext *ctx = bsf->priv_data; -CodedBitstreamFragment *au = >access_unit; -int err, i, j, has_sps; -H264RawAUD aud; - -err = ff_bsf_get_packet_ref(bsf, pkt); -if (err < 0) -return err; - -err = h264_metadata_update_side_data(bsf, pkt); -if (err < 0) -goto fail; - -err = ff_cbs_read_packet(ctx->input, au, pkt); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); -goto fail; -} - -if (au->nb_units == 0) { -av_log(bsf, AV_LOG_ERROR, "No NAL units in packet.\n"); -err = AVERROR_INVALIDDATA; -goto fail; -} - -// If an AUD is present, it must be the first NAL unit. -if (au->units[0].type == H264_NAL_AUD) { -if (ctx->aud == REMOVE) -ff_cbs_delete_unit(au, 0); -} else { -if (ctx->aud == INSERT) { -static const int primary_pic_type_table[] = { -0x084, // 2, 7 -0x0a5, // 0, 2, 5, 7 -0x0e7, // 0, 1, 2, 5, 6, 7 -0x210, // 4, 9 -0x318, // 3, 4, 8, 9 -0x294, // 2, 4, 7, 9 -0x3bd, // 0, 2, 3, 4, 5, 7, 8, 9 -0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 -}; -int primary_pic_type_mask = 0xff; - -for (i = 0; i < au->nb_units; i++) { -if (au->units[i].type == H264_NAL_SLICE || -au->units[i].type == H264_NAL_IDR_SLICE) { -H264RawSlice *slice = au->units[i].content; -
[FFmpeg-cvslog] cbs_sei: Remove restrictions on MDCV values
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:14 2021 +| [88b65bed9ca033818f5618885c8a3d26d61a7c8a] | committer: Mark Thompson cbs_sei: Remove restrictions on MDCV values Since this was originally written the standards have changed to allow arbitrary values here, but leaves their meaning unspecified. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=88b65bed9ca033818f5618885c8a3d26d61a7c8a --- libavcodec/cbs_sei_syntax_template.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libavcodec/cbs_sei_syntax_template.c b/libavcodec/cbs_sei_syntax_template.c index 5f84246663..9114e61ff6 100644 --- a/libavcodec/cbs_sei_syntax_template.c +++ b/libavcodec/cbs_sei_syntax_template.c @@ -103,17 +103,15 @@ static int FUNC(mastering_display_colour_volume) HEADER("Mastering Display Colour Volume"); for (c = 0; c < 3; c++) { -us(16, display_primaries_x[c], 0, 5, 1, c); -us(16, display_primaries_y[c], 0, 5, 1, c); +ubs(16, display_primaries_x[c], 1, c); +ubs(16, display_primaries_y[c], 1, c); } -u(16, white_point_x, 0, 5); -u(16, white_point_y, 0, 5); +ub(16, white_point_x); +ub(16, white_point_y); -u(32, max_display_mastering_luminance, - 1, MAX_UINT_BITS(32)); -u(32, min_display_mastering_luminance, - 0, current->max_display_mastering_luminance - 1); +ub(32, max_display_mastering_luminance); +ub(32, min_display_mastering_luminance); return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs: Implement common parts of cbs-based bitstream filters separately
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:17 2021 +| [01a68c12a7cdf9031c19d1f00885a84d58e2c2a6] | committer: Mark Thompson cbs: Implement common parts of cbs-based bitstream filters separately This allows removal of a lot of duplicated code between BSFs. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=01a68c12a7cdf9031c19d1f00885a84d58e2c2a6 --- libavcodec/Makefile | 2 +- libavcodec/cbs_bsf.c | 159 +++ libavcodec/cbs_bsf.h | 131 ++ 3 files changed, 291 insertions(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 1fcb94fa48..6c1e7a1c7a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -69,7 +69,7 @@ OBJS-$(CONFIG_AUDIODSP)+= audiodsp.o OBJS-$(CONFIG_BLOCKDSP)+= blockdsp.o OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o OBJS-$(CONFIG_CABAC) += cabac.o -OBJS-$(CONFIG_CBS) += cbs.o +OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o diff --git a/libavcodec/cbs_bsf.c b/libavcodec/cbs_bsf.c new file mode 100644 index 00..9b521cf111 --- /dev/null +++ b/libavcodec/cbs_bsf.c @@ -0,0 +1,159 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "bsf_internal.h" +#include "cbs_bsf.h" + +static int cbs_bsf_update_side_data(AVBSFContext *bsf, AVPacket *pkt) +{ +CBSBSFContext *ctx = bsf->priv_data; +CodedBitstreamFragment *frag = >fragment; +uint8_t *side_data; +int side_data_size; +int err; + +side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, +_data_size); +if (!side_data_size) +return 0; + +err = ff_cbs_read(ctx->input, frag, side_data, side_data_size); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, + "Failed to read extradata from packet side data.\n"); +return err; +} + +err = ctx->type->update_fragment(bsf, NULL, frag); +if (err < 0) +return err; + +err = ff_cbs_write_fragment_data(ctx->output, frag); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, + "Failed to write extradata into packet side data.\n"); +return err; +} + +side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, +frag->data_size); +if (!side_data) +return AVERROR(ENOMEM); +memcpy(side_data, frag->data, frag->data_size); + +ff_cbs_fragment_reset(frag); +return 0; +} + +int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt) +{ +CBSBSFContext *ctx = bsf->priv_data; +CodedBitstreamFragment *frag = >fragment; +int err; + +err = ff_bsf_get_packet_ref(bsf, pkt); +if (err < 0) +return err; + +err = cbs_bsf_update_side_data(bsf, pkt); +if (err < 0) +goto fail; + +err = ff_cbs_read_packet(ctx->input, frag, pkt); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to read %s from packet.\n", + ctx->type->fragment_name); +goto fail; +} + +if (frag->nb_units == 0) { +av_log(bsf, AV_LOG_ERROR, "No %s found in packet.\n", + ctx->type->unit_name); +err = AVERROR_INVALIDDATA; +goto fail; +} + +err = ctx->type->update_fragment(bsf, pkt, frag); +if (err < 0) +goto fail; + +err = ff_cbs_write_packet(ctx->output, pkt, frag); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to write %s into packet.\n", + ctx->type->fragment_name); +goto fail; +} + +err = 0; +fail: +ff_cbs_fragment_reset(frag); + +if (err < 0) +av_packet_unref(pkt); + +return err; +} + +int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBS
[FFmpeg-cvslog] h264_metadata_bsf: Improve interpretation of input display matrices
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:16 2021 +| [c9c5b1977fe2406df495665fa3254657f0170ff5] | committer: Mark Thompson h264_metadata_bsf: Improve interpretation of input display matrices The previous code here only worked in more limited cases. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c9c5b1977fe2406df495665fa3254657f0170ff5 --- libavcodec/h264_metadata_bsf.c | 44 -- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 34f032624e..d0089b0eb4 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -431,23 +431,39 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, data = av_packet_get_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX, ); if (data && size >= 9 * sizeof(int32_t)) { int32_t matrix[9]; -int hflip, vflip; -double angle; +double dmatrix[9]; +int hflip, vflip, i; +double scale_x, scale_y, angle; memcpy(matrix, data, sizeof(matrix)); -hflip = vflip = 0; -if (matrix[0] < 0 && matrix[4] > 0) -hflip = 1; -else if (matrix[0] > 0 && matrix[4] < 0) -vflip = 1; -av_display_matrix_flip(matrix, hflip, vflip); +for (i = 0; i < 9; i++) +dmatrix[i] = matrix[i] / 65536.0; + +// Extract scale factors. +scale_x = hypot(dmatrix[0], dmatrix[3]); +scale_y = hypot(dmatrix[1], dmatrix[4]); + +// Select flips to make the main diagonal positive. +hflip = dmatrix[0] < 0.0; +vflip = dmatrix[4] < 0.0; +if (hflip) +scale_x = -scale_x; +if (vflip) +scale_y = -scale_y; + +// Rescale. +for (i = 0; i < 9; i += 3) { +dmatrix[i] /= scale_x; +dmatrix[i + 1] /= scale_y; +} -angle = av_display_rotation_get(matrix); +// Extract rotation. +angle = atan2(dmatrix[3], dmatrix[0]); -if (!(angle >= -180.0 && angle <= 180.0 /* also excludes NaN */) || -matrix[2] != 0 || matrix[5] != 0 || -matrix[6] != 0 || matrix[7] != 0) { +if (!(angle >= -M_PI && angle <= M_PI) || +matrix[2] != 0.0 || matrix[5] != 0.0 || +matrix[6] != 0.0 || matrix[7] != 0.0) { av_log(bsf, AV_LOG_WARNING, "Input display matrix is not " "representable in H.264 parameters.\n"); } else { @@ -455,8 +471,8 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf, disp->ver_flip = vflip; disp->anticlockwise_rotation = (uint16_t)rint((angle >= 0.0 ? angle - : angle + 360.0) * - 65536.0 / 360.0); + : angle + 2 * M_PI) * + 32768.0 / M_PI); write = 1; } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h2645: Merge SEI message handling in common between codecs
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:13 2021 +| [8843607f495c95c1e67a3ce3d6f15dca6e252439] | committer: Mark Thompson cbs_h2645: Merge SEI message handling in common between codecs > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8843607f495c95c1e67a3ce3d6f15dca6e252439 --- libavcodec/Makefile | 4 +- libavcodec/cbs_h264.h | 50 + libavcodec/cbs_h2645.c| 300 ++- libavcodec/cbs_h264_syntax_template.c | 173 ++-- libavcodec/cbs_h265.h | 33 +-- libavcodec/cbs_h265_syntax_template.c | 272 +++-- libavcodec/cbs_sei.c | 369 ++ libavcodec/cbs_sei.h | 139 + libavcodec/cbs_sei_syntax_template.c | 215 ++-- libavcodec/h264_metadata_bsf.c| 113 +-- libavcodec/vaapi_encode_h264.c| 51 ++--- libavcodec/vaapi_encode_h265.c| 38 +--- 12 files changed, 991 insertions(+), 766 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 446e6e6b3b..1fcb94fa48 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -71,8 +71,8 @@ OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o OBJS-$(CONFIG_CABAC) += cabac.o OBJS-$(CONFIG_CBS) += cbs.o OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o -OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o h2645_parse.o -OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o +OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o +OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o OBJS-$(CONFIG_CBS_MPEG2) += cbs_mpeg2.o OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index 81113f1ad0..9eb97eae24 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -291,34 +291,9 @@ typedef struct H264RawSEIDisplayOrientation { uint8_t display_orientation_extension_flag; } H264RawSEIDisplayOrientation; -typedef struct H264RawSEIPayload { -uint32_t payload_type; -uint32_t payload_size; -union { -H264RawSEIBufferingPeriod buffering_period; -H264RawSEIPicTiming pic_timing; -H264RawSEIPanScanRect pan_scan_rect; -// H264RawSEIFiller filler -> no fields. -SEIRawUserDataRegistered user_data_registered; -SEIRawUserDataUnregistered user_data_unregistered; -H264RawSEIRecoveryPoint recovery_point; -H264RawSEIDisplayOrientation display_orientation; -SEIRawMasteringDisplayColourVolume mastering_display_colour_volume; -SEIRawAlternativeTransferCharacteristics -alternative_transfer_characteristics; -struct { -uint8_t *data; -AVBufferRef *data_ref; -size_t data_length; -} other; -} payload; -} H264RawSEIPayload; - typedef struct H264RawSEI { H264RawNALUnitHeader nal_unit_header; - -H264RawSEIPayload payload[H264_MAX_SEI_PAYLOADS]; -uint8_t payload_count; +SEIRawMessageListmessage_list; } H264RawSEI; typedef struct H264RawSliceHeader { @@ -438,27 +413,4 @@ typedef struct CodedBitstreamH264Context { uint8_t last_slice_nal_unit_type; } CodedBitstreamH264Context; - -/** - * Add an SEI message to an access unit. - * - * On success, the payload will be owned by a unit in access_unit; - * on failure, the content of the payload will be freed. - */ -int ff_cbs_h264_add_sei_message(CodedBitstreamFragment *access_unit, -H264RawSEIPayload *payload); - -/** - * Delete an SEI message from an access unit. - * - * Deletes from nal_unit, which must be an SEI NAL unit. If this is the - * last message in nal_unit, also deletes it from access_unit. - * - * Requires nal_unit to be a unit in access_unit and position to be >= 0 - * and < the payload count of the SEI nal_unit. - */ -void ff_cbs_h264_delete_sei_message(CodedBitstreamFragment *access_unit, -CodedBitstreamUnit *nal_unit, -int position); - #endif /* AVCODEC_CBS_H264_H */ diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 4478a6f810..6005d46e0d 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -348,6 +348,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw)) +#define bit_position(rw) (get_bits_count(rw)) #define byte_alignment(rw) (get_bits_count(rw) % 8) #define allocate(name, size) do { \ @@ -379,6 +380,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) #undef xse #undef infer #undef more_rbsp_data +#undef bit_position #undef byte_align
[FFmpeg-cvslog] hevc: Use common SEI types
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 14:38:58 2021 +| [773857df592d8f3095a548b3085c6b7fe6b30dfe] | committer: Mark Thompson hevc: Use common SEI types > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=773857df592d8f3095a548b3085c6b7fe6b30dfe --- libavcodec/cbs_h2645.c| 28 ++-- libavcodec/cbs_h265_syntax_template.c | 15 --- libavcodec/hevc_sei.c | 22 +++--- libavcodec/hevc_sei.h | 34 +- libavcodec/nvenc.c| 2 +- libavcodec/vaapi_encode_h265.c| 4 ++-- 6 files changed, 37 insertions(+), 68 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index d26d85bcd3..4478a6f810 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1445,23 +1445,23 @@ static const CodedBitstreamUnitTypeDescriptor cbs_h264_unit_types[] = { static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload) { switch (payload->payload_type) { -case HEVC_SEI_TYPE_BUFFERING_PERIOD: -case HEVC_SEI_TYPE_PICTURE_TIMING: -case HEVC_SEI_TYPE_PAN_SCAN_RECT: -case HEVC_SEI_TYPE_RECOVERY_POINT: -case HEVC_SEI_TYPE_DISPLAY_ORIENTATION: -case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS: -case HEVC_SEI_TYPE_DECODED_PICTURE_HASH: -case HEVC_SEI_TYPE_TIME_CODE: -case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO: -case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO: -case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: -case HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO: +case SEI_TYPE_BUFFERING_PERIOD: +case SEI_TYPE_PIC_TIMING: +case SEI_TYPE_PAN_SCAN_RECT: +case SEI_TYPE_RECOVERY_POINT: +case SEI_TYPE_DISPLAY_ORIENTATION: +case SEI_TYPE_ACTIVE_PARAMETER_SETS: +case SEI_TYPE_DECODED_PICTURE_HASH: +case SEI_TYPE_TIME_CODE: +case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: +case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO: +case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: +case SEI_TYPE_ALPHA_CHANNEL_INFO: break; -case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: +case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: av_buffer_unref(>payload.user_data_registered.data_ref); break; -case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED: +case SEI_TYPE_USER_DATA_UNREGISTERED: av_buffer_unref(>payload.user_data_unregistered.data_ref); break; default: diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index b792ec688a..64afc3f01d 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -2049,18 +2049,18 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, } \ } while (0) #define SEI_TYPE_N(type, prefix_valid, suffix_valid, name) \ -case HEVC_SEI_TYPE_ ## type: \ +case SEI_TYPE_ ## type: \ SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ CHECK(FUNC(sei_ ## name)(ctx, rw, >payload.name)); \ break #define SEI_TYPE_S(type, prefix_valid, suffix_valid, name) \ -case HEVC_SEI_TYPE_ ## type: \ +case SEI_TYPE_ ## type: \ SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ CHECK(FUNC(sei_ ## name)(ctx, rw, >payload.name, \ >payload_size)); \ break #define SEI_TYPE_E(type, prefix_valid, suffix_valid, name) \ -case HEVC_SEI_TYPE_ ## type: \ +case SEI_TYPE_ ## type: \ SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ CHECK(FUNC(sei_ ## name)(ctx, rw, >payload.name, \ >payload_size, \ @@ -2068,19 +2068,19 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, break #define SEI_TYPE_N2(type, prefix_valid, suffix_valid, name) \ -case HEVC_SEI_TYPE_ ## type: \ +case SEI_TYPE_ ## type: \ SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ CHECK(FUNC_SEI(sei_ ## name)(ctx, rw, >payload.name)); \ break #define SEI_TYPE_S2(type, prefix_valid, suffix_valid, name) \ -case HEVC_SEI_TYPE_ ## type: \ +case SEI_TYPE_ ## type: \ SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ CHECK(FUNC_SEI(sei_ ## name)(ctx, rw, >payload.name, \ >payload_size)); \ break SEI_TYPE_E(BUFFERING_PERIOD, 1, 0, buffering_period); -SEI_TYPE_N(PICTURE_TIMING, 1, 0, pic_timing); +SEI_TYPE_N(PIC_TIMING, 1, 0, pic_timing); SEI_TYPE_N(PAN_SCAN_RECT,1, 0, pan_scan_rect); SEI_TYPE_S2(USER_DATA_REGISTERED_ITU_T_T35, 1, 1, user_data_registered); @@ -2090,7 +2090,8 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx,
[FFmpeg-cvslog] lavc: Add new header for SEI payload types
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 14:31:56 2021 +| [9ef32649d02109c364387edcbb55932491f1dcf1] | committer: Mark Thompson lavc: Add new header for SEI payload types These form a common namespace between the H.264, H.265 and H.266 standards, so we can use the same definitions in all three places. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ef32649d02109c364387edcbb55932491f1dcf1 --- libavcodec/sei.h | 139 +++ 1 file changed, 139 insertions(+) diff --git a/libavcodec/sei.h b/libavcodec/sei.h new file mode 100644 index 00..f07c72ae7b --- /dev/null +++ b/libavcodec/sei.h @@ -0,0 +1,139 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_SEI_H +#define AVCODEC_SEI_H + +// SEI payload types form a common namespace between the H.264, H.265 +// and H.266 standards. A given payload type always has the same +// meaning, but some names have different payload types in different +// standards (e.g. scalable-nesting is 30 in H.264 but 133 in H.265). +// The content of the payload data depends on the standard, though +// many generic parts have the same interpretation everywhere (such as +// mastering-display-colour-volume and user-data-unregistered). +enum { +SEI_TYPE_BUFFERING_PERIOD= 0, +SEI_TYPE_PIC_TIMING = 1, +SEI_TYPE_PAN_SCAN_RECT = 2, +SEI_TYPE_FILLER_PAYLOAD = 3, +SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35 = 4, +SEI_TYPE_USER_DATA_UNREGISTERED = 5, +SEI_TYPE_RECOVERY_POINT = 6, +SEI_TYPE_DEC_REF_PIC_MARKING_REPETITION = 7, +SEI_TYPE_SPARE_PIC = 8, +SEI_TYPE_SCENE_INFO = 9, +SEI_TYPE_SUB_SEQ_INFO= 10, +SEI_TYPE_SUB_SEQ_LAYER_CHARACTERISTICS = 11, +SEI_TYPE_SUB_SEQ_CHARACTERISTICS = 12, +SEI_TYPE_FULL_FRAME_FREEZE = 13, +SEI_TYPE_FULL_FRAME_FREEZE_RELEASE = 14, +SEI_TYPE_FULL_FRAME_SNAPSHOT = 15, +SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START= 16, +SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END = 17, +SEI_TYPE_MOTION_CONSTRAINED_SLICE_GROUP_SET = 18, +SEI_TYPE_FILM_GRAIN_CHARACTERISTICS = 19, +SEI_TYPE_DEBLOCKING_FILTER_DISPLAY_PREFERENCE= 20, +SEI_TYPE_STEREO_VIDEO_INFO = 21, +SEI_TYPE_POST_FILTER_HINT= 22, +SEI_TYPE_TONE_MAPPING_INFO = 23, +SEI_TYPE_SCALABILITY_INFO= 24, +SEI_TYPE_SUB_PIC_SCALABLE_LAYER = 25, +SEI_TYPE_NON_REQUIRED_LAYER_REP = 26, +SEI_TYPE_PRIORITY_LAYER_INFO = 27, +SEI_TYPE_LAYERS_NOT_PRESENT_4= 28, +SEI_TYPE_LAYER_DEPENDENCY_CHANGE = 29, +SEI_TYPE_SCALABLE_NESTING_4 = 30, +SEI_TYPE_BASE_LAYER_TEMPORAL_HRD = 31, +SEI_TYPE_QUALITY_LAYER_INTEGRITY_CHECK = 32, +SEI_TYPE_REDUNDANT_PIC_PROPERTY = 33, +SEI_TYPE_TL0_DEP_REP_INDEX = 34, +SEI_TYPE_TL_SWITCHING_POINT = 35, +SEI_TYPE_PARALLEL_DECODING_INFO = 36, +SEI_TYPE_MVC_SCALABLE_NESTING= 37, +SEI_TYPE_VIEW_SCALABILITY_INFO = 38, +SEI_TYPE_MULTIVIEW_SCENE_INFO_4 = 39, +SEI_TYPE_MULTIVIEW_ACQUISITION_INFO_4= 40, +SEI_TYPE_NON_REQUIRED_VIEW_COMPONENT = 41, +SEI_TYPE_VIEW_DEPENDENCY_CHANGE = 42, +SEI_TYPE_OPERATION_POINTS_NOT_PRESENT= 43, +SEI_TYPE_BASE_VIEW_TEMPORAL_HRD = 44, +SEI_TYPE_FRAME_PACKING_ARRANGEMENT = 45, +SEI_TYPE_MULTIVIEW_VIEW_POSITIO
[FFmpeg-cvslog] h264: Use common SEI types
ffmpeg | branch: master | Mark Thompson | Thu Jan 21 14:37:49 2021 +| [64b3aac8d07a8744656737619b70977359d9a6a5] | committer: Mark Thompson h264: Use common SEI types > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=64b3aac8d07a8744656737619b70977359d9a6a5 --- libavcodec/cbs_h2645.c| 18 +- libavcodec/cbs_h264_syntax_template.c | 20 ++-- libavcodec/h264_metadata_bsf.c| 8 libavcodec/h264_sei.c | 18 +- libavcodec/h264_sei.h | 18 +- libavcodec/vaapi_encode_h264.c| 8 libavcodec/videotoolboxenc.c | 6 +++--- 7 files changed, 40 insertions(+), 56 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 9e210abba4..d26d85bcd3 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1384,18 +1384,18 @@ static void cbs_h265_close(CodedBitstreamContext *ctx) static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload) { switch (payload->payload_type) { -case H264_SEI_TYPE_BUFFERING_PERIOD: -case H264_SEI_TYPE_PIC_TIMING: -case H264_SEI_TYPE_PAN_SCAN_RECT: -case H264_SEI_TYPE_RECOVERY_POINT: -case H264_SEI_TYPE_DISPLAY_ORIENTATION: -case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: -case H264_SEI_TYPE_ALTERNATIVE_TRANSFER: +case SEI_TYPE_BUFFERING_PERIOD: +case SEI_TYPE_PIC_TIMING: +case SEI_TYPE_PAN_SCAN_RECT: +case SEI_TYPE_RECOVERY_POINT: +case SEI_TYPE_DISPLAY_ORIENTATION: +case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: +case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: break; -case H264_SEI_TYPE_USER_DATA_REGISTERED: +case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: av_buffer_unref(>payload.user_data_registered.data_ref); break; -case H264_SEI_TYPE_USER_DATA_UNREGISTERED: +case SEI_TYPE_USER_DATA_UNREGISTERED: av_buffer_unref(>payload.user_data_unregistered.data_ref); break; default: diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 76ed51cc7b..37047dc30b 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -747,45 +747,45 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, #endif switch (current->payload_type) { -case H264_SEI_TYPE_BUFFERING_PERIOD: +case SEI_TYPE_BUFFERING_PERIOD: CHECK(FUNC(sei_buffering_period) (ctx, rw, >payload.buffering_period)); break; -case H264_SEI_TYPE_PIC_TIMING: +case SEI_TYPE_PIC_TIMING: CHECK(FUNC(sei_pic_timing) (ctx, rw, >payload.pic_timing)); break; -case H264_SEI_TYPE_PAN_SCAN_RECT: +case SEI_TYPE_PAN_SCAN_RECT: CHECK(FUNC(sei_pan_scan_rect) (ctx, rw, >payload.pan_scan_rect)); break; -case H264_SEI_TYPE_FILLER_PAYLOAD: +case SEI_TYPE_FILLER_PAYLOAD: { for (i = 0; i < current->payload_size; i++) fixed(8, ff_byte, 0xff); } break; -case H264_SEI_TYPE_USER_DATA_REGISTERED: +case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: CHECK(FUNC_SEI(sei_user_data_registered) (ctx, rw, >payload.user_data_registered, >payload_size)); break; -case H264_SEI_TYPE_USER_DATA_UNREGISTERED: +case SEI_TYPE_USER_DATA_UNREGISTERED: CHECK(FUNC_SEI(sei_user_data_unregistered) (ctx, rw, >payload.user_data_unregistered, >payload_size)); break; -case H264_SEI_TYPE_RECOVERY_POINT: +case SEI_TYPE_RECOVERY_POINT: CHECK(FUNC(sei_recovery_point) (ctx, rw, >payload.recovery_point)); break; -case H264_SEI_TYPE_DISPLAY_ORIENTATION: +case SEI_TYPE_DISPLAY_ORIENTATION: CHECK(FUNC(sei_display_orientation) (ctx, rw, >payload.display_orientation)); break; -case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: +case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: CHECK(FUNC_SEI(sei_mastering_display_colour_volume) (ctx, rw, >payload.mastering_display_colour_volume)); break; -case H264_SEI_TYPE_ALTERNATIVE_TRANSFER: +case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: CHECK(FUNC_SEI(sei_alternative_transfer_characteristics) (ctx, rw, >payload.alternative_transfer_characteristics)); break; diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index f39e649ac6..2228761113 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -435,7 +435,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) for (j = sei->payload_count - 1; j >= 0; j--) { if (sei->payload[j].payloa
[FFmpeg-cvslog] cbs_h2645: Merge SEI messages in common between codecs
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:11 2021 +| [4bf338480035238b3ff595ebd761688fc0db9e11] | committer: Mark Thompson cbs_h2645: Merge SEI messages in common between codecs Make a new template file for common SEI messages - this will also apply to H.266. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4bf338480035238b3ff595ebd761688fc0db9e11 --- libavcodec/cbs_h264.h | 37 ++ libavcodec/cbs_h2645.c| 24 -- libavcodec/cbs_h264_syntax_template.c | 106 +- libavcodec/cbs_h265.h | 45 ++-- libavcodec/cbs_h265_syntax_template.c | 135 +- libavcodec/cbs_sei.h | 60 +++ libavcodec/cbs_sei_syntax_template.c | 132 + libavcodec/h264_metadata_bsf.c| 2 +- libavcodec/vaapi_encode_h264.c| 2 +- libavcodec/vaapi_encode_h265.c| 11 +-- 10 files changed, 250 insertions(+), 304 deletions(-) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index a6fe0a6af2..81113f1ad0 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -24,6 +24,7 @@ #include "cbs.h" #include "cbs_h2645.h" +#include "cbs_sei.h" #include "h264.h" @@ -274,21 +275,6 @@ typedef struct H264RawSEIPanScanRect { uint16_t pan_scan_rect_repetition_period; } H264RawSEIPanScanRect; -typedef struct H264RawSEIUserDataRegistered { -uint8_t itu_t_t35_country_code; -uint8_t itu_t_t35_country_code_extension_byte; -uint8_t *data; -AVBufferRef *data_ref; -size_t data_length; -} H264RawSEIUserDataRegistered; - -typedef struct H264RawSEIUserDataUnregistered { -uint8_t uuid_iso_iec_11578[16]; -uint8_t *data; -AVBufferRef *data_ref; -size_t data_length; -} H264RawSEIUserDataUnregistered; - typedef struct H264RawSEIRecoveryPoint { uint16_t recovery_frame_cnt; uint8_t exact_match_flag; @@ -305,19 +291,6 @@ typedef struct H264RawSEIDisplayOrientation { uint8_t display_orientation_extension_flag; } H264RawSEIDisplayOrientation; -typedef struct H264RawSEIMasteringDisplayColourVolume { -uint16_t display_primaries_x[3]; -uint16_t display_primaries_y[3]; -uint16_t white_point_x; -uint16_t white_point_y; -uint32_t max_display_mastering_luminance; -uint32_t min_display_mastering_luminance; -} H264RawSEIMasteringDisplayColourVolume; - -typedef struct H264RawSEIAlternativeTransferCharacteristics { -uint8_t preferred_transfer_characteristics; -} H264RawSEIAlternativeTransferCharacteristics; - typedef struct H264RawSEIPayload { uint32_t payload_type; uint32_t payload_size; @@ -326,12 +299,12 @@ typedef struct H264RawSEIPayload { H264RawSEIPicTiming pic_timing; H264RawSEIPanScanRect pan_scan_rect; // H264RawSEIFiller filler -> no fields. -H264RawSEIUserDataRegistered user_data_registered; -H264RawSEIUserDataUnregistered user_data_unregistered; +SEIRawUserDataRegistered user_data_registered; +SEIRawUserDataUnregistered user_data_unregistered; H264RawSEIRecoveryPoint recovery_point; H264RawSEIDisplayOrientation display_orientation; -H264RawSEIMasteringDisplayColourVolume mastering_display_colour_volume; -H264RawSEIAlternativeTransferCharacteristics +SEIRawMasteringDisplayColourVolume mastering_display_colour_volume; +SEIRawAlternativeTransferCharacteristics alternative_transfer_characteristics; struct { uint8_t *data; diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 550c059ef3..9e210abba4 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -253,9 +253,11 @@ static int cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t paylo return err; \ } while (0) -#define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name -#define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name) -#define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name) +#define FUNC_NAME2(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name +#define FUNC_NAME1(rw, codec, name) FUNC_NAME2(rw, codec, name) +#define FUNC_H264(name) FUNC_NAME1(READWRITE, h264, name) +#define FUNC_H265(name) FUNC_NAME1(READWRITE, h265, name) +#define FUNC_SEI(name) FUNC_NAME1(READWRITE, sei, name) #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL) @@ -356,11 +358,15 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) name = name ## _ref->data; \ } while (0) -#define FUNC(name) FUNC_H264(READWRITE, name) +#define FUNC(name) FUNC_SEI(name) +#include "cbs_sei_syntax_template.c" +#undef FUNC + +#define FUNC(name) FUNC_H264(name) #include "cbs_h264_syntax_template.c" #undef FUNC -#de
[FFmpeg-cvslog] h264_metadata_bsf: Move SEI user data parsing to init time
ffmpeg | branch: master | Mark Thompson | Fri Jan 1 21:35:12 2021 +| [75092c5b45d00585f72945243a1509d77a8f6476] | committer: Mark Thompson h264_metadata_bsf: Move SEI user data parsing to init time > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=75092c5b45d00585f72945243a1509d77a8f6476 --- libavcodec/h264_metadata_bsf.c | 91 -- 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index d7cf58095b..f39e649ac6 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -78,6 +78,7 @@ typedef struct H264MetadataContext { int crop_bottom; const char *sei_user_data; +H264RawSEIPayload sei_user_data_payload; int delete_filler; @@ -413,54 +414,10 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) // Only insert the SEI in access units containing SPSs, and also // unconditionally in the first access unit we ever see. if (ctx->sei_user_data && (has_sps || !ctx->done_first_au)) { -H264RawSEIPayload payload = { -.payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED, -}; -SEIRawUserDataUnregistered *udu = -_data_unregistered; - -for (i = j = 0; j < 32 && ctx->sei_user_data[i]; i++) { -int c, v; -c = ctx->sei_user_data[i]; -if (c == '-') { -continue; -} else if (av_isxdigit(c)) { -c = av_tolower(c); -v = (c <= '9' ? c - '0' : c - 'a' + 10); -} else { -goto invalid_user_data; -} -if (j & 1) -udu->uuid_iso_iec_11578[j / 2] |= v; -else -udu->uuid_iso_iec_11578[j / 2] = v << 4; -++j; -} -if (j == 32 && ctx->sei_user_data[i] == '+') { -size_t len = strlen(ctx->sei_user_data + i + 1); - -udu->data_ref = av_buffer_alloc(len + 1); -if (!udu->data_ref) { -err = AVERROR(ENOMEM); -goto fail; -} - -udu->data= udu->data_ref->data; -udu->data_length = len + 1; -memcpy(udu->data, ctx->sei_user_data + i + 1, len + 1); - -err = ff_cbs_h264_add_sei_message(au, ); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI " - "message to access unit.\n"); -goto fail; -} - -} else { -invalid_user_data: -av_log(bsf, AV_LOG_ERROR, "Invalid user data: " - "must be \"UUID+string\".\n"); -err = AVERROR(EINVAL); +err = ff_cbs_h264_add_sei_message(au, >sei_user_data_payload); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI " + "message to access unit.\n"); goto fail; } } @@ -627,6 +584,44 @@ static int h264_metadata_init(AVBSFContext *bsf) CodedBitstreamFragment *au = >access_unit; int err, i; +if (ctx->sei_user_data) { +SEIRawUserDataUnregistered *udu = +>sei_user_data_payload.payload.user_data_unregistered; +int j; + +ctx->sei_user_data_payload.payload_type = +H264_SEI_TYPE_USER_DATA_UNREGISTERED; + +// Parse UUID. It must be a hex string of length 32, possibly +// containing '-'s between hex digits (which we ignore). +for (i = j = 0; j < 32 && i < 64 && ctx->sei_user_data[i]; i++) { +int c, v; +c = ctx->sei_user_data[i]; +if (c == '-') { +continue; +} else if (av_isxdigit(c)) { +c = av_tolower(c); +v = (c <= '9' ? c - '0' : c - 'a' + 10); +} else { +break; +} +if (j & 1) +udu->uuid_iso_iec_11578[j / 2] |= v; +else +udu->uuid_iso_iec_11578[j / 2] = v << 4; +++j; +} +if (j == 32 && ctx->sei_user_data[i] == '+') { +udu->data = (uint8_t*)ctx->sei_user_data + i + 1; +udu->data_length = strlen(udu->data) + 1; +} else { +av_log(bsf, AV_LOG_ERROR, "Invalid user data: " + "must be \"UUID+string\".\n"); +err = AVERROR(EINVAL); +goto fail; +} +} + err = ff_cbs_init(>input, AV_CODEC_ID_H264, bsf); if (err < 0) return err; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs: Add function to read extradata from an AVCodecContext
ffmpeg | branch: master | Mark Thompson | Mon Nov 23 17:53:57 2020 +| [7bacf60ae5df75954a538563d19f6001aa598b3f] | committer: Jan Ekström cbs: Add function to read extradata from an AVCodecContext This is useful in decoders and parsers, matching the way that bitstream filters read extradata from AVCodecParameters. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7bacf60ae5df75954a538563d19f6001aa598b3f --- libavcodec/cbs.c | 77 libavcodec/cbs.h | 11 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index c8c526ab12..f98531e131 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -223,66 +223,67 @@ static int cbs_fill_fragment_data(CodedBitstreamFragment *frag, return 0; } -int ff_cbs_read_extradata(CodedBitstreamContext *ctx, - CodedBitstreamFragment *frag, - const AVCodecParameters *par) +static int cbs_read_data(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + AVBufferRef *buf, + const uint8_t *data, size_t size, + int header) { int err; -err = cbs_fill_fragment_data(frag, par->extradata, - par->extradata_size); -if (err < 0) -return err; - -err = ctx->codec->split_fragment(ctx, frag, 1); -if (err < 0) -return err; - -return cbs_read_fragment_content(ctx, frag); -} - -int ff_cbs_read_packet(CodedBitstreamContext *ctx, - CodedBitstreamFragment *frag, - const AVPacket *pkt) -{ -int err; - -if (pkt->buf) { -frag->data_ref = av_buffer_ref(pkt->buf); +if (buf) { +frag->data_ref = av_buffer_ref(buf); if (!frag->data_ref) return AVERROR(ENOMEM); -frag->data = pkt->data; -frag->data_size = pkt->size; +frag->data = (uint8_t *)data; +frag->data_size = size; } else { -err = cbs_fill_fragment_data(frag, pkt->data, pkt->size); +err = cbs_fill_fragment_data(frag, data, size); if (err < 0) return err; } -err = ctx->codec->split_fragment(ctx, frag, 0); +err = ctx->codec->split_fragment(ctx, frag, header); if (err < 0) return err; return cbs_read_fragment_content(ctx, frag); } -int ff_cbs_read(CodedBitstreamContext *ctx, -CodedBitstreamFragment *frag, -const uint8_t *data, size_t size) +int ff_cbs_read_extradata(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVCodecParameters *par) { -int err; +return cbs_read_data(ctx, frag, NULL, + par->extradata, + par->extradata_size, 1); +} -err = cbs_fill_fragment_data(frag, data, size); -if (err < 0) -return err; +int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVCodecContext *avctx) +{ +return cbs_read_data(ctx, frag, NULL, + avctx->extradata, + avctx->extradata_size, 1); +} -err = ctx->codec->split_fragment(ctx, frag, 0); -if (err < 0) -return err; +int ff_cbs_read_packet(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVPacket *pkt) +{ +return cbs_read_data(ctx, frag, pkt->buf, + pkt->data, pkt->size, 0); +} -return cbs_read_fragment_content(ctx, frag); +int ff_cbs_read(CodedBitstreamContext *ctx, +CodedBitstreamFragment *frag, +const uint8_t *data, size_t size) +{ +return cbs_read_data(ctx, frag, NULL, + data, size, 0); } static int cbs_write_unit_data(CodedBitstreamContext *ctx, diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index 635921b11e..3fd0a0ef33 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -262,6 +262,17 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVCodecParameters *par); +/** + * Read the extradata bitstream found in a codec context into a + * fragment, then split into units and decompose. + * + * This acts identical to ff_cbs_read_extradata() for the case where + * you already have a codec context. + */ +int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVCodecContext *av
[FFmpeg-cvslog] lavc: Mark hw_config pointer arrays as const
ffmpeg | branch: master | Mark Thompson | Sun Nov 8 18:51:15 2020 +| [cd322794eecf1dd7d975ce3dcf1c18bbd8b91ad1] | committer: Mark Thompson lavc: Mark hw_config pointer arrays as const They are read-only just like the HWConfig structures they point to. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cd322794eecf1dd7d975ce3dcf1c18bbd8b91ad1 --- libavcodec/codec.h | 2 +- libavcodec/cuviddec.c | 2 +- libavcodec/h263dec.c | 2 +- libavcodec/mediacodecdec.c | 2 +- libavcodec/mmaldec.c | 2 +- libavcodec/nvenc.c | 2 +- libavcodec/nvenc.h | 2 +- libavcodec/qsvdec.c| 2 +- libavcodec/qsvdec.h| 2 +- libavcodec/qsvenc.c| 2 +- libavcodec/qsvenc.h| 2 +- libavcodec/rkmppdec.c | 2 +- libavcodec/vaapi_encode.c | 2 +- libavcodec/vaapi_encode.h | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libavcodec/codec.h b/libavcodec/codec.h index dc8e12b3f0..0ccbf0eb19 100644 --- a/libavcodec/codec.h +++ b/libavcodec/codec.h @@ -320,7 +320,7 @@ typedef struct AVCodec { * * The user can only access this field via avcodec_get_hw_config(). */ -const struct AVCodecHWConfigInternal **hw_configs; +const struct AVCodecHWConfigInternal *const *hw_configs; /** * List of supported codec_tags, terminated by FF_CODEC_TAGS_END. diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index ee2ecc01fe..5e698d4cd0 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -1100,7 +1100,7 @@ static const AVOption options[] = { { NULL } }; -static const AVCodecHWConfigInternal *cuvid_hw_configs[] = { +static const AVCodecHWConfigInternal *const cuvid_hw_configs[] = { &(const AVCodecHWConfigInternal) { .public = { .pix_fmt = AV_PIX_FMT_CUDA, diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 3b29a189e9..32e26a57de 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -743,7 +743,7 @@ const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[] = { AV_PIX_FMT_NONE }; -const AVCodecHWConfigInternal *ff_h263_hw_config_list[] = { +const AVCodecHWConfigInternal *const ff_h263_hw_config_list[] = { #if CONFIG_H263_VAAPI_HWACCEL HWACCEL_VAAPI(h263), #endif diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 25410021e8..ac1725e466 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -486,7 +486,7 @@ static void mediacodec_decode_flush(AVCodecContext *avctx) ff_mediacodec_dec_flush(avctx, s->ctx); } -static const AVCodecHWConfigInternal *mediacodec_hw_configs[] = { +static const AVCodecHWConfigInternal *const mediacodec_hw_configs[] = { &(const AVCodecHWConfigInternal) { .public = { .pix_fmt = AV_PIX_FMT_MEDIACODEC, diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c index cd2b263a98..172fb61c9b 100644 --- a/libavcodec/mmaldec.c +++ b/libavcodec/mmaldec.c @@ -809,7 +809,7 @@ static int ffmmal_decode(AVCodecContext *avctx, void *data, int *got_frame, return ret; } -static const AVCodecHWConfigInternal *mmal_hw_configs[] = { +static const AVCodecHWConfigInternal *const mmal_hw_configs[] = { HW_CONFIG_INTERNAL(MMAL), NULL }; diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 48625f5baa..1c06b6af27 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -59,7 +59,7 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = { AV_PIX_FMT_NONE }; -const AVCodecHWConfigInternal *ff_nvenc_hw_configs[] = { +const AVCodecHWConfigInternal *const ff_nvenc_hw_configs[] = { HW_CONFIG_ENCODER_FRAMES(CUDA, CUDA), HW_CONFIG_ENCODER_DEVICE(NONE, CUDA), #if CONFIG_D3D11VA diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index f6f2a6361a..fefc5f7f0b 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -230,6 +230,6 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, AVPacket *pkt); void ff_nvenc_encode_flush(AVCodecContext *avctx); extern const enum AVPixelFormat ff_nvenc_pix_fmts[]; -extern const AVCodecHWConfigInternal *ff_nvenc_hw_configs[]; +extern const AVCodecHWConfigInternal *const ff_nvenc_hw_configs[]; #endif /* AVCODEC_NVENC_H */ diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index fc25dc73e5..c666aaeb52 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -43,7 +43,7 @@ #include "qsv_internal.h" #include "qsvdec.h" -const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = { +const AVCodecHWConfigInternal *const ff_qsv_hw_configs[] = { &(const AVCodecHWConfigInternal) { .public = { .pix_fmt = AV_PIX_FMT_QSV, diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h index cb948f516d..f3b7344cba 100644 --- a/libavcodec/qsvdec.h +++ b/libavcodec/qsvdec.h @@ -74,7 +74,7 @@ typedef struct QSVContext { int nb_ext_buffers; } QSVContext; -extern const AVCo
[FFmpeg-cvslog] vaapi_encode_mpeg2: Fix setting colour properties
ffmpeg | branch: master | Mark Thompson | Mon Nov 2 22:46:49 2020 +| [755203c2d270e1334987b462f80151eb88e30121] | committer: Mark Thompson vaapi_encode_mpeg2: Fix setting colour properties Follow the same pattern as the previous commits for H.264 and H.265. Reviewed-By: Jan Ekström Tested-By: Xu, Yefeng > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=755203c2d270e1334987b462f80151eb88e30121 --- libavcodec/vaapi_encode_mpeg2.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index b8f1c06d0f..df2c62b8e7 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -292,17 +292,16 @@ static int vaapi_encode_mpeg2_init_sequence_params(AVCodecContext *avctx) priv->sequence_display_extension.extension_start_code_identifier = MPEG2_EXTENSION_SEQUENCE_DISPLAY; +// Unspecified video format, from table 6-6. sde->video_format = 5; -if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || + +sde->colour_primaries = avctx->color_primaries; +sde->transfer_characteristics = avctx->color_trc; +sde->matrix_coefficients = avctx->colorspace; +sde->colour_description = +avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || avctx->color_trc != AVCOL_TRC_UNSPECIFIED || -avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { -sde->colour_description = 1; -sde->colour_primaries = avctx->color_primaries; -sde->transfer_characteristics = avctx->color_trc; -sde->matrix_coefficients = avctx->colorspace; -} else { -sde->colour_description = 0; -} +avctx->colorspace != AVCOL_SPC_UNSPECIFIED; sde->display_horizontal_size = avctx->width; sde->display_vertical_size = avctx->height; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode_h265: Fix setting colour properties
ffmpeg | branch: master | Mark Thompson | Mon Nov 2 22:46:48 2020 +| [486817e1aedda759bd21287b462ee0bb6e100949] | committer: Mark Thompson vaapi_encode_h265: Fix setting colour properties Matching the previous commit for H.264. Reviewed-By: Jan Ekström Tested-By: Xu, Yefeng > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=486817e1aedda759bd21287b462ee0bb6e100949 --- libavcodec/vaapi_encode_h265.c | 34 -- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 316030914c..3e0af17ea5 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -488,30 +488,20 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) vui->aspect_ratio_info_present_flag = 1; } -if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED || -avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || +// Unspecified video format, from table E-2. +vui->video_format = 5; +vui->video_full_range_flag= +avctx->color_range == AVCOL_RANGE_JPEG; +vui->colour_primaries = avctx->color_primaries; +vui->transfer_characteristics = avctx->color_trc; +vui->matrix_coefficients = avctx->colorspace; +if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || avctx->color_trc != AVCOL_TRC_UNSPECIFIED || -avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { +avctx->colorspace != AVCOL_SPC_UNSPECIFIED) +vui->colour_description_present_flag = 1; +if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED || +vui->colour_description_present_flag) vui->video_signal_type_present_flag = 1; -vui->video_format = 5; // Unspecified. -vui->video_full_range_flag = -avctx->color_range == AVCOL_RANGE_JPEG; - -if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || -avctx->color_trc != AVCOL_TRC_UNSPECIFIED || -avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { -vui->colour_description_present_flag = 1; -vui->colour_primaries = avctx->color_primaries; -vui->transfer_characteristics = avctx->color_trc; -vui->matrix_coefficients = avctx->colorspace; -} -} else { -vui->video_format = 5; -vui->video_full_range_flag= 0; -vui->colour_primaries = avctx->color_primaries; -vui->transfer_characteristics = avctx->color_trc; -vui->matrix_coefficients = avctx->colorspace; -} if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) { vui->chroma_loc_info_present_flag = 1; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode_h264: Fix setting colour properties
ffmpeg | branch: master | Mark Thompson | Mon Nov 2 22:46:47 2020 +| [9faf4dcf234dbc34f05cd2d973473df2eece4881] | committer: Mark Thompson vaapi_encode_h264: Fix setting colour properties The properties should always be set; only the presence flags want to be conditional. Fixes #8959. Reviewed-By: Jan Ekström Tested-By: Xu, Yefeng > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9faf4dcf234dbc34f05cd2d973473df2eece4881 --- libavcodec/vaapi_encode_h264.c | 34 -- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 5e1683e851..e52a0e37a4 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -411,30 +411,20 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) sps->vui.aspect_ratio_info_present_flag = 1; } -if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED || -avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || +// Unspecified video format, from table E-2. +sps->vui.video_format = 5; +sps->vui.video_full_range_flag= +avctx->color_range == AVCOL_RANGE_JPEG; +sps->vui.colour_primaries = avctx->color_primaries; +sps->vui.transfer_characteristics = avctx->color_trc; +sps->vui.matrix_coefficients = avctx->colorspace; +if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || avctx->color_trc != AVCOL_TRC_UNSPECIFIED || -avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { +avctx->colorspace != AVCOL_SPC_UNSPECIFIED) +sps->vui.colour_description_present_flag = 1; +if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED || +sps->vui.colour_description_present_flag) sps->vui.video_signal_type_present_flag = 1; -sps->vui.video_format = 5; // Unspecified. -sps->vui.video_full_range_flag = -avctx->color_range == AVCOL_RANGE_JPEG; - -if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || -avctx->color_trc != AVCOL_TRC_UNSPECIFIED || -avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { -sps->vui.colour_description_present_flag = 1; -sps->vui.colour_primaries = avctx->color_primaries; -sps->vui.transfer_characteristics = avctx->color_trc; -sps->vui.matrix_coefficients = avctx->colorspace; -} -} else { -sps->vui.video_format = 5; -sps->vui.video_full_range_flag= 0; -sps->vui.colour_primaries = avctx->color_primaries; -sps->vui.transfer_characteristics = avctx->color_trc; -sps->vui.matrix_coefficients = avctx->colorspace; -} if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) { sps->vui.chroma_loc_info_present_flag = 1; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] Revert "avfilter/setparams: add FF_FILTER_FLAG_HWFRAME_AWARE"
ffmpeg | branch: master | Mark Thompson | Tue Sep 29 17:01:22 2020 +0100| [4fceb2634e7a81e40c49df6478d924558bdc607c] | committer: Mark Thompson Revert "avfilter/setparams: add FF_FILTER_FLAG_HWFRAME_AWARE" This reverts commit 5bbf58ab876279ca1a5a2f30563f271c99b93e62. The setparams filters are not hwframe aware, so the default context passthrough behaviour is needed to allow using them with hardware frames. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4fceb2634e7a81e40c49df6478d924558bdc607c --- libavfilter/vf_setparams.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c index 72a69e3fc2..689097fac0 100644 --- a/libavfilter/vf_setparams.c +++ b/libavfilter/vf_setparams.c @@ -169,7 +169,6 @@ AVFilter ff_vf_setparams = { .priv_class = _class, .inputs = inputs, .outputs = outputs, -.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, }; #if CONFIG_SETRANGE_FILTER @@ -209,7 +208,6 @@ AVFilter ff_vf_setrange = { .priv_class = _class, .inputs = inputs, .outputs = outputs, -.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, }; #endif /* CONFIG_SETRANGE_FILTER */ @@ -244,6 +242,5 @@ AVFilter ff_vf_setfield = { .priv_class = _class, .inputs = inputs, .outputs = outputs, -.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, }; #endif /* CONFIG_SETFIELD_FILTER */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_av1: Fix test for presence of buffer_removal_time element
ffmpeg | branch: release/4.3 | Mark Thompson | Sun Aug 23 17:06:06 2020 +0100| [f070c53c7a5057248e6a4819dc967fa2c87600b0] | committer: James Almer cbs_av1: Fix test for presence of buffer_removal_time element The frame must be in both the spatial and temporal layers for the operating point, not just one of them. (cherry picked from commit b567cb8d0b664775201d843ab985f49fefeb25d5) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f070c53c7a5057248e6a4819dc967fa2c87600b0 --- libavcodec/cbs_av1_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index a315e8868a..ce6a66823c 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1381,7 +1381,7 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, int in_temporal_layer = (op_pt_idc >> priv->temporal_id ) & 1; int in_spatial_layer = (op_pt_idc >> (priv->spatial_id + 8)) & 1; if (seq->operating_point_idc[i] == 0 || -in_temporal_layer || in_spatial_layer) { +(in_temporal_layer && in_spatial_layer)) { fbs(seq->decoder_model_info.buffer_removal_time_length_minus_1 + 1, buffer_removal_time[i], 1, i); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_vp9: Use table-based alloc/free
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 17:32:25 2020 +0100| [f643f9bd6d6c954717cd8e607034b0dd25156244] | committer: Mark Thompson cbs_vp9: Use table-based alloc/free > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f643f9bd6d6c954717cd8e607034b0dd25156244 --- libavcodec/cbs_vp9.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c index 6e0a7dcbea..6a480b4ce3 100644 --- a/libavcodec/cbs_vp9.c +++ b/libavcodec/cbs_vp9.c @@ -479,13 +479,6 @@ static int cbs_vp9_split_fragment(CodedBitstreamContext *ctx, return 0; } -static void cbs_vp9_free_frame(void *opaque, uint8_t *content) -{ -VP9RawFrame *frame = (VP9RawFrame*)content; -av_buffer_unref(>data_ref); -av_freep(); -} - static int cbs_vp9_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit) { @@ -497,8 +490,7 @@ static int cbs_vp9_read_unit(CodedBitstreamContext *ctx, if (err < 0) return err; -err = ff_cbs_alloc_unit_content(unit, sizeof(*frame), -_vp9_free_frame); +err = ff_cbs_alloc_unit_content2(ctx, unit); if (err < 0) return err; frame = unit->content; @@ -642,11 +634,18 @@ static int cbs_vp9_assemble_fragment(CodedBitstreamContext *ctx, return 0; } +static const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types[] = { +CBS_UNIT_TYPE_INTERNAL_REF(0, VP9RawFrame, data), +CBS_UNIT_TYPE_END_OF_LIST +}; + const CodedBitstreamType ff_cbs_type_vp9 = { .codec_id = AV_CODEC_ID_VP9, .priv_data_size= sizeof(CodedBitstreamVP9Context), +.unit_types= cbs_vp9_unit_types, + .split_fragment= _vp9_split_fragment, .read_unit = _vp9_read_unit, .write_unit= _vp9_write_unit, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs: Ensure that reference fields always follow the associated pointer
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 17:32:17 2020 +0100| [1fe77d4a637c4033180a35b6ebf13b5a4707d2a4] | committer: Mark Thompson cbs: Ensure that reference fields always follow the associated pointer Having these together allows us to find both pointers given the address of only one of them. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1fe77d4a637c4033180a35b6ebf13b5a4707d2a4 --- libavcodec/cbs_av1.h | 6 +++--- libavcodec/cbs_h264.h | 18 +- libavcodec/cbs_h265.h | 18 +- libavcodec/cbs_jpeg.h | 2 +- libavcodec/cbs_mpeg2.h | 10 +- libavcodec/cbs_vp9.h | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h index 913a6e5dea..7a0c08c596 100644 --- a/libavcodec/cbs_av1.h +++ b/libavcodec/cbs_av1.h @@ -284,8 +284,8 @@ typedef struct AV1RawFrameHeader { typedef struct AV1RawTileData { uint8_t *data; -size_t data_size; AVBufferRef *data_ref; +size_t data_size; } AV1RawTileData; typedef struct AV1RawTileGroup { @@ -346,8 +346,8 @@ typedef struct AV1RawMetadataITUTT35 { uint8_t itu_t_t35_country_code_extension_byte; uint8_t *payload; -size_t payload_size; AVBufferRef *payload_ref; +size_t payload_size; } AV1RawMetadataITUTT35; typedef struct AV1RawMetadataTimecode { @@ -379,8 +379,8 @@ typedef struct AV1RawMetadata { typedef struct AV1RawPadding { uint8_t *payload; -size_t payload_size; AVBufferRef *payload_ref; +size_t payload_size; } AV1RawPadding; diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index f54ccd3b36..a6fe0a6af2 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -277,16 +277,16 @@ typedef struct H264RawSEIPanScanRect { typedef struct H264RawSEIUserDataRegistered { uint8_t itu_t_t35_country_code; uint8_t itu_t_t35_country_code_extension_byte; -uint8_t *data; -size_t data_length; +uint8_t *data; AVBufferRef *data_ref; +size_t data_length; } H264RawSEIUserDataRegistered; typedef struct H264RawSEIUserDataUnregistered { uint8_t uuid_iso_iec_11578[16]; -uint8_t *data; -size_t data_length; +uint8_t *data; AVBufferRef *data_ref; +size_t data_length; } H264RawSEIUserDataUnregistered; typedef struct H264RawSEIRecoveryPoint { @@ -334,9 +334,9 @@ typedef struct H264RawSEIPayload { H264RawSEIAlternativeTransferCharacteristics alternative_transfer_characteristics; struct { -uint8_t *data; -size_t data_length; +uint8_t *data; AVBufferRef *data_ref; +size_t data_length; } other; } payload; } H264RawSEIPayload; @@ -429,10 +429,10 @@ typedef struct H264RawSliceHeader { typedef struct H264RawSlice { H264RawSliceHeader header; -uint8_t *data; -size_t data_size; -int data_bit_start; +uint8_t *data; AVBufferRef *data_ref; +size_t data_size; +int data_bit_start; } H264RawSlice; typedef struct H264RawFiller { diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h index 73897f77a4..15b22bbfd4 100644 --- a/libavcodec/cbs_h265.h +++ b/libavcodec/cbs_h265.h @@ -183,9 +183,9 @@ typedef struct H265RawVUI { } H265RawVUI; typedef struct H265RawExtensionData { -uint8_t *data; -size_t bit_length; +uint8_t *data; AVBufferRef *data_ref; +size_t bit_length; } H265RawExtensionData; typedef struct H265RawVPS { @@ -541,10 +541,10 @@ typedef struct H265RawSliceHeader { typedef struct H265RawSlice { H265RawSliceHeader header; -uint8_t *data; -size_t data_size; -int data_bit_start; +uint8_t *data; AVBufferRef *data_ref; +size_t data_size; +int data_bit_start; } H265RawSlice; @@ -600,15 +600,15 @@ typedef struct H265RawSEIUserDataRegistered { uint8_t itu_t_t35_country_code; uint8_t itu_t_t35_country_code_extension_byte; uint8_t *data; -size_t data_length; AVBufferRef *data_ref; +size_t data_length; } H265RawSEIUserDataRegistered; typedef struct H265RawSEIUserDataUnregistered { uint8_t uuid_iso_iec_11578[16]; uint8_t *data; -size_t data_length; AVBufferRef *data_ref; +size_t data_length; } H265RawSEIUserDataUnregistered; typedef struct H265RawSEIRecoveryPoint { @@ -710,9 +710,9 @@ typedef struct H265RawSEIPayload { alternative_transfer_characteristics; H265RawSEIAlphaChannelInfo alpha_channel_info; struct { -uint8_t *data; -size_t data_length; +uint8_t *data; AVBufferRef *data_ref; +size_t data_length; } other; } payload; H265RawExtensionData extension_d
[FFmpeg-cvslog] cbs: Add support functions for handling unit content references
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 17:32:21 2020 +0100| [42daac1c74169ec4373b5199932c5f3176a2e897] | committer: Mark Thompson cbs: Add support functions for handling unit content references Use the unit type table to determine what we need to do to clone the internals of the unit content when making copies for refcounting or writeability. (This will still fail for units with complex content if they do not have a defined clone function.) Setup and naming from a patch by Andreas Rheinhardt , but with the implementation changed to use the unit type information if possible rather than requiring a codec-specific function. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42daac1c74169ec4373b5199932c5f3176a2e897 --- libavcodec/cbs.c | 163 ++ libavcodec/cbs.h | 29 + libavcodec/cbs_internal.h | 1 + 3 files changed, 193 insertions(+) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 61cf8e3466..7c1aa005c2 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -871,3 +871,166 @@ int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx, return 0; } + +static int cbs_clone_unit_content(AVBufferRef **clone_ref, + CodedBitstreamUnit *unit, + const CodedBitstreamUnitTypeDescriptor *desc) +{ +uint8_t *src, *copy; +uint8_t **src_ptr, **copy_ptr; +AVBufferRef **src_buf, **copy_buf; +int err, i; + +av_assert0(unit->content); +src = unit->content; + +copy = av_memdup(src, desc->content_size); +if (!copy) +return AVERROR(ENOMEM); + +for (i = 0; i < desc->nb_ref_offsets; i++) { +src_ptr = (uint8_t**)(src + desc->ref_offsets[i]); +src_buf = (AVBufferRef**)(src_ptr + 1); +copy_ptr = (uint8_t**)(copy + desc->ref_offsets[i]); +copy_buf = (AVBufferRef**)(copy_ptr + 1); + +if (!*src_ptr) { +av_assert0(!*src_buf); +continue; +} +if (!*src_buf) { +// We can't handle a non-refcounted pointer here - we don't +// have enough information to handle whatever structure lies +// at the other end of it. +err = AVERROR(EINVAL); +goto fail; +} + +// src_ptr is required to point somewhere inside src_buf. If it +// doesn't, there is a bug somewhere. +av_assert0(*src_ptr >= (*src_buf)->data && + *src_ptr < (*src_buf)->data + (*src_buf)->size); + +*copy_buf = av_buffer_ref(*src_buf); +if (!*copy_buf) { +err = AVERROR(ENOMEM); +goto fail; +} +*copy_ptr = (*copy_buf)->data + (*src_ptr - (*src_buf)->data); +} + +*clone_ref = av_buffer_create(copy, desc->content_size, + desc->content_free ? desc->content_free : + cbs_default_free_unit_content, + (void*)desc, 0); +if (!*clone_ref) { +err = AVERROR(ENOMEM); +goto fail; +} + +return 0; + +fail: +for (--i; i >= 0; i--) +av_buffer_unref((AVBufferRef**)(copy + desc->ref_offsets[i])); +av_freep(); +*clone_ref = NULL; +return err; +} + +int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx, +CodedBitstreamUnit *unit) +{ +const CodedBitstreamUnitTypeDescriptor *desc; +AVBufferRef *ref; +int err; + +av_assert0(unit->content); +if (unit->content_ref) { +// Already refcounted, nothing to do. +return 0; +} + +desc = cbs_find_unit_type_desc(ctx, unit); +if (!desc) +return AVERROR(ENOSYS); + +switch (desc->content_type) { +case CBS_CONTENT_TYPE_POD: +ref = av_buffer_alloc(desc->content_size); +if (!ref) +return AVERROR(ENOMEM); +memcpy(ref->data, unit->content, desc->content_size); +err = 0; +break; + +case CBS_CONTENT_TYPE_INTERNAL_REFS: +err = cbs_clone_unit_content(, unit, desc); +break; + +case CBS_CONTENT_TYPE_COMPLEX: +if (!desc->content_clone) +return AVERROR_PATCHWELCOME; +err = desc->content_clone(, unit); +break; + +default: +av_assert0(0 && "Invalid content type."); +} + +if (err < 0) +return err; + +unit->content_ref = ref; +unit->content = ref->data; +return 0; +} + +int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx, + CodedBitstreamUnit *unit) +{ +const CodedBitstreamUnitTypeDescriptor *desc; +AVBufferRef *ref; +int err; + +// This can only be applied to refcounted units. +err = ff_cbs_make_unit_refcounted(ctx, unit); +if (err <
[FFmpeg-cvslog] cbs_av1: Use table-based alloc/free
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 17:32:26 2020 +0100| [ae7686a64fea5e70e315a02c0f680b2cc04cc188] | committer: Mark Thompson cbs_av1: Use table-based alloc/free > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae7686a64fea5e70e315a02c0f680b2cc04cc188 --- libavcodec/cbs_av1.c | 85 1 file changed, 39 insertions(+), 46 deletions(-) diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index 72ad18151e..dcf6c140ae 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -809,50 +809,6 @@ fail: return err; } -static void cbs_av1_free_tile_data(AV1RawTileData *td) -{ -av_buffer_unref(>data_ref); -} - -static void cbs_av1_free_padding(AV1RawPadding *pd) -{ -av_buffer_unref(>payload_ref); -} - -static void cbs_av1_free_metadata(AV1RawMetadata *md) -{ -switch (md->metadata_type) { -case AV1_METADATA_TYPE_ITUT_T35: -av_buffer_unref(>metadata.itut_t35.payload_ref); -break; -} -} - -static void cbs_av1_free_obu(void *opaque, uint8_t *content) -{ -AV1RawOBU *obu = (AV1RawOBU*)content; - -switch (obu->header.obu_type) { -case AV1_OBU_TILE_GROUP: -cbs_av1_free_tile_data(>obu.tile_group.tile_data); -break; -case AV1_OBU_FRAME: -cbs_av1_free_tile_data(>obu.frame.tile_group.tile_data); -break; -case AV1_OBU_TILE_LIST: -cbs_av1_free_tile_data(>obu.tile_list.tile_data); -break; -case AV1_OBU_METADATA: -cbs_av1_free_metadata(>obu.metadata); -break; -case AV1_OBU_PADDING: -cbs_av1_free_padding(>obu.padding); -break; -} - -av_freep(); -} - static int cbs_av1_ref_tile_data(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, GetBitContext *gbc, @@ -887,8 +843,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, GetBitContext gbc; int err, start_pos, end_pos; -err = ff_cbs_alloc_unit_content(unit, sizeof(*obu), -_av1_free_obu); +err = ff_cbs_alloc_unit_content2(ctx, unit); if (err < 0) return err; obu = unit->content; @@ -1247,11 +1202,49 @@ static void cbs_av1_close(CodedBitstreamContext *ctx) av_buffer_unref(>frame_header_ref); } +static void cbs_av1_free_metadata(void *unit, uint8_t *content) +{ +AV1RawOBU *obu = (AV1RawOBU*)content; +AV1RawMetadata *md; + +av_assert0(obu->header.obu_type == AV1_OBU_METADATA); +md = >obu.metadata; + +switch (md->metadata_type) { +case AV1_METADATA_TYPE_ITUT_T35: +av_buffer_unref(>metadata.itut_t35.payload_ref); +break; +} +} + +static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = { +CBS_UNIT_TYPE_POD(AV1_OBU_SEQUENCE_HEADER,AV1RawOBU), +CBS_UNIT_TYPE_POD(AV1_OBU_TEMPORAL_DELIMITER, AV1RawOBU), +CBS_UNIT_TYPE_POD(AV1_OBU_FRAME_HEADER, AV1RawOBU), +CBS_UNIT_TYPE_POD(AV1_OBU_REDUNDANT_FRAME_HEADER, AV1RawOBU), + +CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_TILE_GROUP, AV1RawOBU, + obu.tile_group.tile_data.data), +CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_FRAME, AV1RawOBU, + obu.frame.tile_group.tile_data.data), +CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_TILE_LIST, AV1RawOBU, + obu.tile_list.tile_data.data), +CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_PADDING,AV1RawOBU, + obu.padding.payload), + +CBS_UNIT_TYPE_COMPLEX(AV1_OBU_METADATA, AV1RawOBU, + _av1_free_metadata), + +CBS_UNIT_TYPE_END_OF_LIST +}; + const CodedBitstreamType ff_cbs_type_av1 = { .codec_id = AV_CODEC_ID_AV1, .priv_data_size= sizeof(CodedBitstreamAV1Context), +.unit_types= cbs_av1_unit_types, + .split_fragment= _av1_split_fragment, .read_unit = _av1_read_unit, .write_unit= _av1_write_obu, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h2645: Ensure that non-refcounted parameter sets are fully copied
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 17:32:22 2020 +0100| [0720e15c0330f0f101c02d5c2c6548e964079f6d] | committer: Mark Thompson cbs_h2645: Ensure that non-refcounted parameter sets are fully copied Only copying the main structure is not necessarily sufficient - there could be references to substructures. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0720e15c0330f0f101c02d5c2c6548e964079f6d --- libavcodec/cbs_h2645.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 5725539e60..e19fa5249d 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -720,18 +720,20 @@ static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \ CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \ H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \ unsigned int id = ps_var->id_element; \ +int err; \ if (id >= FF_ARRAY_ELEMS(priv->ps_var)) { \ av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid " #ps_name \ " id : %d.\n", id); \ return AVERROR_INVALIDDATA; \ } \ +err = ff_cbs_make_unit_refcounted(ctx, unit); \ +if (err < 0) \ +return err; \ if (priv->ps_var[id] == priv->active_ ## ps_var) \ priv->active_ ## ps_var = NULL ; \ av_buffer_unref(>ps_var ## _ref[id]); \ -if (unit->content_ref) \ -priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \ -else \ -priv->ps_var ## _ref[id] = av_buffer_alloc(sizeof(*ps_var)); \ +av_assert0(unit->content_ref); \ +priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \ if (!priv->ps_var ## _ref[id]) \ return AVERROR(ENOMEM); \ priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## _ref[id]->data; \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h265: Use table-based alloc/free
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 17:32:24 2020 +0100| [e38646de1cef80ebf451402ddaf15941f2b60522] | committer: Mark Thompson cbs_h265: Use table-based alloc/free > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e38646de1cef80ebf451402ddaf15941f2b60522 --- libavcodec/cbs_h2645.c | 198 +++-- 1 file changed, 93 insertions(+), 105 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index e19fa5249d..b9233f4df7 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -454,72 +454,6 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) #undef allocate -static void cbs_h265_free_vps(void *opaque, uint8_t *content) -{ -H265RawVPS *vps = (H265RawVPS*)content; -av_buffer_unref(>extension_data.data_ref); -av_freep(); -} - -static void cbs_h265_free_sps(void *opaque, uint8_t *content) -{ -H265RawSPS *sps = (H265RawSPS*)content; -av_buffer_unref(>extension_data.data_ref); -av_freep(); -} - -static void cbs_h265_free_pps(void *opaque, uint8_t *content) -{ -H265RawPPS *pps = (H265RawPPS*)content; -av_buffer_unref(>extension_data.data_ref); -av_freep(); -} - -static void cbs_h265_free_slice(void *opaque, uint8_t *content) -{ -H265RawSlice *slice = (H265RawSlice*)content; -av_buffer_unref(>data_ref); -av_freep(); -} - -static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload) -{ -switch (payload->payload_type) { -case HEVC_SEI_TYPE_BUFFERING_PERIOD: -case HEVC_SEI_TYPE_PICTURE_TIMING: -case HEVC_SEI_TYPE_PAN_SCAN_RECT: -case HEVC_SEI_TYPE_RECOVERY_POINT: -case HEVC_SEI_TYPE_DISPLAY_ORIENTATION: -case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS: -case HEVC_SEI_TYPE_DECODED_PICTURE_HASH: -case HEVC_SEI_TYPE_TIME_CODE: -case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO: -case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO: -case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: -case HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO: -break; -case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: -av_buffer_unref(>payload.user_data_registered.data_ref); -break; -case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED: -av_buffer_unref(>payload.user_data_unregistered.data_ref); -break; -default: -av_buffer_unref(>payload.other.data_ref); -break; -} -av_buffer_unref(>extension_data.data_ref); -} - -static void cbs_h265_free_sei(void *opaque, uint8_t *content) -{ -H265RawSEI *sei = (H265RawSEI*)content; -int i; -for (i = 0; i < sei->payload_count; i++) -cbs_h265_free_sei_payload(>payload[i]); -av_freep(); -} - static int cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const H2645Packet *packet) @@ -877,16 +811,14 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, if (err < 0) return err; +err = ff_cbs_alloc_unit_content2(ctx, unit); +if (err < 0) +return err; + switch (unit->type) { case HEVC_NAL_VPS: { -H265RawVPS *vps; - -err = ff_cbs_alloc_unit_content(unit, sizeof(*vps), -_h265_free_vps); -if (err < 0) -return err; -vps = unit->content; +H265RawVPS *vps = unit->content; err = cbs_h265_read_vps(ctx, , vps); if (err < 0) @@ -899,13 +831,7 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, break; case HEVC_NAL_SPS: { -H265RawSPS *sps; - -err = ff_cbs_alloc_unit_content(unit, sizeof(*sps), -_h265_free_sps); -if (err < 0) -return err; -sps = unit->content; +H265RawSPS *sps = unit->content; err = cbs_h265_read_sps(ctx, , sps); if (err < 0) @@ -919,13 +845,7 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, case HEVC_NAL_PPS: { -H265RawPPS *pps; - -err = ff_cbs_alloc_unit_content(unit, sizeof(*pps), -_h265_free_pps); -if (err < 0) -return err; -pps = unit->content; +H265RawPPS *pps = unit->content; err = cbs_h265_read_pps(ctx, , pps); if (err < 0) @@ -954,15 +874,9 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, case HEVC_NAL_IDR_N_LP: case HEVC_NAL_CRA_NUT: { -H265RawSlice *slice; +H265RawSlice *slice = unit->content; int pos, len; -err = ff_cbs_alloc_unit_content(unit, sizeof(*slice), -
[FFmpeg-cvslog] cbs_mpeg2: Use table-based alloc/free
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 17:32:27 2020 +0100| [cf6af829c2db8a8c55f49526f73e37b9da772c30] | committer: Mark Thompson cbs_mpeg2: Use table-based alloc/free > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cf6af829c2db8a8c55f49526f73e37b9da772c30 --- libavcodec/cbs_mpeg2.c | 70 +- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c index 8b6e5a9852..26400f279f 100644 --- a/libavcodec/cbs_mpeg2.c +++ b/libavcodec/cbs_mpeg2.c @@ -140,28 +140,6 @@ #undef infer -static void cbs_mpeg2_free_picture_header(void *opaque, uint8_t *content) -{ -MPEG2RawPictureHeader *picture = (MPEG2RawPictureHeader*)content; -av_buffer_unref(>extra_information_picture.extra_information_ref); -av_freep(); -} - -static void cbs_mpeg2_free_user_data(void *opaque, uint8_t *content) -{ -MPEG2RawUserData *user = (MPEG2RawUserData*)content; -av_buffer_unref(>user_data_ref); -av_freep(); -} - -static void cbs_mpeg2_free_slice(void *opaque, uint8_t *content) -{ -MPEG2RawSlice *slice = (MPEG2RawSlice*)content; - av_buffer_unref(>header.extra_information_slice.extra_information_ref); -av_buffer_unref(>data_ref); -av_freep(); -} - static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header) @@ -231,16 +209,14 @@ static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx, if (err < 0) return err; +err = ff_cbs_alloc_unit_content2(ctx, unit); +if (err < 0) +return err; + if (MPEG2_START_IS_SLICE(unit->type)) { -MPEG2RawSlice *slice; +MPEG2RawSlice *slice = unit->content; int pos, len; -err = ff_cbs_alloc_unit_content(unit, sizeof(*slice), -_mpeg2_free_slice); -if (err < 0) -return err; -slice = unit->content; - err = cbs_mpeg2_read_slice_header(ctx, , >header); if (err < 0) return err; @@ -264,12 +240,7 @@ static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx, #define START(start_code, type, read_func, free_func) \ case start_code: \ { \ -type *header; \ -err = ff_cbs_alloc_unit_content(unit, \ -sizeof(*header), free_func); \ -if (err < 0) \ -return err; \ -header = unit->content; \ +type *header = unit->content; \ err = cbs_mpeg2_read_ ## read_func(ctx, , header); \ if (err < 0) \ return err; \ @@ -420,11 +391,40 @@ static int cbs_mpeg2_assemble_fragment(CodedBitstreamContext *ctx, return 0; } +static const CodedBitstreamUnitTypeDescriptor cbs_mpeg2_unit_types[] = { +CBS_UNIT_TYPE_INTERNAL_REF(MPEG2_START_PICTURE, MPEG2RawPictureHeader, + extra_information_picture.extra_information), + +{ +.nb_unit_types = CBS_UNIT_TYPE_RANGE, +.unit_type_range_start = 0x01, +.unit_type_range_end = 0xaf, + +.content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, +.content_size = sizeof(MPEG2RawSlice), +.nb_ref_offsets = 2, +.ref_offsets= { offsetof(MPEG2RawSlice, header.extra_information_slice.extra_information), +offsetof(MPEG2RawSlice, data) }, +}, + +CBS_UNIT_TYPE_INTERNAL_REF(MPEG2_START_USER_DATA, MPEG2RawUserData, + user_data), + +CBS_UNIT_TYPE_POD(MPEG2_START_SEQUENCE_HEADER, MPEG2RawSequenceHeader), +CBS_UNIT_TYPE_POD(MPEG2_START_EXTENSION, MPEG2RawExtensionData), +CBS_UNIT_TYPE_POD(MPEG2_START_SEQUENCE_END,MPEG2RawSequenceEnd), +CBS_UNIT_TYPE_POD(MPEG2_START_GROUP, MPEG2RawGroupOfPicturesHeader), + +CBS_UNIT_TYPE_END_OF_LIST +}; + const CodedBitstreamType ff_cbs_type_mpeg2 = { .codec_id = AV_CODEC_ID_MPEG2VIDEO, .priv_data_size= sizeof(CodedBitstreamMPEG2Context), +.unit_types= cbs_mpeg2_unit_types, + .split_fragment= _mpeg2_split_fragment, .read_unit = _mpeg2_read_unit, .write_unit= _mpeg2_write_unit, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h264: Use table-based alloc/free
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 17:32:20 2020 +0100| [2cb152d52f28081acf3c2306557944105af8374f] | committer: Mark Thompson cbs_h264: Use table-based alloc/free > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2cb152d52f28081acf3c2306557944105af8374f --- libavcodec/cbs_h2645.c | 163 + 1 file changed, 70 insertions(+), 93 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index e5c8012d39..5725539e60 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -454,52 +454,6 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) #undef allocate -static void cbs_h264_free_pps(void *opaque, uint8_t *content) -{ -H264RawPPS *pps = (H264RawPPS*)content; -av_buffer_unref(>slice_group_id_ref); -av_freep(); -} - -static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload) -{ -switch (payload->payload_type) { -case H264_SEI_TYPE_BUFFERING_PERIOD: -case H264_SEI_TYPE_PIC_TIMING: -case H264_SEI_TYPE_PAN_SCAN_RECT: -case H264_SEI_TYPE_RECOVERY_POINT: -case H264_SEI_TYPE_DISPLAY_ORIENTATION: -case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: -case H264_SEI_TYPE_ALTERNATIVE_TRANSFER: -break; -case H264_SEI_TYPE_USER_DATA_REGISTERED: -av_buffer_unref(>payload.user_data_registered.data_ref); -break; -case H264_SEI_TYPE_USER_DATA_UNREGISTERED: -av_buffer_unref(>payload.user_data_unregistered.data_ref); -break; -default: -av_buffer_unref(>payload.other.data_ref); -break; -} -} - -static void cbs_h264_free_sei(void *opaque, uint8_t *content) -{ -H264RawSEI *sei = (H264RawSEI*)content; -int i; -for (i = 0; i < sei->payload_count; i++) -cbs_h264_free_sei_payload(>payload[i]); -av_freep(); -} - -static void cbs_h264_free_slice(void *opaque, uint8_t *content) -{ -H264RawSlice *slice = (H264RawSlice*)content; -av_buffer_unref(>data_ref); -av_freep(); -} - static void cbs_h265_free_vps(void *opaque, uint8_t *content) { H265RawVPS *vps = (H265RawVPS*)content; @@ -802,15 +756,14 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, if (err < 0) return err; +err = ff_cbs_alloc_unit_content2(ctx, unit); +if (err < 0) +return err; + switch (unit->type) { case H264_NAL_SPS: { -H264RawSPS *sps; - -err = ff_cbs_alloc_unit_content(unit, sizeof(*sps), NULL); -if (err < 0) -return err; -sps = unit->content; +H264RawSPS *sps = unit->content; err = cbs_h264_read_sps(ctx, , sps); if (err < 0) @@ -824,12 +777,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, case H264_NAL_SPS_EXT: { -err = ff_cbs_alloc_unit_content(unit, -sizeof(H264RawSPSExtension), -NULL); -if (err < 0) -return err; - err = cbs_h264_read_sps_extension(ctx, , unit->content); if (err < 0) return err; @@ -838,13 +785,7 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, case H264_NAL_PPS: { -H264RawPPS *pps; - -err = ff_cbs_alloc_unit_content(unit, sizeof(*pps), -_h264_free_pps); -if (err < 0) -return err; -pps = unit->content; +H264RawPPS *pps = unit->content; err = cbs_h264_read_pps(ctx, , pps); if (err < 0) @@ -860,15 +801,9 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, case H264_NAL_IDR_SLICE: case H264_NAL_AUXILIARY_SLICE: { -H264RawSlice *slice; +H264RawSlice *slice = unit->content; int pos, len; -err = ff_cbs_alloc_unit_content(unit, sizeof(*slice), -_h264_free_slice); -if (err < 0) -return err; -slice = unit->content; - err = cbs_h264_read_slice_header(ctx, , >header); if (err < 0) return err; @@ -890,11 +825,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, case H264_NAL_AUD: { -err = ff_cbs_alloc_unit_content(unit, -sizeof(H264RawAUD), NULL); -if (err < 0) -return err; - err = cbs_h264_read_aud(ctx, , unit->content); if (err < 0) return err; @@ -903,11 +833,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, ca
[FFmpeg-cvslog] cbs_av1: Fill tile width/height values when uniform_tile_spacing_flag is set
ffmpeg | branch: master | Mark Thompson | Mon Aug 31 22:00:57 2020 +0100| [2a19232c1996fee52a3f4201fa379001627dcc89] | committer: Mark Thompson cbs_av1: Fill tile width/height values when uniform_tile_spacing_flag is set They are not explicitly in the bitstream in this case, but it is helpful to be able to use these values without always needing to check the flag beforehand. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2a19232c1996fee52a3f4201fa379001627dcc89 --- libavcodec/cbs_av1_syntax_template.c | 9 + 1 file changed, 9 insertions(+) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 19b82bc3f8..2d2e240e3e 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -636,6 +636,15 @@ static int FUNC(tile_info)(CodedBitstreamContext *ctx, RWContext *rw, current->tile_rows_log2; current->tile_rows = (sb_rows + tile_height_sb - 1) / tile_height_sb; +for (i = 0; i < current->tile_cols - 1; i++) +infer(width_in_sbs_minus_1[i], tile_width_sb - 1); +infer(width_in_sbs_minus_1[i], + sb_cols - (current->tile_cols - 1) * tile_width_sb - 1); +for (i = 0; i < current->tile_rows - 1; i++) +infer(height_in_sbs_minus_1[i], tile_height_sb - 1); +infer(height_in_sbs_minus_1[i], + sb_rows - (current->tile_rows - 1) * tile_height_sb - 1); + } else { int widest_tile_sb, start_sb, size_sb, max_width, max_height; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs: Describe allocate/free methods in tabular form
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 17:32:18 2020 +0100| [bc7a7e0d65bd72b317b2c4b84fac505ba3db7556] | committer: Mark Thompson cbs: Describe allocate/free methods in tabular form Unit types are split into three categories, depending on how their content is managed: * POD structure - these require no special treatment. * Structure containing references to refcounted buffers - these can use a common free function when the offsets of all the internal references are known. * More complex structures - these still require ad-hoc treatment. For each codec we can then maintain a table of descriptors for each set of equivalent unit types, defining the mechanism needed to allocate/free that unit content. This is not required to be used immediately - a new alloc function supports this, but does not replace the old one which works without referring to these tables. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bc7a7e0d65bd72b317b2c4b84fac505ba3db7556 --- libavcodec/cbs.c | 69 +++ libavcodec/cbs.h | 9 +++ libavcodec/cbs_internal.h | 61 + 3 files changed, 139 insertions(+) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 6464980c8e..61cf8e3466 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -802,3 +802,72 @@ void ff_cbs_delete_unit(CodedBitstreamFragment *frag, frag->units + position + 1, (frag->nb_units - position) * sizeof(*frag->units)); } + +static void cbs_default_free_unit_content(void *opaque, uint8_t *data) +{ +const CodedBitstreamUnitTypeDescriptor *desc = opaque; +if (desc->content_type == CBS_CONTENT_TYPE_INTERNAL_REFS) { +int i; +for (i = 0; i < desc->nb_ref_offsets; i++) { +void **ptr = (void**)(data + desc->ref_offsets[i]); +av_buffer_unref((AVBufferRef**)(ptr + 1)); +} +} +av_free(data); +} + +static const CodedBitstreamUnitTypeDescriptor +*cbs_find_unit_type_desc(CodedBitstreamContext *ctx, + CodedBitstreamUnit *unit) +{ +const CodedBitstreamUnitTypeDescriptor *desc; +int i, j; + +if (!ctx->codec->unit_types) +return NULL; + +for (i = 0;; i++) { +desc = >codec->unit_types[i]; +if (desc->nb_unit_types == 0) +break; +if (desc->nb_unit_types == CBS_UNIT_TYPE_RANGE) { +if (unit->type >= desc->unit_type_range_start && +unit->type <= desc->unit_type_range_end) +return desc; +} else { +for (j = 0; j < desc->nb_unit_types; j++) { +if (desc->unit_types[j] == unit->type) +return desc; +} +} +} +return NULL; +} + +int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx, + CodedBitstreamUnit *unit) +{ +const CodedBitstreamUnitTypeDescriptor *desc; + +av_assert0(!unit->content && !unit->content_ref); + +desc = cbs_find_unit_type_desc(ctx, unit); +if (!desc) +return AVERROR(ENOSYS); + +unit->content = av_mallocz(desc->content_size); +if (!unit->content) +return AVERROR(ENOMEM); + +unit->content_ref = +av_buffer_create(unit->content, desc->content_size, + desc->content_free ? desc->content_free +: cbs_default_free_unit_content, + (void*)desc, 0); +if (!unit->content_ref) { +av_freep(>content); +return AVERROR(ENOMEM); +} + +return 0; +} diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index 07faf18c5b..ea8d942894 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -349,6 +349,15 @@ int ff_cbs_alloc_unit_content(CodedBitstreamUnit *unit, size_t size, void (*free)(void *opaque, uint8_t *content)); +/** + * Allocate a new internal content buffer matching the type of the unit. + * + * The content will be zeroed. + */ +int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx, + CodedBitstreamUnit *unit); + + /** * Allocate a new internal data buffer of the given size in the unit. * diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index 4c5a535ca6..282492bc88 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -25,11 +25,72 @@ #include "put_bits.h" +enum CBSContentType { +// Unit content is a simple structure. +CBS_CONTENT_TYPE_POD, +// Unit content contains some references to other structures, but all +// managed via buffer reference counting. The descriptor defines the +// structure offsets of every buffer reference. +CBS_CONTENT_TYPE_
[FFmpeg-cvslog] cbs: Add macros to support defining unit type tables
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 17:32:19 2020 +0100| [225f2878853e1e4980d55707c68a14595a639ad3] | committer: Mark Thompson cbs: Add macros to support defining unit type tables > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=225f2878853e1e4980d55707c68a14595a639ad3 --- libavcodec/cbs_internal.h | 24 1 file changed, 24 insertions(+) diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index 282492bc88..35159f9c5f 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -167,6 +167,30 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1))) +#define CBS_UNIT_TYPE_POD(type, structure) { \ +.nb_unit_types = 1, \ +.unit_types = { type }, \ +.content_type = CBS_CONTENT_TYPE_POD, \ +.content_size = sizeof(structure), \ +} +#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field) { \ +.nb_unit_types = 1, \ +.unit_types = { type }, \ +.content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \ +.content_size = sizeof(structure), \ +.nb_ref_offsets = 1, \ +.ref_offsets= { offsetof(structure, ref_field) }, \ +} +#define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func) { \ +.nb_unit_types = 1, \ +.unit_types = { type }, \ +.content_type = CBS_CONTENT_TYPE_COMPLEX, \ +.content_size = sizeof(structure), \ +.content_free = free_func, \ +} +#define CBS_UNIT_TYPE_END_OF_LIST { .nb_unit_types = 0 } + + extern const CodedBitstreamType ff_cbs_type_av1; extern const CodedBitstreamType ff_cbs_type_h264; extern const CodedBitstreamType ff_cbs_type_h265; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] hwcontext_vaapi: Don't require a render node when deriving from DRM
ffmpeg | branch: master | Mark Thompson | Fri Aug 28 23:15:41 2020 +0100| [303d252a4b4c104685dc46152c26abaf7ff2ce60] | committer: Mark Thompson hwcontext_vaapi: Don't require a render node when deriving from DRM The V4L2 driver does not actually have an associated DRM device at all, so users work around the requirement by giving libva an unrelated display-only device instead (which is fine, because it doesn't actually do anything with that device). This was broken by bc9b6358fb7315c0173de322472641766f6289da forcing a render node, because the display-only device did not have an associated render node to use. Fix that by just passing through the original non-render DRM fd if we can't find a render node. Reported-by: Paul Kocialkowski Tested-by: Paul Kocialkowski > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=303d252a4b4c104685dc46152c26abaf7ff2ce60 --- libavutil/hwcontext_vaapi.c | 28 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 38bdeb7820..2227d6ed69 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1677,20 +1677,24 @@ static int vaapi_device_derive(AVHWDeviceContext *ctx, } else { render_node = drmGetRenderDeviceNameFromFd(src_hwctx->fd); if (!render_node) { -av_log(ctx, AV_LOG_ERROR, "Failed to find a render node " - "matching the DRM device.\n"); -return AVERROR(ENODEV); -} -fd = open(render_node, O_RDWR); -if (fd < 0) { -av_log(ctx, AV_LOG_ERROR, "Failed to open render node %s" - "matching the DRM device.\n", render_node); +av_log(ctx, AV_LOG_VERBOSE, "Using non-render node " + "because the device does not have an " + "associated render node.\n"); +fd = src_hwctx->fd; +} else { +fd = open(render_node, O_RDWR); +if (fd < 0) { +av_log(ctx, AV_LOG_VERBOSE, "Using non-render node " + "because the associated render node " + "could not be opened.\n"); +fd = src_hwctx->fd; +} else { +av_log(ctx, AV_LOG_VERBOSE, "Using render node %s " + "in place of non-render DRM device.\n", + render_node); +} free(render_node); -return AVERROR(errno); } -av_log(ctx, AV_LOG_VERBOSE, "Using render node %s in place " - "of non-render DRM device.\n", render_node); -free(render_node); } } #else ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_av1: Fix test for presence of buffer_removal_time element
ffmpeg | branch: master | Mark Thompson | Sun Aug 23 17:06:06 2020 +0100| [b567cb8d0b664775201d843ab985f49fefeb25d5] | committer: Mark Thompson cbs_av1: Fix test for presence of buffer_removal_time element The frame must be in both the spatial and temporal layers for the operating point, not just one of them. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b567cb8d0b664775201d843ab985f49fefeb25d5 --- libavcodec/cbs_av1_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 240fa188e4..3a832c3ca0 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1388,7 +1388,7 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, int in_temporal_layer = (op_pt_idc >> priv->temporal_id ) & 1; int in_spatial_layer = (op_pt_idc >> (priv->spatial_id + 8)) & 1; if (seq->operating_point_idc[i] == 0 || -in_temporal_layer || in_spatial_layer) { +(in_temporal_layer && in_spatial_layer)) { fbs(seq->decoder_model_info.buffer_removal_time_length_minus_1 + 1, buffer_removal_time[i], 1, i); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] kmsgrab: Use GetFB2 if available
ffmpeg | branch: master | Mark Thompson | Sun Jul 5 16:49:44 2020 +0100| [ef934dba2d0caab7ab778c99c6005b8b9720eb27] | committer: Mark Thompson kmsgrab: Use GetFB2 if available The most useful feature here is the ability to automatically extract the framebuffer format and modifiers. It also makes support for multi-plane framebuffers possible, though none are added to the format table in this patch. This requires libdrm 2.4.101 (from April 2020) to build, so it includes a configure check to allow compatibility with existing distributions. Even with libdrm support, it still won't do anything at runtime if you are running Linux < 5.7 (before June 2020). > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ef934dba2d0caab7ab778c99c6005b8b9720eb27 --- configure | 4 + libavdevice/kmsgrab.c | 218 +- 2 files changed, 203 insertions(+), 19 deletions(-) diff --git a/configure b/configure index b137669dd3..8de1afcb99 100755 --- a/configure +++ b/configure @@ -2325,6 +2325,7 @@ HAVE_LIST=" $THREADS_LIST $TOOLCHAIN_FEATURES $TYPES_LIST +libdrm_getfb2 makeinfo makeinfo_html opencl_d3d11 @@ -6657,6 +6658,9 @@ test_cpp <= 0.35.0" "va/va.h" vaInitialize diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c index 8e8c7de549..4b5bcfbf83 100644 --- a/libavdevice/kmsgrab.c +++ b/libavdevice/kmsgrab.c @@ -27,6 +27,11 @@ #include #include +// Required for compatibility when building against libdrm < 2.4.83. +#ifndef DRM_FORMAT_MOD_INVALID +#define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1) +#endif + #include "libavutil/hwcontext.h" #include "libavutil/hwcontext_drm.h" #include "libavutil/internal.h" @@ -45,6 +50,7 @@ typedef struct KMSGrabContext { AVBufferRef *device_ref; AVHWDeviceContext *device; AVDRMDeviceContext *hwctx; +int fb2_available; AVBufferRef *frames_ref; AVHWFramesContext *frames; @@ -68,8 +74,10 @@ typedef struct KMSGrabContext { static void kmsgrab_free_desc(void *opaque, uint8_t *data) { AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor*)data; +int i; -close(desc->objects[0].fd); +for (i = 0; i < desc->nb_objects; i++) +close(desc->objects[i].fd); av_free(desc); } @@ -144,6 +152,116 @@ fail: return err; } +#if HAVE_LIBDRM_GETFB2 +static int kmsgrab_get_fb2(AVFormatContext *avctx, + drmModePlane *plane, + AVDRMFrameDescriptor *desc) +{ +KMSGrabContext *ctx = avctx->priv_data; +drmModeFB2 *fb; +int err, i, nb_objects; + +fb = drmModeGetFB2(ctx->hwctx->fd, plane->fb_id); +if (!fb) { +err = errno; +av_log(avctx, AV_LOG_ERROR, "Failed to get framebuffer " + "%"PRIu32": %s.\n", plane->fb_id, strerror(err)); +return AVERROR(err); +} +if (fb->pixel_format != ctx->drm_format) { +av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" framebuffer " + "format changed: now %"PRIx32".\n", + ctx->plane_id, fb->pixel_format); +err = AVERROR(EIO); +goto fail; +} +if (fb->modifier != ctx->drm_format_modifier) { +av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" framebuffer " + "format modifier changed: now %"PRIx64".\n", + ctx->plane_id, fb->modifier); +err = AVERROR(EIO); +goto fail; +} +if (fb->width != ctx->width || fb->height != ctx->height) { +av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" framebuffer " + "dimensions changed: now %"PRIu32"x%"PRIu32".\n", + ctx->plane_id, fb->width, fb->height); +err = AVERROR(EIO); +goto fail; +} +if (!fb->handles[0]) { +av_log(avctx, AV_LOG_ERROR, "No handle set on framebuffer.\n"); +err = AVERROR(EIO); +goto fail; +} + +*desc = (AVDRMFrameDescriptor) { +.nb_layers = 1, +.layers[0] = { +.format = ctx->drm_format, +}, +}; + +nb_objects = 0; +for (i = 0; i < 4 && fb->handles[i]; i++) { +size_t size; +int dup = 0, j, obj; + +size = fb->offsets[i] + fb->height * fb->pitches[i]; + +for (j = 0; j < i; j++) { +if (fb->handles[i] == fb->handles[j]) { +dup = 1; +break; +} +} +if (dup) { +obj = desc->layers[0].planes[j].object_index; + +if (desc->objects[j].size < size) +desc->objects[j].size = size; + +desc->layers[0].planes[i
[FFmpeg-cvslog] doc/indevs: Note improved behaviour of kmsgrab with Linux 5.7
ffmpeg | branch: master | Mark Thompson | Sun Jul 5 16:49:46 2020 +0100| [991daf3895cf2c322e288f015ae8d5ef0d3b45f3] | committer: Mark Thompson doc/indevs: Note improved behaviour of kmsgrab with Linux 5.7 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=991daf3895cf2c322e288f015ae8d5ef0d3b45f3 --- doc/indevs.texi | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index 0f33fc66d8..4d2312e201 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -889,11 +889,15 @@ If you don't understand what all of that means, you probably don't want this. L DRM device to capture on. Defaults to @option{/dev/dri/card0}. @item format -Pixel format of the framebuffer. Defaults to @option{bgr0}. +Pixel format of the framebuffer. This can be autodetected if you are running Linux 5.7 +or later, but needs to be provided for earlier versions. Defaults to @option{bgr0}, +which is the most common format used by the Linux console and Xorg X server. @item format_modifier Format modifier to signal on output frames. This is necessary to import correctly into -some APIs, but can't be autodetected. See the libdrm documentation for possible values. +some APIs. It can be autodetected if you are running Linux 5.7 or later, but will need +to be provided explicitly when needed in earlier versions. See the libdrm documentation +for possible values. @item crtc_id KMS CRTC ID to define the capture source. The first active plane on the given CRTC ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] kmsgrab: Add more supported formats
ffmpeg | branch: master | Mark Thompson | Sat Aug 1 18:57:35 2020 +0100| [6e951d0cf8dcbc98cb45b9a72ed8d9e76f4a2e3f] | committer: Mark Thompson kmsgrab: Add more supported formats X2RGB10 tested on both Intel Gen9 and AMD Polaris 11. NV12 tested on Intel Gen9 only - since it has multiple planes, this requires GetFB2. Also add some comments to split the list up a bit. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6e951d0cf8dcbc98cb45b9a72ed8d9e76f4a2e3f --- libavdevice/kmsgrab.c | 9 + 1 file changed, 9 insertions(+) diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c index edfa264909..a0aa9dc22f 100644 --- a/libavdevice/kmsgrab.c +++ b/libavdevice/kmsgrab.c @@ -367,6 +367,7 @@ static const struct { enum AVPixelFormat pixfmt; uint32_t drm_format; } kmsgrab_formats[] = { +// Monochrome. #ifdef DRM_FORMAT_R8 { AV_PIX_FMT_GRAY8,DRM_FORMAT_R8 }, #endif @@ -374,6 +375,7 @@ static const struct { { AV_PIX_FMT_GRAY16LE, DRM_FORMAT_R16 }, { AV_PIX_FMT_GRAY16BE, DRM_FORMAT_R16 | DRM_FORMAT_BIG_ENDIAN }, #endif +// <8-bit RGB. { AV_PIX_FMT_BGR8, DRM_FORMAT_BGR233 }, { AV_PIX_FMT_RGB555LE, DRM_FORMAT_XRGB1555 }, { AV_PIX_FMT_RGB555BE, DRM_FORMAT_XRGB1555 | DRM_FORMAT_BIG_ENDIAN }, @@ -383,6 +385,7 @@ static const struct { { AV_PIX_FMT_RGB565BE, DRM_FORMAT_RGB565 | DRM_FORMAT_BIG_ENDIAN }, { AV_PIX_FMT_BGR565LE, DRM_FORMAT_BGR565 }, { AV_PIX_FMT_BGR565BE, DRM_FORMAT_BGR565 | DRM_FORMAT_BIG_ENDIAN }, +// 8-bit RGB. { AV_PIX_FMT_RGB24,DRM_FORMAT_RGB888 }, { AV_PIX_FMT_BGR24,DRM_FORMAT_BGR888 }, { AV_PIX_FMT_0RGB, DRM_FORMAT_BGRX }, @@ -393,6 +396,12 @@ static const struct { { AV_PIX_FMT_ABGR, DRM_FORMAT_RGBA }, { AV_PIX_FMT_RGBA, DRM_FORMAT_ABGR }, { AV_PIX_FMT_BGRA, DRM_FORMAT_ARGB }, +// 10-bit RGB. +{ AV_PIX_FMT_X2RGB10LE, DRM_FORMAT_XRGB2101010 }, +{ AV_PIX_FMT_X2RGB10BE, DRM_FORMAT_XRGB2101010 | DRM_FORMAT_BIG_ENDIAN }, +// 8-bit YUV 4:2:0. +{ AV_PIX_FMT_NV12, DRM_FORMAT_NV12 }, +// 8-bit YUV 4:2:2. { AV_PIX_FMT_YUYV422, DRM_FORMAT_YUYV }, { AV_PIX_FMT_YVYU422, DRM_FORMAT_YVYU }, { AV_PIX_FMT_UYVY422, DRM_FORMAT_UYVY }, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] kmsgrab: Don't require the user to set framebuffer format
ffmpeg | branch: master | Mark Thompson | Sun Jul 5 16:49:45 2020 +0100| [ff14858a6045aa62cd508b4a6c50973a291c91aa] | committer: Mark Thompson kmsgrab: Don't require the user to set framebuffer format This is provided by GetFB2, but we still need the option for cases where that isn't available. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff14858a6045aa62cd508b4a6c50973a291c91aa --- libavdevice/kmsgrab.c | 55 +-- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c index 4b5bcfbf83..edfa264909 100644 --- a/libavdevice/kmsgrab.c +++ b/libavdevice/kmsgrab.c @@ -410,18 +410,6 @@ static av_cold int kmsgrab_read_header(AVFormatContext *avctx) AVStream *stream; int err, i; -for (i = 0; i < FF_ARRAY_ELEMS(kmsgrab_formats); i++) { -if (kmsgrab_formats[i].pixfmt == ctx->format) { -ctx->drm_format = kmsgrab_formats[i].drm_format; -break; -} -} -if (i >= FF_ARRAY_ELEMS(kmsgrab_formats)) { -av_log(avctx, AV_LOG_ERROR, "Unsupported format %s.\n", - av_get_pix_fmt_name(ctx->format)); -return AVERROR(EINVAL); -} - err = av_hwdevice_ctx_create(>device_ref, AV_HWDEVICE_TYPE_DRM, ctx->device_path, NULL, 0); if (err < 0) { @@ -537,9 +525,25 @@ static av_cold int kmsgrab_read_header(AVFormatContext *avctx) err = AVERROR(EINVAL); goto fail; } -if (ctx->drm_format != fb2->pixel_format) { + +for (i = 0; i < FF_ARRAY_ELEMS(kmsgrab_formats); i++) { +if (kmsgrab_formats[i].drm_format == fb2->pixel_format) { +if (ctx->format != AV_PIX_FMT_NONE && +ctx->format != kmsgrab_formats[i].pixfmt) { +av_log(avctx, AV_LOG_ERROR, "Framebuffer pixel format " + "%"PRIx32" does not match expected format.\n", + fb2->pixel_format); +err = AVERROR(EINVAL); +goto fail; +} +ctx->drm_format = fb2->pixel_format; +ctx->format = kmsgrab_formats[i].pixfmt; +break; +} +} +if (i == FF_ARRAY_ELEMS(kmsgrab_formats)) { av_log(avctx, AV_LOG_ERROR, "Framebuffer pixel format " - "%"PRIx32" does not match expected format.\n", + "%"PRIx32" is not a known supported format.\n", fb2->pixel_format); err = AVERROR(EINVAL); goto fail; @@ -554,11 +558,32 @@ static av_cold int kmsgrab_read_header(AVFormatContext *avctx) } else { ctx->drm_format_modifier = fb2->modifier; } +av_log(avctx, AV_LOG_VERBOSE, "Format is %s, from " + "DRM format %"PRIx32" modifier %"PRIx64".\n", + av_get_pix_fmt_name(ctx->format), + ctx->drm_format, ctx->drm_format_modifier); + ctx->fb2_available = 1; } #endif if (!ctx->fb2_available) { +if (ctx->format == AV_PIX_FMT_NONE) { +// Backward compatibility: assume BGR0 if no format supplied. +ctx->format = AV_PIX_FMT_BGR0; +} +for (i = 0; i < FF_ARRAY_ELEMS(kmsgrab_formats); i++) { +if (kmsgrab_formats[i].pixfmt == ctx->format) { +ctx->drm_format = kmsgrab_formats[i].drm_format; +break; +} +} +if (i >= FF_ARRAY_ELEMS(kmsgrab_formats)) { +av_log(avctx, AV_LOG_ERROR, "Unsupported format %s.\n", + av_get_pix_fmt_name(ctx->format)); +return AVERROR(EINVAL); +} + fb = drmModeGetFB(ctx->hwctx->fd, plane->fb_id); if (!fb) { err = errno; @@ -649,7 +674,7 @@ static const AVOption options[] = { { .str = "/dev/dri/card0" }, 0, 0, FLAGS }, { "format", "Pixel format for framebuffer", OFFSET(format), AV_OPT_TYPE_PIXEL_FMT, - { .i64 = AV_PIX_FMT_BGR0 }, 0, UINT32_MAX, FLAGS }, + { .i64 = AV_PIX_FMT_NONE }, -1, INT32_MAX, FLAGS }, { "format_modifier", "DRM format modifier for framebuffer", OFFSET(drm_format_modifier), AV_OPT_TYPE_INT64, { .i64 = DRM_FORMAT_MOD_INVALID }, 0, INT64_MAX, FLAGS }, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] kmsgrab: Refactor and clean error cases
ffmpeg | branch: master | Mark Thompson | Sun Jul 5 16:49:43 2020 +0100| [fa0b064cf2ff267feaa9405ffd0ca74280f274d9] | committer: Mark Thompson kmsgrab: Refactor and clean error cases > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fa0b064cf2ff267feaa9405ffd0ca74280f274d9 --- libavdevice/kmsgrab.c | 161 +++--- 1 file changed, 100 insertions(+), 61 deletions(-) diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c index d0de774871..8e8c7de549 100644 --- a/libavdevice/kmsgrab.c +++ b/libavdevice/kmsgrab.c @@ -81,70 +81,44 @@ static void kmsgrab_free_frame(void *opaque, uint8_t *data) av_frame_free(); } -static int kmsgrab_read_packet(AVFormatContext *avctx, AVPacket *pkt) +static int kmsgrab_get_fb(AVFormatContext *avctx, + drmModePlane *plane, + AVDRMFrameDescriptor *desc) { KMSGrabContext *ctx = avctx->priv_data; -drmModePlane *plane; -drmModeFB *fb; -AVDRMFrameDescriptor *desc; -AVFrame *frame; -int64_t now; +drmModeFB *fb = NULL; int err, fd; -now = av_gettime(); -if (ctx->frame_last) { -int64_t delay; -while (1) { -delay = ctx->frame_last + ctx->frame_delay - now; -if (delay <= 0) -break; -av_usleep(delay); -now = av_gettime(); -} -} -ctx->frame_last = now; - -plane = drmModeGetPlane(ctx->hwctx->fd, ctx->plane_id); -if (!plane) { -av_log(avctx, AV_LOG_ERROR, "Failed to get plane " - "%"PRIu32".\n", ctx->plane_id); -return AVERROR(EIO); -} -if (!plane->fb_id) { -av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" no longer has " - "an associated framebuffer.\n", ctx->plane_id); -return AVERROR(EIO); -} - fb = drmModeGetFB(ctx->hwctx->fd, plane->fb_id); if (!fb) { +err = errno; av_log(avctx, AV_LOG_ERROR, "Failed to get framebuffer " - "%"PRIu32".\n", plane->fb_id); -return AVERROR(EIO); + "%"PRIu32": %s.\n", plane->fb_id, strerror(err)); +err = AVERROR(err); +goto fail; } if (fb->width != ctx->width || fb->height != ctx->height) { av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" framebuffer " "dimensions changed: now %"PRIu32"x%"PRIu32".\n", ctx->plane_id, fb->width, fb->height); -return AVERROR(EIO); +err = AVERROR(EIO); +goto fail; } if (!fb->handle) { av_log(avctx, AV_LOG_ERROR, "No handle set on framebuffer.\n"); -return AVERROR(EIO); +err = AVERROR(EIO); +goto fail; } err = drmPrimeHandleToFD(ctx->hwctx->fd, fb->handle, O_RDONLY, ); if (err < 0) { err = errno; av_log(avctx, AV_LOG_ERROR, "Failed to get PRIME fd from " - "framebuffer handle: %s.\n", strerror(errno)); -return AVERROR(err); + "framebuffer handle: %s.\n", strerror(err)); +err = AVERROR(err); +goto fail; } -desc = av_mallocz(sizeof(*desc)); -if (!desc) -return AVERROR(ENOMEM); - *desc = (AVDRMFrameDescriptor) { .nb_objects = 1, .objects[0] = { @@ -164,31 +138,93 @@ static int kmsgrab_read_packet(AVFormatContext *avctx, AVPacket *pkt) }, }; +err = 0; +fail: +drmModeFreeFB(fb); +return err; +} + +static int kmsgrab_read_packet(AVFormatContext *avctx, AVPacket *pkt) +{ +KMSGrabContext *ctx = avctx->priv_data; +drmModePlane *plane = NULL; +AVDRMFrameDescriptor *desc = NULL; +AVFrame *frame = NULL; +int64_t now; +int err; + +now = av_gettime(); +if (ctx->frame_last) { +int64_t delay; +while (1) { +delay = ctx->frame_last + ctx->frame_delay - now; +if (delay <= 0) +break; +av_usleep(delay); +now = av_gettime(); +} +} +ctx->frame_last = now; + +plane = drmModeGetPlane(ctx->hwctx->fd, ctx->plane_id); +if (!plane) { +err = errno; +av_log(avctx, AV_LOG_ERROR, "Failed to get plane " + "%"PRIu32": %s.\n", ctx->plane_id, strerror(err)); +err = AVERROR(err); +goto fail; +} +if (!plane->fb_id) { +av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" no longer has " + "an associated framebuffer.\n", ctx->plane_id); +err = AVERROR(EIO); +goto fail; +} + +
[FFmpeg-cvslog] vaapi_encode_h265: Fix ordering of tile dimensions
ffmpeg | branch: master | Mark Thompson | Tue Jul 28 23:50:21 2020 +0100| [bc58d1f58eeb7f80049b18395256f2a8cb039f64] | committer: Mark Thompson vaapi_encode_h265: Fix ordering of tile dimensions Dimensions are normally specified as width x height, and this will match the same option to libaom-av1. Remove the indirection through the private context at the same time. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bc58d1f58eeb7f80049b18395256f2a8cb039f64 --- doc/encoders.texi | 2 +- libavcodec/vaapi_encode.h | 2 +- libavcodec/vaapi_encode_h265.c | 13 +++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 78b3be9605..de0472e225 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3264,7 +3264,7 @@ messages). @end table @item tiles -Set the number of tiles to encode the input video with, as rows x columns. +Set the number of tiles to encode the input video with, as columns x rows. Larger numbers allow greater parallelism in both encoding and decoding, but may decrease coding efficiency. diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 6487a99604..2d71eb0199 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -307,8 +307,8 @@ typedef struct VAAPIEncodeContext { int slice_size; // Tile encoding. -int tile_rows; int tile_cols; +int tile_rows; // Tile width of the i-th column. int col_width[MAX_TILE_COLS]; // Tile height of i-th row. diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 511218f659..04bd2bef1d 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -63,9 +63,6 @@ typedef struct VAAPIEncodeH265Context { int level; int sei; -int trows; -int tcols; - // Derived settings. int fixed_qp_idr; int fixed_qp_p; @@ -1208,11 +1205,6 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx) if (priv->qp > 0) ctx->explicit_qp = priv->qp; -if (priv->trows && priv->tcols) { -ctx->tile_rows = priv->trows; -ctx->tile_cols = priv->tcols; -} - return ff_vaapi_encode_init(avctx); } @@ -1289,8 +1281,9 @@ static const AVOption vaapi_encode_h265_options[] = { { .i64 = SEI_MASTERING_DISPLAY | SEI_CONTENT_LIGHT_LEVEL }, INT_MIN, INT_MAX, FLAGS, "sei" }, -{ "tiles", "Tile rows x cols", - OFFSET(trows), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, FLAGS }, +{ "tiles", "Tile columns x rows", + OFFSET(common.tile_cols), AV_OPT_TYPE_IMAGE_SIZE, + { .str = NULL }, 0, 0, FLAGS }, { NULL }, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode: Delete unused field
ffmpeg | branch: master | Mark Thompson | Tue Jul 28 23:50:23 2020 +0100| [c67bdd6534a0ee67c0d18aed0e3345e59464254f] | committer: Mark Thompson vaapi_encode: Delete unused field > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c67bdd6534a0ee67c0d18aed0e3345e59464254f --- libavcodec/vaapi_encode.c | 12 libavcodec/vaapi_encode.h | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 4544090bcc..b3a02459f1 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -607,11 +607,9 @@ fail_with_picture: fail: for(i = 0; i < pic->nb_param_buffers; i++) vaDestroyBuffer(ctx->hwctx->display, pic->param_buffers[i]); -for (i = 0; i < pic->nb_slices; i++) { -if (pic->slices) { -av_freep(>slices[i].priv_data); +if (pic->slices) { +for (i = 0; i < pic->nb_slices; i++) av_freep(>slices[i].codec_slice_params); -} } fail_at_end: av_freep(>codec_picture_params); @@ -742,11 +740,9 @@ static int vaapi_encode_free(AVCodecContext *avctx, if (pic->encode_issued) vaapi_encode_discard(avctx, pic); -for (i = 0; i < pic->nb_slices; i++) { -if (pic->slices) { -av_freep(>slices[i].priv_data); +if (pic->slices) { +for (i = 0; i < pic->nb_slices; i++) av_freep(>slices[i].codec_slice_params); -} } av_freep(>codec_picture_params); diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 2d71eb0199..aa2a45bca6 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -64,7 +64,6 @@ typedef struct VAAPIEncodeSlice { int row_size; int block_start; int block_size; -void *priv_data; void *codec_slice_params; } VAAPIEncodeSlice; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode_h265: Remove confusing and redundant tile options
ffmpeg | branch: master | Mark Thompson | Tue Jul 28 23:50:20 2020 +0100| [e80fe329435d08f13a4b506c1af06359a31267f9] | committer: Mark Thompson vaapi_encode_h265: Remove confusing and redundant tile options The tile_rows/cols options currently do a confusingly different thing to the options of the same name on other encoders like libvpx and libaom. There is no backward-compatibility reason to implement the log2 behaviour as there was for libaom, so just get rid of them entirely. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e80fe329435d08f13a4b506c1af06359a31267f9 --- doc/encoders.texi | 8 libavcodec/vaapi_encode_h265.c | 4 2 files changed, 12 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 2f5457fb26..78b3be9605 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3268,14 +3268,6 @@ Set the number of tiles to encode the input video with, as rows x columns. Larger numbers allow greater parallelism in both encoding and decoding, but may decrease coding efficiency. -@item tile_rows -Selects how many rows of tiles to encode with. For example, 4 tile rows would -be requested by setting the tile_rows option to 4. - -@item tile_cols -Selects how many columns of tiles to encode with. For example, 5 tile columns -would be requested by setting the tile_cols option to 5. - @end table @item mjpeg_vaapi diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index f6008778df..511218f659 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1291,10 +1291,6 @@ static const AVOption vaapi_encode_h265_options[] = { { "tiles", "Tile rows x cols", OFFSET(trows), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, FLAGS }, -{ "tile_rows", "Number of rows for tile encoding", - OFFSET(trows), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, -{ "tile_cols", "Number of cols for tile encoding", - OFFSET(tcols), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, { NULL }, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode_h265: Don't require uniform_spacing_flag
ffmpeg | branch: master | Mark Thompson | Tue Jul 28 23:50:22 2020 +0100| [3d19c5ee688ebe9adeee8b3ddf9274517e55c8ab] | committer: Mark Thompson vaapi_encode_h265: Don't require uniform_spacing_flag Though still use it if the tile arrangement matches. Also try to keep the fields in the same order as the standard. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3d19c5ee688ebe9adeee8b3ddf9274517e55c8ab --- libavcodec/vaapi_encode_h265.c | 41 ++--- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 04bd2bef1d..316030914c 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -555,23 +555,42 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) pps->cu_qp_delta_enabled_flag = (ctx->va_rc_mode != VA_RC_CQP); pps->diff_cu_qp_delta_depth = 0; -pps->pps_loop_filter_across_slices_enabled_flag = 1; - if (ctx->tile_rows && ctx->tile_cols) { -pps->tiles_enabled_flag = 1; -pps->uniform_spacing_flag = 1; - -pps->num_tile_rows_minus1 = ctx->tile_rows - 1; -pps->num_tile_columns_minus1= ctx->tile_cols - 1; - -pps->loop_filter_across_tiles_enabled_flag = 1; +int uniform_spacing; + +pps->tiles_enabled_flag = 1; +pps->num_tile_columns_minus1 = ctx->tile_cols - 1; +pps->num_tile_rows_minus1= ctx->tile_rows - 1; + +// Test whether the spacing provided matches the H.265 uniform +// spacing, and set the flag if it does. +uniform_spacing = 1; +for (i = 0; i <= pps->num_tile_columns_minus1 && +uniform_spacing; i++) { +if (ctx->col_width[i] != +(i + 1) * ctx->slice_block_cols / ctx->tile_cols - + i * ctx->slice_block_cols / ctx->tile_cols) +uniform_spacing = 0; +} +for (i = 0; i <= pps->num_tile_rows_minus1 && +uniform_spacing; i++) { +if (ctx->row_height[i] != +(i + 1) * ctx->slice_block_rows / ctx->tile_rows - + i * ctx->slice_block_rows / ctx->tile_rows) +uniform_spacing = 0; +} +pps->uniform_spacing_flag = uniform_spacing; -for (i = 0; i <= pps->num_tile_rows_minus1; i++) -pps->row_height_minus1[i] = ctx->row_height[i] - 1; for (i = 0; i <= pps->num_tile_columns_minus1; i++) pps->column_width_minus1[i] = ctx->col_width[i] - 1; +for (i = 0; i <= pps->num_tile_rows_minus1; i++) +pps->row_height_minus1[i] = ctx->row_height[i] - 1; + +pps->loop_filter_across_tiles_enabled_flag = 1; } +pps->pps_loop_filter_across_slices_enabled_flag = 1; + // Fill VAAPI parameter buffers. *vseq = (VAEncSequenceParameterBufferHEVC) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libsvtav1: Fix the documentation to match the actual options
ffmpeg | branch: master | Mark Thompson | Thu Jul 30 22:32:00 2020 +0100| [11a2d05b3fa977ea9437725531a4875b735c977e] | committer: Mark Thompson libsvtav1: Fix the documentation to match the actual options > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=11a2d05b3fa977ea9437725531a4875b735c977e --- doc/encoders.texi | 48 libavcodec/libsvtav1.c | 6 +++--- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index af7d2ba983..2f5457fb26 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1687,7 +1687,7 @@ Enable smooth interintra mode. Default is true. @end table -@section libsvt-av1 +@section libsvtav1 SVT-AV1 encoder wrapper. @@ -1697,31 +1697,55 @@ You need to explicitly configure the build with @code{--enable-libsvtav1}. @subsection Options @table @option +@item profile +Set the encoding profile. + +@item level +Set the operating point level. + +@item tier +Set the operating point tier. + +@item rc +Set the rate control mode to use. + +Possible modes: +@table @option +@item cqp +Constant quantizer: use fixed values of qindex (dependent on the frame type) +throughout the stream. This mode is the default. + +@item vbr +Variable bitrate: use a target bitrate for the whole stream. + +@item cvbr +Constrained variable bitrate: use a target bitrate for each GOP. +@end table + @item qmax -Sets the maximum quantizer to use when using bitrate mode. +Set the maximum quantizer to use when using a bitrate mode. @item qmin -Sets the minimum quantizer to use when using bitrate mode. +Set the minimum quantizer to use when using a bitrate mode. @item qp -Uses quantizer mode to encode at the given quantizer (0-63). +Set the quantizer used in cqp rate control mode (0-63). -@item hielevel +@item sc_detection Enable scene change detection. @item la_depth Set number of frames to look ahead (0-120). @item preset -Set encoding preset. +Set the quality-speed tradeoff, in the range 0 to 8. Higher values are +faster but lower quality. Defaults to 8 (highest speed). -@item tier - -@item tile-rows -Selects how many rows of tiles to encode with (0-6). +@item tile_rows +Set log2 of the number of rows of tiles to use (0-6). -@item tile-columns -Selects how many columns of tiles to encode with (0-4). +@item tile_columns +Set log2 of the number of columns of tiles to use (0-4). @end table diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 13d3adc0f8..40942c6f6a 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -489,7 +489,7 @@ static const AVOption options[] = { { "preset", "Encoding preset [0, 8]", OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = MAX_ENC_PRESET }, 0, MAX_ENC_PRESET, VE }, -{ "tier", "Set tier (general_tier_flag)", OFFSET(tier), +{ "tier", "Set operating point tier", OFFSET(tier), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, "tier" }, { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "tier" }, { "high", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "tier" }, @@ -526,11 +526,11 @@ static const AVOption options[] = { { "rc", "Bit rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, VE , "rc"}, -{ "cqp", "Const Quantization Parameter", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "rc" }, +{ "cqp", "Constant quantizer", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "rc" }, { "vbr", "Variable Bit Rate, use a target bitrate for the entire stream", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "rc" }, { "cvbr", "Constrained Variable Bit Rate, use a target bitrate for each GOP", 0, AV_OPT_TYPE_CONST,{ .i64 = 2 }, INT_MIN, INT_MAX, VE, "rc" }, -{ "qp", "QP value for intra frames", OFFSET(qp), +{ "qp", "Quantizer to use with cqp rate control mode", OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE }, { "sc_detection", "Scene change detection", OFFSET(scd), ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libsvtav1: Rename without a _
ffmpeg | branch: master | Mark Thompson | Thu Jul 30 22:31:58 2020 +0100| [30a4bdbc1f4853c1deb2cd551d8c661f7b067503] | committer: Mark Thompson libsvtav1: Rename without a _ The external library is called libsvtav1, so use this name everywhere. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=30a4bdbc1f4853c1deb2cd551d8c661f7b067503 --- configure| 2 +- libavcodec/Makefile | 2 +- libavcodec/allcodecs.c | 2 +- libavcodec/{libsvt_av1.c => libsvtav1.c} | 8 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 169f23e17f..b137669dd3 100755 --- a/configure +++ b/configure @@ -3245,7 +3245,7 @@ libshine_encoder_select="audio_frame_queue" libspeex_decoder_deps="libspeex" libspeex_encoder_deps="libspeex" libspeex_encoder_select="audio_frame_queue" -libsvt_av1_encoder_deps="libsvtav1" +libsvtav1_encoder_deps="libsvtav1" libtheora_encoder_deps="libtheora" libtwolame_encoder_deps="libtwolame" libvo_amrwbenc_encoder_deps="libvo_amrwbenc" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 9d4d52d048..98b388e260 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1026,7 +1026,7 @@ OBJS-$(CONFIG_LIBRAV1E_ENCODER) += librav1e.o OBJS-$(CONFIG_LIBSHINE_ENCODER) += libshine.o OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o -OBJS-$(CONFIG_LIBSVT_AV1_ENCODER) += libsvt_av1.o +OBJS-$(CONFIG_LIBSVTAV1_ENCODER) += libsvtav1.o OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 80142899fe..2e291f749f 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -727,7 +727,7 @@ extern AVCodec ff_librsvg_decoder; extern AVCodec ff_libshine_encoder; extern AVCodec ff_libspeex_encoder; extern AVCodec ff_libspeex_decoder; -extern AVCodec ff_libsvt_av1_encoder; +extern AVCodec ff_libsvtav1_encoder; extern AVCodec ff_libtheora_encoder; extern AVCodec ff_libtwolame_encoder; extern AVCodec ff_libvo_amrwbenc_encoder; diff --git a/libavcodec/libsvt_av1.c b/libavcodec/libsvtav1.c similarity index 99% rename from libavcodec/libsvt_av1.c rename to libavcodec/libsvtav1.c index c7ae5f9691..0c951286c7 100644 --- a/libavcodec/libsvt_av1.c +++ b/libavcodec/libsvtav1.c @@ -543,7 +543,7 @@ static const AVOption options[] = { }; static const AVClass class = { -.class_name = "libsvt_av1", +.class_name = "libsvtav1", .item_name = av_default_item_name, .option = options, .version= LIBAVUTIL_VERSION_INT, @@ -557,8 +557,8 @@ static const AVCodecDefault eb_enc_defaults[] = { { NULL }, }; -AVCodec ff_libsvt_av1_encoder = { -.name = "libsvt_av1", +AVCodec ff_libsvtav1_encoder = { +.name = "libsvtav1", .long_name = NULL_IF_CONFIG_SMALL("SVT-AV1(Scalable Video Technology for AV1) encoder"), .priv_data_size = sizeof(SvtContext), .type = AVMEDIA_TYPE_VIDEO, @@ -573,5 +573,5 @@ AVCodec ff_libsvt_av1_encoder = { .priv_class = , .defaults = eb_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, -.wrapper_name = "libsvt_av1", +.wrapper_name = "libsvtav1", }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libsvtav1: Use _ rather than - in options
ffmpeg | branch: master | Mark Thompson | Thu Jul 30 22:31:59 2020 +0100| [ad7aa1e8e7e60d3db1264c16c8cd891782ab8887] | committer: Mark Thompson libsvtav1: Use _ rather than - in options > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ad7aa1e8e7e60d3db1264c16c8cd891782ab8887 --- libavcodec/libsvtav1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 0c951286c7..13d3adc0f8 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -536,8 +536,8 @@ static const AVOption options[] = { { "sc_detection", "Scene change detection", OFFSET(scd), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, -{ "tile-columns", "Log2 of number of tile columns to use", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE}, -{ "tile-rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE}, +{ "tile_columns", "Log2 of number of tile columns to use", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE}, +{ "tile_rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE}, {NULL}, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] Revert "lavc/vaapi_encode: add EQUAL_MULTI_ROWS support for slice structure"
ffmpeg | branch: master | Mark Thompson | Mon Jul 27 22:27:14 2020 +0100| [16c2ed4362bde4502698f1768b884d81ea11abcb] | committer: Mark Thompson Revert "lavc/vaapi_encode: add EQUAL_MULTI_ROWS support for slice structure" This reverts commit 489c5db0791f39518775b12eef6d48276c17f96f. Treating EQUAL_MULTI_ROWS in the same way as the arbitrary-size cases is just wrong. Consider 9 rows, 4 slices - we pick 4 slices with sizes { 3, 2, 2, 2 }, which EQUAL_MULTI_ROWS does not allow. It isn't possible to split the frame into 4 slices at all with the EQUAL_MULTI_ROWS structure - the closest options are 3 slices with sizes { 3, 3, 3 } or 5 slices with sizes { 2, 2, 2, 2, 1 }. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=16c2ed4362bde4502698f1768b884d81ea11abcb --- libavcodec/vaapi_encode.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 6766641ac7..4544090bcc 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1908,9 +1908,6 @@ static av_cold int vaapi_encode_init_row_slice_structure(AVCodecContext *avctx, req_slices = avctx->slices; } if (slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS || -#if VA_CHECK_VERSION(1, 8, 0) -slice_structure & VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS || -#endif slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS) { ctx->nb_slices = req_slices; ctx->slice_size = ctx->slice_block_rows / ctx->nb_slices; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode_h265: Enable 4:2:2 support
ffmpeg | branch: master | Mark Thompson | Thu Mar 5 00:25:28 2020 +| [9badc602928a2e14797e4d0e4a20770e42932b7d] | committer: Linjie Fu vaapi_encode_h265: Enable 4:2:2 support > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9badc602928a2e14797e4d0e4a20770e42932b7d --- libavcodec/vaapi_encode_h265.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 7aa395fb61..f6008778df 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1136,6 +1136,10 @@ static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = { #if VA_CHECK_VERSION(0, 37, 0) { FF_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1, VAProfileHEVCMain10 }, { FF_PROFILE_HEVC_REXT,10, 3, 1, 1, VAProfileHEVCMain10 }, +#endif +#if VA_CHECK_VERSION(1, 2, 0) +{ FF_PROFILE_HEVC_REXT, 8, 3, 1, 0, VAProfileHEVCMain422_10 }, +{ FF_PROFILE_HEVC_REXT,10, 3, 1, 0, VAProfileHEVCMain422_10 }, #endif { FF_PROFILE_UNKNOWN } }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h265: Ensure that a predicted RPS doesn't contain too many pictures
ffmpeg | branch: master | Mark Thompson | Sun May 3 16:30:00 2020 +0100| [c53f9f436440be4e180aa3895920ef21019c076f] | committer: Mark Thompson cbs_h265: Ensure that a predicted RPS doesn't contain too many pictures If the RPS we are predicting from has maximum size then at least one of the pictures in it must be discarded before adding the current one. Also revert 588114cea4ee434c9c61353ed91ffc817d2965f5, which added now-redundant checks for the special case of a too-large RPS with all pictures being in the same direction from the current one. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c53f9f436440be4e180aa3895920ef21019c076f --- libavcodec/cbs_h265_syntax_template.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index d3ac618db6..55da1a0a11 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -522,7 +522,7 @@ static int FUNC(st_ref_pic_set)(CodedBitstreamContext *ctx, RWContext *rw, infer(inter_ref_pic_set_prediction_flag, 0); if (current->inter_ref_pic_set_prediction_flag) { -unsigned int ref_rps_idx, num_delta_pocs; +unsigned int ref_rps_idx, num_delta_pocs, num_ref_pics; const H265RawSTRefPicSet *ref; int delta_rps, d_poc; int ref_delta_poc_s0[HEVC_MAX_REFS], ref_delta_poc_s1[HEVC_MAX_REFS]; @@ -538,18 +538,28 @@ static int FUNC(st_ref_pic_set)(CodedBitstreamContext *ctx, RWContext *rw, ref_rps_idx = st_rps_idx - (current->delta_idx_minus1 + 1); ref = >st_ref_pic_set[ref_rps_idx]; num_delta_pocs = ref->num_negative_pics + ref->num_positive_pics; +av_assert0(num_delta_pocs < HEVC_MAX_DPB_SIZE); flag(delta_rps_sign); ue(abs_delta_rps_minus1, 0, INT16_MAX); delta_rps = (1 - 2 * current->delta_rps_sign) * (current->abs_delta_rps_minus1 + 1); +num_ref_pics = 0; for (j = 0; j <= num_delta_pocs; j++) { flags(used_by_curr_pic_flag[j], 1, j); if (!current->used_by_curr_pic_flag[j]) flags(use_delta_flag[j], 1, j); else infer(use_delta_flag[j], 1); +if (current->use_delta_flag[i]) +++num_ref_pics; +} +if (num_ref_pics >= HEVC_MAX_DPB_SIZE) { +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: " + "short-term ref pic set %d " + "contains too many pictures.\n", st_rps_idx); +return AVERROR_INVALIDDATA; } // Since the stored form of an RPS here is actually the delta-step @@ -601,8 +611,6 @@ static int FUNC(st_ref_pic_set)(CodedBitstreamContext *ctx, RWContext *rw, } } -if (i > 15) -return AVERROR_INVALIDDATA; infer(num_negative_pics, i); for (i = 0; i < current->num_negative_pics; i++) { infer(delta_poc_s0_minus1[i], @@ -632,8 +640,6 @@ static int FUNC(st_ref_pic_set)(CodedBitstreamContext *ctx, RWContext *rw, } } -if (i + current->num_negative_pics > 15) -return AVERROR_INVALIDDATA; infer(num_positive_pics, i); for (i = 0; i < current->num_positive_pics; i++) { infer(delta_poc_s1_minus1[i], ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] ffmpeg: Don't require a known device to pass a frames context to an encoder
ffmpeg | branch: master | Mark Thompson | Tue Apr 28 23:56:42 2020 +0100| [706ed34ce7aca7be4adab69a55dab02f4573591a] | committer: Mark Thompson ffmpeg: Don't require a known device to pass a frames context to an encoder The previous code here did not handle passing a frames context when ffmpeg itself did not know about the device it came from (for example, because it was created by device derivation inside a filter graph), which would break encoders requiring that input. Fix that by checking for HW frames and device context methods independently, and prefer to use a frames context method if possible. At the same time, revert the encoding additions to the device matching function because the additional complexity was not relevant to decoding. Also fixes #8637, which is the same case but with the device creation hidden in the ad-hoc libmfx setup code. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=706ed34ce7aca7be4adab69a55dab02f4573591a --- fftools/ffmpeg_hw.c | 75 ++--- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index c5c8aa97ef..fc4a5d31d6 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -19,6 +19,7 @@ #include #include "libavutil/avstring.h" +#include "libavutil/pixdesc.h" #include "libavfilter/buffersink.h" #include "ffmpeg.h" @@ -282,10 +283,7 @@ void hw_device_free_all(void) nb_hw_devices = 0; } -static HWDevice *hw_device_match_by_codec(const AVCodec *codec, - enum AVPixelFormat format, - int possible_methods, - int *matched_methods) +static HWDevice *hw_device_match_by_codec(const AVCodec *codec) { const AVCodecHWConfig *config; HWDevice *dev; @@ -294,18 +292,11 @@ static HWDevice *hw_device_match_by_codec(const AVCodec *codec, config = avcodec_get_hw_config(codec, i); if (!config) return NULL; -if (format != AV_PIX_FMT_NONE && -config->pix_fmt != AV_PIX_FMT_NONE && -config->pix_fmt != format) -continue; -if (!(config->methods & possible_methods)) +if (!(config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)) continue; dev = hw_device_get_by_type(config->device_type); -if (dev) { -if (matched_methods) -*matched_methods = config->methods & possible_methods; +if (dev) return dev; -} } } @@ -351,9 +342,7 @@ int hw_device_setup_for_decode(InputStream *ist) if (!dev) err = hw_device_init_from_type(type, NULL, ); } else { -dev = hw_device_match_by_codec(ist->dec, AV_PIX_FMT_NONE, - AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX, - NULL); +dev = hw_device_match_by_codec(ist->dec); if (!dev) { // No device for this codec, but not using generic hwaccel // and therefore may well not need one - ignore. @@ -429,37 +418,57 @@ int hw_device_setup_for_decode(InputStream *ist) int hw_device_setup_for_encode(OutputStream *ost) { -HWDevice *dev; -AVBufferRef *frames_ref; -int methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX; -int matched_methods; +const AVCodecHWConfig *config; +HWDevice *dev = NULL; +AVBufferRef *frames_ref = NULL; +int i; if (ost->filter) { frames_ref = av_buffersink_get_hw_frames_ctx(ost->filter->filter); if (frames_ref && ((AVHWFramesContext*)frames_ref->data)->format == -ost->enc_ctx->pix_fmt) -methods |= AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX; +ost->enc_ctx->pix_fmt) { +// Matching format, will try to use hw_frames_ctx. +} else { +frames_ref = NULL; +} } -dev = hw_device_match_by_codec(ost->enc, ost->enc_ctx->pix_fmt, - methods, _methods); -if (dev) { -if (matched_methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) { -ost->enc_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref); -if (!ost->enc_ctx->hw_device_ctx) -return AVERROR(ENOMEM); -} -if (matched_methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX) { +for (i = 0;; i++) { +config = avcodec_get_hw_config(ost->enc, i); +if (!config) +break; + +if (frames_ref && +config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX && +(config->pix_fmt == AV_PIX_FMT_NONE ||
[FFmpeg-cvslog] avcodec/nvenc: add hardware config metadata
ffmpeg | branch: master | Mark Thompson | Mon Apr 13 16:33:18 2020 +0100| [1dff97b7bc792267c3e79030fbaed0e9fefc65fb] | committer: Timo Rothenpieler avcodec/nvenc: add hardware config metadata Signed-off-by: Timo Rothenpieler > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1dff97b7bc792267c3e79030fbaed0e9fefc65fb --- libavcodec/nvenc.c | 10 ++ libavcodec/nvenc.h | 2 ++ libavcodec/nvenc_h264.c | 3 +++ libavcodec/nvenc_hevc.c | 2 ++ 4 files changed, 17 insertions(+) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 9a96bf2bba..2c75399b44 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -55,6 +55,16 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = { AV_PIX_FMT_NONE }; +const AVCodecHWConfigInternal *ff_nvenc_hw_configs[] = { +HW_CONFIG_ENCODER_FRAMES(CUDA, CUDA), +HW_CONFIG_ENCODER_DEVICE(NONE, CUDA), +#if CONFIG_D3D11VA +HW_CONFIG_ENCODER_FRAMES(D3D11, D3D11VA), +HW_CONFIG_ENCODER_DEVICE(NONE, D3D11VA), +#endif +NULL, +}; + #define IS_10BIT(pix_fmt) (pix_fmt == AV_PIX_FMT_P010|| \ pix_fmt == AV_PIX_FMT_P016|| \ pix_fmt == AV_PIX_FMT_YUV444P16) diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index c44c81e675..6bdf4741fa 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -33,6 +33,7 @@ typedef void ID3D11Device; #include "compat/cuda/dynlink_loader.h" #include "libavutil/fifo.h" #include "libavutil/opt.h" +#include "hwconfig.h" #include "avcodec.h" @@ -217,5 +218,6 @@ int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, void ff_nvenc_encode_flush(AVCodecContext *avctx); extern const enum AVPixelFormat ff_nvenc_pix_fmts[]; +extern const AVCodecHWConfigInternal *ff_nvenc_hw_configs[]; #endif /* AVCODEC_NVENC_H */ diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index c39f90fe1b..bac45ac8ee 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -191,6 +191,7 @@ AVCodec ff_nvenc_encoder = { .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .pix_fmts = ff_nvenc_pix_fmts, .wrapper_name = "nvenc", +.hw_configs = ff_nvenc_hw_configs, }; #endif @@ -222,6 +223,7 @@ AVCodec ff_nvenc_h264_encoder = { .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .pix_fmts = ff_nvenc_pix_fmts, .wrapper_name = "nvenc", +.hw_configs = ff_nvenc_hw_configs, }; #endif @@ -253,4 +255,5 @@ AVCodec ff_h264_nvenc_encoder = { .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .pix_fmts = ff_nvenc_pix_fmts, .wrapper_name = "nvenc", +.hw_configs = ff_nvenc_hw_configs, }; diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index ea337a514f..89919b162c 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -178,6 +178,7 @@ AVCodec ff_nvenc_hevc_encoder = { AV_CODEC_CAP_ENCODER_FLUSH, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "nvenc", +.hw_configs = ff_nvenc_hw_configs, }; #endif @@ -208,4 +209,5 @@ AVCodec ff_hevc_nvenc_encoder = { AV_CODEC_CAP_ENCODER_FLUSH, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "nvenc", +.hw_configs = ff_nvenc_hw_configs, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] ffmpeg: Remove the hw_device_ctx global
ffmpeg | branch: master | Mark Thompson | Mon Apr 13 16:33:21 2020 +0100| [79c173cc1900c735b1e256f5755b3e434a080a4f] | committer: Mark Thompson ffmpeg: Remove the hw_device_ctx global The ad-hoc libmfx setup code is the only place its still used, so move it into that file. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79c173cc1900c735b1e256f5755b3e434a080a4f --- fftools/ffmpeg.c | 1 - fftools/ffmpeg.h | 1 - fftools/ffmpeg_opt.c | 11 ++- fftools/ffmpeg_qsv.c | 1 + 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 2287af59f0..cf64837b8a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4759,7 +4759,6 @@ static int transcode(void) } } -av_buffer_unref(_device_ctx); hw_device_free_all(); /* finished ! */ diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 43b5040f73..98700f24e5 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -615,7 +615,6 @@ extern const AVIOInterruptCB int_cb; extern const OptionDef options[]; extern const HWAccel hwaccels[]; -extern AVBufferRef *hw_device_ctx; #if CONFIG_QSV extern char *qsv_device; #endif diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 680f0f1dfb..16e321b5a3 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -139,7 +139,6 @@ const HWAccel hwaccels[] = { #endif { 0 }, }; -AVBufferRef *hw_device_ctx; HWDevice *filter_hw_device; char *vstats_filename; @@ -536,21 +535,15 @@ static int opt_sdp_file(void *optctx, const char *opt, const char *arg) #if CONFIG_VAAPI static int opt_vaapi_device(void *optctx, const char *opt, const char *arg) { -HWDevice *dev; const char *prefix = "vaapi:"; char *tmp; int err; tmp = av_asprintf("%s%s", prefix, arg); if (!tmp) return AVERROR(ENOMEM); -err = hw_device_init_from_string(tmp, ); +err = hw_device_init_from_string(tmp, NULL); av_free(tmp); -if (err < 0) -return err; -hw_device_ctx = av_buffer_ref(dev->device_ref); -if (!hw_device_ctx) -return AVERROR(ENOMEM); -return 0; +return err; } #endif diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c index 9c4285b6c7..960c88b69d 100644 --- a/fftools/ffmpeg_qsv.c +++ b/fftools/ffmpeg_qsv.c @@ -28,6 +28,7 @@ #include "ffmpeg.h" +static AVBufferRef *hw_device_ctx; char *qsv_device = NULL; static int qsv_get_buffer(AVCodecContext *s, AVFrame *frame, int flags) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] ffmpeg: Use hardware config metadata with encoders
ffmpeg | branch: master | Mark Thompson | Mon Apr 13 16:33:20 2020 +0100| [8abd3b202821e9c491f44d097686402aafdda7c5] | committer: Mark Thompson ffmpeg: Use hardware config metadata with encoders This can support encoders which want frames and/or device contexts. For the device case, it currently picks the first initialised device of the desired type to give to the encoder - a new option would be needed if it were necessary to choose between multiple devices of the same type. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8abd3b202821e9c491f44d097686402aafdda7c5 --- fftools/ffmpeg.c| 19 ++- fftools/ffmpeg_hw.c | 48 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index d896b14a14..2287af59f0 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3476,21 +3476,14 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) !av_dict_get(ost->encoder_opts, "ab", NULL, 0)) av_dict_set(>encoder_opts, "b", "128000", 0); -if (ost->filter && av_buffersink_get_hw_frames_ctx(ost->filter->filter) && - ((AVHWFramesContext*)av_buffersink_get_hw_frames_ctx(ost->filter->filter)->data)->format == -av_buffersink_get_format(ost->filter->filter)) { -ost->enc_ctx->hw_frames_ctx = av_buffer_ref(av_buffersink_get_hw_frames_ctx(ost->filter->filter)); -if (!ost->enc_ctx->hw_frames_ctx) -return AVERROR(ENOMEM); -} else { -ret = hw_device_setup_for_encode(ost); -if (ret < 0) { -snprintf(error, error_len, "Device setup failed for " - "encoder on output stream #%d:%d : %s", +ret = hw_device_setup_for_encode(ost); +if (ret < 0) { +snprintf(error, error_len, "Device setup failed for " + "encoder on output stream #%d:%d : %s", ost->file_index, ost->index, av_err2str(ret)); -return ret; -} +return ret; } + if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && ost->enc->type == AVMEDIA_TYPE_SUBTITLE) { int input_props = 0, output_props = 0; AVCodecDescriptor const *input_descriptor = diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index 40739fc320..c5c8aa97ef 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -19,6 +19,7 @@ #include #include "libavutil/avstring.h" +#include "libavfilter/buffersink.h" #include "ffmpeg.h" @@ -281,7 +282,10 @@ void hw_device_free_all(void) nb_hw_devices = 0; } -static HWDevice *hw_device_match_by_codec(const AVCodec *codec) +static HWDevice *hw_device_match_by_codec(const AVCodec *codec, + enum AVPixelFormat format, + int possible_methods, + int *matched_methods) { const AVCodecHWConfig *config; HWDevice *dev; @@ -290,11 +294,18 @@ static HWDevice *hw_device_match_by_codec(const AVCodec *codec) config = avcodec_get_hw_config(codec, i); if (!config) return NULL; -if (!(config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)) +if (format != AV_PIX_FMT_NONE && +config->pix_fmt != AV_PIX_FMT_NONE && +config->pix_fmt != format) +continue; +if (!(config->methods & possible_methods)) continue; dev = hw_device_get_by_type(config->device_type); -if (dev) +if (dev) { +if (matched_methods) +*matched_methods = config->methods & possible_methods; return dev; +} } } @@ -340,7 +351,9 @@ int hw_device_setup_for_decode(InputStream *ist) if (!dev) err = hw_device_init_from_type(type, NULL, ); } else { -dev = hw_device_match_by_codec(ist->dec); +dev = hw_device_match_by_codec(ist->dec, AV_PIX_FMT_NONE, + AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX, + NULL); if (!dev) { // No device for this codec, but not using generic hwaccel // and therefore may well not need one - ignore. @@ -417,12 +430,31 @@ int hw_device_setup_for_decode(InputStream *ist) int hw_device_setup_for_encode(OutputStream *ost) { HWDevice *dev; +AVBufferRef *frames_ref; +int methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX; +int mat
[FFmpeg-cvslog] lavc: Rename hwaccel.h to hwconfig.h
ffmpeg | branch: master | Mark Thompson | Mon Apr 13 16:33:14 2020 +0100| [2594f6a362c788a036dbf3e27d540d15fe7f72d0] | committer: Mark Thompson lavc: Rename hwaccel.h to hwconfig.h This already applied to decoders as well as hwaccels, and adding encoder support was going to make the name even more inaccurate. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2594f6a362c788a036dbf3e27d540d15fe7f72d0 --- libavcodec/cuviddec.c| 2 +- libavcodec/decode.c | 2 +- libavcodec/h263dec.c | 2 +- libavcodec/h264dec.c | 2 +- libavcodec/hevcdec.c | 2 +- libavcodec/{hwaccel.h => hwconfig.h} | 6 +++--- libavcodec/mediacodecdec.c | 2 +- libavcodec/mjpegdec.c| 2 +- libavcodec/mmaldec.c | 2 +- libavcodec/mpeg12dec.c | 2 +- libavcodec/mpeg4videodec.c | 2 +- libavcodec/pthread_frame.c | 2 +- libavcodec/qsvdec.h | 2 +- libavcodec/rkmppdec.c| 2 +- libavcodec/utils.c | 2 +- libavcodec/vaapi_h264.c | 2 +- libavcodec/vaapi_hevc.c | 2 +- libavcodec/vaapi_mjpeg.c | 2 +- libavcodec/vaapi_mpeg2.c | 2 +- libavcodec/vaapi_mpeg4.c | 2 +- libavcodec/vaapi_vc1.c | 2 +- libavcodec/vaapi_vp8.c | 2 +- libavcodec/vaapi_vp9.c | 2 +- libavcodec/vc1dec.c | 2 +- libavcodec/vdpau_h264.c | 2 +- libavcodec/vdpau_hevc.c | 2 +- libavcodec/vdpau_mpeg12.c| 2 +- libavcodec/vdpau_mpeg4.c | 2 +- libavcodec/vdpau_vc1.c | 2 +- libavcodec/vdpau_vp9.c | 2 +- libavcodec/vp8.c | 2 +- libavcodec/vp9.c | 2 +- 32 files changed, 34 insertions(+), 34 deletions(-) diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index 50dc8956c3..9477b8fd3a 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -33,7 +33,7 @@ #include "avcodec.h" #include "decode.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "nvdec.h" #include "internal.h" diff --git a/libavcodec/decode.c b/libavcodec/decode.c index d4bdb9b1c0..2094095eca 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -41,7 +41,7 @@ #include "avcodec.h" #include "bytestream.h" #include "decode.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "thread.h" diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 8ee844e298..31ac563f43 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -33,7 +33,7 @@ #include "flv.h" #include "h263.h" #include "h263_parser.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "mpeg_er.h" #include "mpeg4video.h" diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index e374f32e91..4c355feb18 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -46,7 +46,7 @@ #include "h264_mvpred.h" #include "h264_ps.h" #include "golomb.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "mathops.h" #include "me_cmp.h" #include "mpegutils.h" diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 36be83948e..78299f4b32 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -41,7 +41,7 @@ #include "hevc_data.h" #include "hevc_parse.h" #include "hevcdec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "profiles.h" const uint8_t ff_hevc_pel_weight[65] = { [2] = 0, [4] = 1, [6] = 2, [8] = 3, [12] = 4, [16] = 5, [24] = 6, [32] = 7, [48] = 8, [64] = 9 }; diff --git a/libavcodec/hwaccel.h b/libavcodec/hwconfig.h similarity index 97% rename from libavcodec/hwaccel.h rename to libavcodec/hwconfig.h index 3aaa92571c..4199ffdd50 100644 --- a/libavcodec/hwaccel.h +++ b/libavcodec/hwconfig.h @@ -16,8 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_HWACCEL_H -#define AVCODEC_HWACCEL_H +#ifndef AVCODEC_HWCONFIG_H +#define AVCODEC_HWCONFIG_H #include "avcodec.h" #include "hwaccels.h" @@ -81,4 +81,4 @@ typedef struct AVCodecHWConfigInternal { #define HWACCEL_XVMC(codec) \ HW_CONFIG_HWACCEL(0, 0, 1, XVMC, NONE, ff_ ## codec ## _xvmc_hwaccel) -#endif /* AVCODEC_HWACCEL_H */ +#endif /* AVCODEC_HWCONFIG_H */ diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index f5771bffb1..25410021e8 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -34,7 +34,7
[FFmpeg-cvslog] lavc/vaapi_encode: Add hardware config metadata
ffmpeg | branch: master | Mark Thompson | Mon Apr 13 16:33:17 2020 +0100| [344e6c3ff1b47279ffb360aba3f5e10183bc4eb4] | committer: Mark Thompson lavc/vaapi_encode: Add hardware config metadata These encoders all accept VAAPI surfaces in a hardware frames context. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=344e6c3ff1b47279ffb360aba3f5e10183bc4eb4 --- libavcodec/vaapi_encode.c | 5 + libavcodec/vaapi_encode.h | 3 +++ libavcodec/vaapi_encode_h264.c | 1 + libavcodec/vaapi_encode_h265.c | 1 + libavcodec/vaapi_encode_mjpeg.c | 1 + libavcodec/vaapi_encode_mpeg2.c | 1 + libavcodec/vaapi_encode_vp8.c | 1 + libavcodec/vaapi_encode_vp9.c | 1 + 8 files changed, 14 insertions(+) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 8ff720e395..f551967ad6 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -27,6 +27,11 @@ #include "vaapi_encode.h" #include "avcodec.h" +const AVCodecHWConfigInternal *ff_vaapi_encode_hw_configs[] = { +HW_CONFIG_ENCODER_FRAMES(VAAPI, VAAPI), +NULL, +}; + static const char * const picture_type_name[] = { "IDR", "I", "P", "B" }; static int vaapi_encode_make_packed_header(AVCodecContext *avctx, diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index b9a3defd72..1329f6428f 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -31,6 +31,7 @@ #include "libavutil/hwcontext_vaapi.h" #include "avcodec.h" +#include "hwconfig.h" struct VAAPIEncodeType; struct VAAPIEncodePicture; @@ -44,6 +45,8 @@ enum { MAX_PARAM_BUFFER_SIZE = 1024, }; +extern const AVCodecHWConfigInternal *ff_vaapi_encode_hw_configs[]; + enum { PICTURE_TYPE_IDR = 0, PICTURE_TYPE_I = 1, diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index f4965d8b09..67b1ecae1b 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -1361,5 +1361,6 @@ AVCodec ff_h264_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, +.hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 97dc5a7e75..e20e8cbdd0 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1297,5 +1297,6 @@ AVCodec ff_hevc_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, +.hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c index bd029cc903..2b5d3bf4f9 100644 --- a/libavcodec/vaapi_encode_mjpeg.c +++ b/libavcodec/vaapi_encode_mjpeg.c @@ -570,5 +570,6 @@ AVCodec ff_mjpeg_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, +.hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index bac9ea1fa6..0398c4cd8c 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -707,5 +707,6 @@ AVCodec ff_mpeg2_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, +.hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_vp8.c b/libavcodec/vaapi_encode_vp8.c index 6e7bf9d106..16cbcbd81c 100644 --- a/libavcodec/vaapi_encode_vp8.c +++ b/libavcodec/vaapi_encode_vp8.c @@ -262,5 +262,6 @@ AVCodec ff_vp8_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, +.hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index d7f415d704..d05319ef39 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -296,5 +296,6 @@ AVCodec ff_vp9_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, +.hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/qsvenc: Add hardware config metadata
ffmpeg | branch: master | Mark Thompson | Mon Apr 13 16:33:16 2020 +0100| [5a1ff449071fefa7913858fbe2d084f698443e57] | committer: Mark Thompson lavc/qsvenc: Add hardware config metadata All of these encoders can accept libmfx surfaces directly in a hardware frames context, or they can accept software frames if a suitable device is supplied to use. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5a1ff449071fefa7913858fbe2d084f698443e57 --- libavcodec/qsvenc.c | 7 +++ libavcodec/qsvenc.h | 3 +++ libavcodec/qsvenc_h264.c | 1 + libavcodec/qsvenc_hevc.c | 1 + libavcodec/qsvenc_jpeg.c | 1 + libavcodec/qsvenc_mpeg2.c | 1 + libavcodec/qsvenc_vp9.c | 1 + 7 files changed, 15 insertions(+) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index afab8fd715..9ec0636dde 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1652,3 +1652,10 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) return 0; } + +const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[] = { +HW_CONFIG_ENCODER_FRAMES(QSV, QSV), +HW_CONFIG_ENCODER_DEVICE(NV12, QSV), +HW_CONFIG_ENCODER_DEVICE(P010, QSV), +NULL, +}; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 6609171af3..4f579d1db1 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -32,6 +32,7 @@ #include "libavutil/fifo.h" #include "avcodec.h" +#include "hwconfig.h" #include "qsv_internal.h" #define QSV_HAVE_CO2 QSV_VERSION_ATLEAST(1, 6) @@ -97,6 +98,8 @@ { "forced_idr", "Forcing I frames as IDR frames", OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE }, \ { "low_power", "enable low power mode(experimental: many limitations by mfx version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, VE},\ +extern const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[]; + typedef int SetEncodeCtrlCB (AVCodecContext *avctx, const AVFrame *frame, mfxEncodeCtrl* enc_ctrl); typedef struct QSVEncContext { diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 27f36b9f7b..364975bea5 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -197,4 +197,5 @@ AVCodec ff_h264_qsv_encoder = { .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "qsv", +.hw_configs = ff_qsv_enc_hw_configs, }; diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 27e2232a9f..36e5ef6052 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -288,4 +288,5 @@ AVCodec ff_hevc_qsv_encoder = { .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "qsv", +.hw_configs = ff_qsv_enc_hw_configs, }; diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c index 1619a335c7..f76af9486b 100644 --- a/libavcodec/qsvenc_jpeg.c +++ b/libavcodec/qsvenc_jpeg.c @@ -95,4 +95,5 @@ AVCodec ff_mjpeg_qsv_encoder = { .priv_class = , .defaults = qsv_enc_defaults, .wrapper_name = "qsv", +.hw_configs = ff_qsv_enc_hw_configs, }; diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c index e4ade56d62..0e34bb75dc 100644 --- a/libavcodec/qsvenc_mpeg2.c +++ b/libavcodec/qsvenc_mpeg2.c @@ -112,4 +112,5 @@ AVCodec ff_mpeg2_qsv_encoder = { .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "qsv", +.hw_configs = ff_qsv_enc_hw_configs, }; diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c index 9402f806b1..ce44c09397 100644 --- a/libavcodec/qsvenc_vp9.c +++ b/libavcodec/qsvenc_vp9.c @@ -110,4 +110,5 @@ AVCodec ff_vp9_qsv_encoder = { .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "qsv", +.hw_configs = ff_qsv_enc_hw_configs, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] ffmpeg: Make filter hardware device selection clearer
ffmpeg | branch: master | Mark Thompson | Mon Apr 13 16:33:19 2020 +0100| [e2542124059f5960ac2bbd94183012814263f20d] | committer: Mark Thompson ffmpeg: Make filter hardware device selection clearer Also move it into a dedicated function in the hardware file. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e2542124059f5960ac2bbd94183012814263f20d --- fftools/ffmpeg.h| 1 + fftools/ffmpeg_filter.c | 14 +++--- fftools/ffmpeg_hw.c | 28 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fbaae15377..43b5040f73 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -661,6 +661,7 @@ void hw_device_free_all(void); int hw_device_setup_for_decode(InputStream *ist); int hw_device_setup_for_encode(OutputStream *ost); +int hw_device_setup_for_filter(FilterGraph *fg); int hwaccel_decode_init(AVCodecContext *avctx); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index b66faa50b5..8b5b157be7 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1061,17 +1061,9 @@ int configure_filtergraph(FilterGraph *fg) if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, , )) < 0) goto fail; -if (filter_hw_device || hw_device_ctx) { -AVBufferRef *device = filter_hw_device ? filter_hw_device->device_ref - : hw_device_ctx; -for (i = 0; i < fg->graph->nb_filters; i++) { -fg->graph->filters[i]->hw_device_ctx = av_buffer_ref(device); -if (!fg->graph->filters[i]->hw_device_ctx) { -ret = AVERROR(ENOMEM); -goto fail; -} -} -} +ret = hw_device_setup_for_filter(fg); +if (ret < 0) +goto fail; if (simple && (!inputs || inputs->next || !outputs || outputs->next)) { const char *num_inputs; diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index 962d8f7d5a..40739fc320 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -480,3 +480,31 @@ int hwaccel_decode_init(AVCodecContext *avctx) return 0; } + +int hw_device_setup_for_filter(FilterGraph *fg) +{ +HWDevice *dev; +int i; + +// If the user has supplied exactly one hardware device then just +// give it straight to every filter for convenience. If more than +// one device is available then the user needs to pick one explcitly +// with the filter_hw_device option. +if (filter_hw_device) +dev = filter_hw_device; +else if (nb_hw_devices == 1) +dev = hw_devices[0]; +else +dev = NULL; + +if (dev) { +for (i = 0; i < fg->graph->nb_filters; i++) { +fg->graph->filters[i]->hw_device_ctx = +av_buffer_ref(dev->device_ref); +if (!fg->graph->filters[i]->hw_device_ctx) +return AVERROR(ENOMEM); +} +} + +return 0; +} ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] hwcontext_vaapi: Only accept a render node when deriving from DRM device
ffmpeg | branch: master | Mark Thompson | Sun Feb 16 20:59:54 2020 +| [bc9b6358fb7315c0173de322472641766f6289da] | committer: Mark Thompson hwcontext_vaapi: Only accept a render node when deriving from DRM device If we are given a non-render node, try to find the matching render node and fail if that isn't possible. libva will not accept a non-render device which is not DRM master, because it requires legacy DRM authentication to succeed in that case: <https://github.com/intel/libva/blob/master/va/drm/va_drm.c#L68-L75>. This is annoying for kmsgrab because in most recording situations DRM master is already held by something else (such as a windowing system), leading to device derivation not working and forcing the user to create the target VAAPI device separately. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bc9b6358fb7315c0173de322472641766f6289da --- libavutil/hwcontext_vaapi.c | 46 ++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index cfcfc46867..b306965b4a 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1631,6 +1631,7 @@ static int vaapi_device_derive(AVHWDeviceContext *ctx, AVDRMDeviceContext *src_hwctx = src_ctx->hwctx; VADisplay *display; VAAPIDevicePriv *priv; +int fd; if (src_hwctx->fd < 0) { av_log(ctx, AV_LOG_ERROR, "DRM instance requires an associated " @@ -1638,17 +1639,56 @@ static int vaapi_device_derive(AVHWDeviceContext *ctx, return AVERROR(EINVAL); } +#if CONFIG_LIBDRM +{ +int node_type = drmGetNodeTypeFromFd(src_hwctx->fd); +char *render_node; +if (node_type < 0) { +av_log(ctx, AV_LOG_ERROR, "DRM instance fd does not appear " + "to refer to a DRM device.\n"); +return AVERROR(EINVAL); +} +if (node_type == DRM_NODE_RENDER) { +fd = src_hwctx->fd; +} else { +render_node = drmGetRenderDeviceNameFromFd(src_hwctx->fd); +if (!render_node) { +av_log(ctx, AV_LOG_ERROR, "Failed to find a render node " + "matching the DRM device.\n"); +return AVERROR(ENODEV); +} +fd = open(render_node, O_RDWR); +if (fd < 0) { +av_log(ctx, AV_LOG_ERROR, "Failed to open render node %s" + "matching the DRM device.\n", render_node); +free(render_node); +return AVERROR(errno); +} +av_log(ctx, AV_LOG_VERBOSE, "Using render node %s in place " + "of non-render DRM device.\n", render_node); +free(render_node); +} +} +#else +fd = src_hwctx->fd; +#endif + priv = av_mallocz(sizeof(*priv)); if (!priv) return AVERROR(ENOMEM); -// Inherits the fd from the source context, which will close it. -priv->drm_fd = -1; +if (fd == src_hwctx->fd) { +// The fd is inherited from the source context and we are holding +// a reference to that, we don't want to close it from here. +priv->drm_fd = -1; +} else { +priv->drm_fd = fd; +} ctx->user_opaque = priv; ctx->free= _device_free; -display = vaGetDisplayDRM(src_hwctx->fd); +display = vaGetDisplayDRM(fd); if (!display) { av_log(ctx, AV_LOG_ERROR, "Failed to open a VA display from " "DRM device.\n"); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/cbs_h2645: Add missing newlines in log messages
ffmpeg | branch: master | Mark Thompson | Sun Sep 29 17:45:58 2019 +0100| [bf0ab6e9c460faf14eac4373fc65cae8ed1c8c71] | committer: Mark Thompson lavc/cbs_h2645: Add missing newlines in log messages > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bf0ab6e9c460faf14eac4373fc65cae8ed1c8c71 --- libavcodec/cbs_h2645.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 5f1a20d427..c8347ba5fa 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -616,7 +616,7 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx, version = bytestream2_get_byte(); if (version != 1) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid AVCC header: " - "first byte %u.", version); + "first byte %u.\n", version); return AVERROR_INVALIDDATA; } @@ -691,7 +691,7 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx, version = bytestream2_get_byte(); if (version != 1) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid HVCC header: " - "first byte %u.", version); + "first byte %u.\n", version); return AVERROR_INVALIDDATA; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/vp9_raw_reorder_bsf: Fix operator ordering
ffmpeg | branch: master | Mark Thompson | Sun Sep 29 17:46:01 2019 +0100| [e1b5620b62ef0e3d04a6c4f3d837328076ed2a9b] | committer: Mark Thompson lavc/vp9_raw_reorder_bsf: Fix operator ordering Fixes CID 1413024. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e1b5620b62ef0e3d04a6c4f3d837328076ed2a9b --- libavcodec/vp9_raw_reorder_bsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vp9_raw_reorder_bsf.c b/libavcodec/vp9_raw_reorder_bsf.c index f19b4c7198..e55a358457 100644 --- a/libavcodec/vp9_raw_reorder_bsf.c +++ b/libavcodec/vp9_raw_reorder_bsf.c @@ -292,7 +292,7 @@ static int vp9_raw_reorder_filter(AVBSFContext *bsf, AVPacket *out) return err; } -if (in->data[in->size - 1] & 0xe0 == 0xc0) { +if ((in->data[in->size - 1] & 0xe0) == 0xc0) { av_log(bsf, AV_LOG_ERROR, "Input in superframes is not " "supported.\n"); av_packet_free(); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavfi/vf_deshake_opencl: Avoid propagating uninitialised data
ffmpeg | branch: master | Mark Thompson | Sun Sep 29 17:46:03 2019 +0100| [f130b221196cf82e19be78aa810125a41eb340fc] | committer: Mark Thompson lavfi/vf_deshake_opencl: Avoid propagating uninitialised data Fixes CID 1452753. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f130b221196cf82e19be78aa810125a41eb340fc --- libavfilter/vf_deshake_opencl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavfilter/vf_deshake_opencl.c b/libavfilter/vf_deshake_opencl.c index c914a77d83..0ef015808f 100644 --- a/libavfilter/vf_deshake_opencl.c +++ b/libavfilter/vf_deshake_opencl.c @@ -757,6 +757,8 @@ static FrameDelta decompose_transform(double *model) double f = model[5]; double delta = a * d - b * c; +memset(, 0, sizeof(ret)); + ret.translation.s[0] = e; ret.translation.s[1] = f; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] doc/ffmpeg: Document device selection for Vulkan
ffmpeg | branch: master | Mark Thompson | Sun Feb 9 19:15:53 2020 +| [48b102c5a60642687574413bf149273e43224b57] | committer: Mark Thompson doc/ffmpeg: Document device selection for Vulkan > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=48b102c5a60642687574413bf149273e43224b57 --- doc/ffmpeg.texi | 14 ++ 1 file changed, 14 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index dd461c02fc..29753f06ca 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1029,6 +1029,20 @@ Choose the GPU device on the second platform supporting the @emph{cl_khr_fp16} extension. @end table +@item vulkan +If @var{device} is an integer, it selects the device by its index in a +system-dependent list of devices. If @var{device} is any other string, it +selects the first device with a name containing that string as a substring. + +Examples: +@table @emph +@item -init_hw_device vulkan:1 +Choose the second device on the system. + +@item -init_hw_device vulkan:RADV +Choose the first device with a name containing the string @emph{RADV}. +@end table + @end table @item -init_hw_device @var{type}[=@var{name}]@@@var{source} ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/vaapi_encode: Fix leak in error case
ffmpeg | branch: master | Mark Thompson | Sun Sep 29 17:46:00 2019 +0100| [177a90b1a3fcbadbcd3e32bfab5fa3cf01e9b8b8] | committer: Mark Thompson lavc/vaapi_encode: Fix leak in error case Fixes CID 1442564. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=177a90b1a3fcbadbcd3e32bfab5fa3cf01e9b8b8 --- libavcodec/vaapi_encode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index b0235114df..8ff720e395 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1101,6 +1101,7 @@ int ff_vaapi_encode_send_frame(AVCodecContext *avctx, const AVFrame *frame) return 0; fail: +vaapi_encode_free(avctx, pic); return err; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/h265_metadata_bsf: Fix parameter ordering
ffmpeg | branch: master | Mark Thompson | Sun Sep 29 17:45:59 2019 +0100| [5392982241ededd6f6b041ff9ab288d0605564ea] | committer: Mark Thompson lavc/h265_metadata_bsf: Fix parameter ordering Fixes CID 1452433. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5392982241ededd6f6b041ff9ab288d0605564ea --- libavcodec/h265_metadata_bsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c index b3a1fda144..730f7ac28f 100644 --- a/libavcodec/h265_metadata_bsf.c +++ b/libavcodec/h265_metadata_bsf.c @@ -131,7 +131,7 @@ static void h265_metadata_guess_level(AVBSFContext *bsf, } desc = ff_h265_guess_level(ptl, bit_rate, width, height, - 0, tile_cols, tile_rows, + 0, tile_rows, tile_cols, max_dec_pic_buffering); if (desc) { av_log(bsf, AV_LOG_DEBUG, "Stream appears to conform to " ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavfi/vf_*_vaapi: Fix error case
ffmpeg | branch: master | Mark Thompson | Sun Sep 29 17:46:04 2019 +0100| [593106ff475e77a6d630a4fec1bc974fa145b9fd] | committer: Mark Thompson lavfi/vf_*_vaapi: Fix error case Fixes CID 1452400, 1452416, 1452550, 1452590, 1452760. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=593106ff475e77a6d630a4fec1bc974fa145b9fd --- libavfilter/vf_deinterlace_vaapi.c | 2 +- libavfilter/vf_misc_vaapi.c| 2 +- libavfilter/vf_procamp_vaapi.c | 2 +- libavfilter/vf_scale_vaapi.c | 2 +- libavfilter/vf_transpose_vaapi.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_deinterlace_vaapi.c b/libavfilter/vf_deinterlace_vaapi.c index 72d034981a..71809eb01a 100644 --- a/libavfilter/vf_deinterlace_vaapi.c +++ b/libavfilter/vf_deinterlace_vaapi.c @@ -239,7 +239,7 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) err = av_frame_copy_props(output_frame, input_frame); if (err < 0) -return err; +goto fail; err = ff_vaapi_vpp_init_params(avctx, , input_frame, output_frame); diff --git a/libavfilter/vf_misc_vaapi.c b/libavfilter/vf_misc_vaapi.c index 54516d7e35..5814ff8c2e 100644 --- a/libavfilter/vf_misc_vaapi.c +++ b/libavfilter/vf_misc_vaapi.c @@ -145,7 +145,7 @@ static int misc_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) err = av_frame_copy_props(output_frame, input_frame); if (err < 0) -return err; +goto fail; err = ff_vaapi_vpp_init_params(avctx, , input_frame, output_frame); diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c index c3e9866f22..7342048583 100644 --- a/libavfilter/vf_procamp_vaapi.c +++ b/libavfilter/vf_procamp_vaapi.c @@ -150,7 +150,7 @@ static int procamp_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame err = av_frame_copy_props(output_frame, input_frame); if (err < 0) -return err; +goto fail; err = ff_vaapi_vpp_init_params(avctx, , input_frame, output_frame); diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c index 8298a013da..b9a5eeff65 100644 --- a/libavfilter/vf_scale_vaapi.c +++ b/libavfilter/vf_scale_vaapi.c @@ -125,7 +125,7 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) err = av_frame_copy_props(output_frame, input_frame); if (err < 0) -return err; +goto fail; if (ctx->colour_primaries != AVCOL_PRI_UNSPECIFIED) output_frame->color_primaries = ctx->colour_primaries; diff --git a/libavfilter/vf_transpose_vaapi.c b/libavfilter/vf_transpose_vaapi.c index 69dbdd7017..a4c654266d 100644 --- a/libavfilter/vf_transpose_vaapi.c +++ b/libavfilter/vf_transpose_vaapi.c @@ -145,7 +145,7 @@ static int transpose_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_fra err = av_frame_copy_props(output_frame, input_frame); if (err < 0) -return err; +goto fail; err = ff_vaapi_vpp_init_params(avctx, , input_frame, output_frame); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vf_tonemap_vaapi: Fix memory leak in error case
ffmpeg | branch: master | Mark Thompson | Mon Jan 6 23:56:10 2020 +| [f907eea8632b62f61aa9a2b28464f7d657dac45b] | committer: Mark Thompson vf_tonemap_vaapi: Fix memory leak in error case Fixes CID 1457236. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f907eea8632b62f61aa9a2b28464f7d657dac45b --- libavfilter/vf_tonemap_vaapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_tonemap_vaapi.c b/libavfilter/vf_tonemap_vaapi.c index cc81334d77..2f41b90424 100644 --- a/libavfilter/vf_tonemap_vaapi.c +++ b/libavfilter/vf_tonemap_vaapi.c @@ -278,7 +278,7 @@ static int tonemap_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame err = av_frame_copy_props(output_frame, input_frame); if (err < 0) -return err; +goto fail; if (ctx->color_primaries != AVCOL_PRI_UNSPECIFIED) output_frame->color_primaries = ctx->color_primaries; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h264: Fix missing inferred colour description fields
ffmpeg | branch: release/4.1 | Mark Thompson | Sun Jul 28 19:23:15 2019 +0100| [07afe2e3ca2e33a52acd142ba0595e495589de96] | committer: James Almer cbs_h264: Fix missing inferred colour description fields With video_signal_type_present_flag set but colour_description_present_flag unset the colour fields would not have had their correct values inferred. (cherry picked from commit f9b8503639c0ff90846f07c92e2fe7836690dd0c) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=07afe2e3ca2e33a52acd142ba0595e495589de96 --- libavcodec/cbs_h264_syntax_template.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 07b4cddb5e..57fc02082c 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -137,6 +137,10 @@ static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw, u(8, colour_primaries, 0, 255); u(8, transfer_characteristics, 0, 255); u(8, matrix_coefficients, 0, 255); +} else { +infer(colour_primaries, 2); +infer(transfer_characteristics, 2); +infer(matrix_coefficients, 2); } } else { infer(video_format, 5); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h264: Fix missing inferred colour description fields
ffmpeg | branch: release/4.2 | Mark Thompson | Sun Jul 28 19:23:15 2019 +0100| [82a3a623f0129b6ee16d3b553051b5e4a6a2b95a] | committer: James Almer cbs_h264: Fix missing inferred colour description fields With video_signal_type_present_flag set but colour_description_present_flag unset the colour fields would not have had their correct values inferred. (cherry picked from commit f9b8503639c0ff90846f07c92e2fe7836690dd0c) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=82a3a623f0129b6ee16d3b553051b5e4a6a2b95a --- libavcodec/cbs_h264_syntax_template.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 26be6e590f..1671a15d33 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -137,6 +137,10 @@ static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw, ub(8, colour_primaries); ub(8, transfer_characteristics); ub(8, matrix_coefficients); +} else { +infer(colour_primaries, 2); +infer(transfer_characteristics, 2); +infer(matrix_coefficients, 2); } } else { infer(video_format, 5); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] h264_metadata: Support overscan_appropriate_flag
ffmpeg | branch: master | Mark Thompson | Sun Jul 28 19:23:16 2019 +0100| [b123d0780ec26456b08cd50e1062d464262ceb38] | committer: Mark Thompson h264_metadata: Support overscan_appropriate_flag Fixes #8041. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b123d0780ec26456b08cd50e1062d464262ceb38 --- doc/bitstream_filters.texi | 4 libavcodec/h264_metadata_bsf.c | 11 +++ 2 files changed, 15 insertions(+) diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index 023945e9be..50a1679fc7 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -224,6 +224,10 @@ Insert or remove AUD NAL units in all access units of the stream. @item sample_aspect_ratio Set the sample aspect ratio of the stream in the VUI parameters. +@item overscan_appropriate_flag +Set whether the stream is suitable for display using overscan +or not (see H.264 section E.2.1). + @item video_format @item video_full_range_flag Set the video format in the stream (see H.264 section E.2.1 and diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 3684e6bf7f..5de74be9d6 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -57,6 +57,8 @@ typedef struct H264MetadataContext { AVRational sample_aspect_ratio; +int overscan_appropriate_flag; + int video_format; int video_full_range_flag; int colour_primaries; @@ -129,6 +131,11 @@ static int h264_metadata_update_sps(AVBSFContext *bsf, } \ } while (0) +if (ctx->overscan_appropriate_flag >= 0) { +SET_VUI_FIELD(overscan_appropriate_flag); +sps->vui.overscan_info_present_flag = 1; +} + if (ctx->video_format >= 0 || ctx->video_full_range_flag>= 0 || ctx->colour_primaries >= 0 || @@ -630,6 +637,10 @@ static const AVOption h264_metadata_options[] = { OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, { .dbl = 0.0 }, 0, 65535, FLAGS }, +{ "overscan_appropriate_flag", "Set VUI overscan appropriate flag", +OFFSET(overscan_appropriate_flag), AV_OPT_TYPE_INT, +{ .i64 = -1 }, -1, 1, FLAGS }, + { "video_format", "Set video format (table E-2)", OFFSET(video_format), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 7, FLAGS}, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h264: Fix missing inferred colour description fields
ffmpeg | branch: master | Mark Thompson | Sun Jul 28 19:23:15 2019 +0100| [f9b8503639c0ff90846f07c92e2fe7836690dd0c] | committer: Mark Thompson cbs_h264: Fix missing inferred colour description fields With video_signal_type_present_flag set but colour_description_present_flag unset the colour fields would not have had their correct values inferred. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f9b8503639c0ff90846f07c92e2fe7836690dd0c --- libavcodec/cbs_h264_syntax_template.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 26be6e590f..1671a15d33 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -137,6 +137,10 @@ static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw, ub(8, colour_primaries); ub(8, transfer_characteristics); ub(8, matrix_coefficients); +} else { +infer(colour_primaries, 2); +infer(transfer_characteristics, 2); +infer(matrix_coefficients, 2); } } else { infer(video_format, 5); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode: Add ROI support
ffmpeg | branch: master | Mark Thompson | Sun Jul 7 20:26:49 2019 +0100| [33871478605812a94502e33a6d1b965f71e6818a] | committer: Mark Thompson vaapi_encode: Add ROI support > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=33871478605812a94502e33a6d1b965f71e6818a --- libavcodec/vaapi_encode.c | 116 libavcodec/vaapi_encode.h | 18 +++ libavcodec/vaapi_encode_h264.c | 2 + libavcodec/vaapi_encode_h265.c | 2 + libavcodec/vaapi_encode_mpeg2.c | 2 + libavcodec/vaapi_encode_vp8.c | 2 + libavcodec/vaapi_encode_vp9.c | 2 + 7 files changed, 144 insertions(+) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index dd2a24de04..e69b59fa37 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -166,6 +166,7 @@ static int vaapi_encode_issue(AVCodecContext *avctx, int err, i; char data[MAX_PARAM_BUFFER_SIZE]; size_t bit_len; +av_unused AVFrameSideData *sd; av_log(avctx, AV_LOG_DEBUG, "Issuing encode for pic %"PRId64"/%"PRId64" " "as type %s.\n", pic->display_order, pic->encode_order, @@ -435,6 +436,71 @@ static int vaapi_encode_issue(AVCodecContext *avctx, } } +#if VA_CHECK_VERSION(1, 0, 0) +sd = av_frame_get_side_data(pic->input_image, +AV_FRAME_DATA_REGIONS_OF_INTEREST); +if (sd && ctx->roi_allowed) { +const AVRegionOfInterest *roi; +uint32_t roi_size; +VAEncMiscParameterBufferROI param_roi; +int nb_roi, i, v; + +roi = (const AVRegionOfInterest*)sd->data; +roi_size = roi->self_size; +av_assert0(roi_size && sd->size % roi_size == 0); +nb_roi = sd->size / roi_size; +if (nb_roi > ctx->roi_max_regions) { +if (!ctx->roi_warned) { +av_log(avctx, AV_LOG_WARNING, "More ROIs set than " + "supported by driver (%d > %d).\n", + nb_roi, ctx->roi_max_regions); +ctx->roi_warned = 1; +} +nb_roi = ctx->roi_max_regions; +} + +pic->roi = av_mallocz_array(nb_roi, sizeof(*pic->roi)); +if (!pic->roi) { +err = AVERROR(ENOMEM); +goto fail; +} +// For overlapping regions, the first in the array takes priority. +for (i = 0; i < nb_roi; i++) { +roi = (const AVRegionOfInterest*)(sd->data + roi_size * i); + +av_assert0(roi->qoffset.den != 0); +v = roi->qoffset.num * ctx->roi_quant_range / roi->qoffset.den; +av_log(avctx, AV_LOG_DEBUG, "ROI: (%d,%d)-(%d,%d) -> %+d.\n", + roi->top, roi->left, roi->bottom, roi->right, v); + +pic->roi[i] = (VAEncROI) { +.roi_rectangle = { +.x = roi->left, +.y = roi->top, +.width = roi->right - roi->left, +.height = roi->bottom - roi->top, +}, +.roi_value = av_clip_c(v, INT8_MIN, INT8_MAX), +}; +} + +param_roi = (VAEncMiscParameterBufferROI) { +.num_roi = nb_roi, +.max_delta_qp = INT8_MAX, +.min_delta_qp = INT8_MIN, +.roi = pic->roi, +.roi_flags.bits.roi_value_is_qp_delta = 1, +}; + +err = vaapi_encode_make_misc_param_buffer(avctx, pic, + VAEncMiscParameterTypeROI, + _roi, + sizeof(param_roi)); +if (err < 0) +goto fail; +} +#endif + vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context, pic->input_surface); if (vas != VA_STATUS_SUCCESS) { @@ -500,6 +566,7 @@ fail_at_end: av_freep(>codec_picture_params); av_freep(>param_buffers); av_freep(>slices); +av_freep(>roi); av_frame_free(>recon_image); av_buffer_unref(>output_buffer_ref); pic->output_buffer = VA_INVALID_ID; @@ -634,6 +701,7 @@ static int vaapi_encode_free(AVCodecContext *avctx, av_freep(>priv_data); av_freep(>codec_picture_params); +av_freep(>roi); av_free(pic); @@ -948,6 +1016,17 @@ static int vaapi_encode_check_frame(AVCodecContext *avctx, ctx->crop_warned = 1; } +if (!ctx->roi_allowed) { +AVFrameSideData *sd = +av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST); + +if (sd && !ctx->roi_warned) { +av_log(avctx, AV_LOG_WARNING, "ROI side data on input
[FFmpeg-cvslog] lavfi: addroi filter
ffmpeg | branch: master | Mark Thompson | Sun Jul 7 20:26:50 2019 +0100| [20fed2f0ab197d60801280dfc844f6b29a397ff2] | committer: Mark Thompson lavfi: addroi filter This can be used to add region of interest side data to video frames. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=20fed2f0ab197d60801280dfc844f6b29a397ff2 --- doc/filters.texi | 73 + libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_addroi.c | 269 +++ 4 files changed, 344 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index c4ba907981..e081cdc7bc 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -5931,6 +5931,79 @@ build. Below is a description of the currently available video filters. +@section addroi + +Mark a region of interest in a video frame. + +The frame data is passed through unchanged, but metadata is attached +to the frame indicating regions of interest which can affect the +behaviour of later encoding. Multiple regions can be marked by +applying the filter multiple times. + +@table @option +@item x +Region distance in pixels from the left edge of the frame. +@item y +Region distance in pixels from the top edge of the frame. +@item w +Region width in pixels. +@item h +Region height in pixels. + +The parameters @var{x}, @var{y}, @var{w} and @var{h} are expressions, +and may contain the following variables: +@table @option +@item iw +Width of the input frame. +@item ih +Height of the input frame. +@end table + +@item qoffset +Quantisation offset to apply within the region. + +This must be a real value in the range -1 to +1. A value of zero +indicates no quality change. A negative value asks for better quality +(less quantisation), while a positive value asks for worse quality +(greater quantisation). + +The range is calibrated so that the extreme values indicate the +largest possible offset - if the rest of the frame is encoded with the +worst possible quality, an offset of -1 indicates that this region +should be encoded with the best possible quality anyway. Intermediate +values are then interpolated in some codec-dependent way. + +For example, in 10-bit H.264 the quantisation parameter varies between +-12 and 51. A typical qoffset value of -1/10 therefore indicates that +this region should be encoded with a QP around one-tenth of the full +range better than the rest of the frame. So, if most of the frame +were to be encoded with a QP of around 30, this region would get a QP +of around 24 (an offset of approximately -1/10 * (51 - -12) = -6.3). +An extreme value of -1 would indicate that this region should be +encoded with the best possible quality regardless of the treatment of +the rest of the frame - that is, should be encoded at a QP of -12. +@item clear +If set to true, remove any existing regions of interest marked on the +frame before adding the new one. +@end table + +@subsection Examples + +@itemize +@item +Mark the centre quarter of the frame as interesting. +@example +addroi=iw/4:ih/4:iw/2:ih/2:-1/10 +@end example +@item +Mark the 100-pixel-wide region on the left edge of the frame as very +uninteresting (to be encoded at much lower quality than the rest of +the frame). +@example +addroi=0:0:100:ih:+1/5 +@end example +@end itemize + @section alphaextract Extract the alpha component from the input as a grayscale video. This diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 450d7810ef..efc7bbb153 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -151,6 +151,7 @@ OBJS-$(CONFIG_SINE_FILTER) += asrc_sine.o OBJS-$(CONFIG_ANULLSINK_FILTER) += asink_anullsink.o # video filters +OBJS-$(CONFIG_ADDROI_FILTER) += vf_addroi.o OBJS-$(CONFIG_ALPHAEXTRACT_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_ALPHAMERGE_FILTER) += vf_alphamerge.o OBJS-$(CONFIG_AMPLIFY_FILTER)+= vf_amplify.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 04a3df7d56..abd726d616 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -143,6 +143,7 @@ extern AVFilter ff_asrc_sine; extern AVFilter ff_asink_anullsink; +extern AVFilter ff_vf_addroi; extern AVFilter ff_vf_alphaextract; extern AVFilter ff_vf_alphamerge; extern AVFilter ff_vf_amplify; diff --git a/libavfilter/vf_addroi.c b/libavfilter/vf_addroi.c new file mode 100644 index 00..489998ce73 --- /dev/null +++ b/libavfilter/vf_addroi.c @@ -0,0 +1,269 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warra