[FFmpeg-devel] Optimize HEVC decoding for loongarch
ffmpeg -i 5_h265_1080p_60fps_3Mbps.mkv -f rawvideo -y /dev/null -an before: 94fps after : 191fps [PATCH v1 1/5] avutil: [loongarch] Update loongson_intrinsics.h to [PATCH v1 2/5] avcodec: [loongarch] Optimize Hevcdsp with LSX. [PATCH v1 3/5] avcodec: [loongarch] Optimize Hevc_idct/lpf with LSX. [PATCH v1 4/5] avcodec: [loongarch] Optimize Hevc_mc_bi with LSX. [PATCH v1 5/5] avcodec: [loongarch] Optimize Hevc_mc_uni/w with LSX. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v1 1/5] avutil: [loongarch] Update loongson_intrinsics.h to v1.1.0
The loongson_intrinsics.h file is updated from v1.0.3 version to v1.1.0. Some spelling mistakes are fixed and new functions are added. Signed-off-by: Hao Chen --- libavutil/loongarch/loongson_intrinsics.h | 1697 +++-- 1 file changed, 884 insertions(+), 813 deletions(-) diff --git a/libavutil/loongarch/loongson_intrinsics.h b/libavutil/loongarch/loongson_intrinsics.h index 6e0439f829..eb256863c8 100644 --- a/libavutil/loongarch/loongson_intrinsics.h +++ b/libavutil/loongarch/loongson_intrinsics.h @@ -33,7 +33,7 @@ *Xiwei Gu *Lu Wang * - * This file is a header file for loongarch builtin extention. + * This file is a header file for loongarch builtin extension. * */ @@ -42,50 +42,50 @@ /** * MAJOR version: Macro usage changes. - * MINOR version: Add new functions, or bug fix. + * MINOR version: Add new functions, or bug fixes. * MICRO version: Comment changes or implementation changes. */ #define LSOM_VERSION_MAJOR 1 -#define LSOM_VERSION_MINOR 0 -#define LSOM_VERSION_MICRO 3 +#define LSOM_VERSION_MINOR 1 +#define LSOM_VERSION_MICRO 0 #define DUP2_ARG1(_INS, _IN0, _IN1, _OUT0, _OUT1) \ -{ \ -_OUT0 = _INS(_IN0); \ -_OUT1 = _INS(_IN1); \ -} + { \ +_OUT0 = _INS(_IN0); \ +_OUT1 = _INS(_IN1); \ + } #define DUP2_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _OUT0, _OUT1) \ -{ \ -_OUT0 = _INS(_IN0, _IN1); \ -_OUT1 = _INS(_IN2, _IN3); \ -} + { \ +_OUT0 = _INS(_IN0, _IN1); \ +_OUT1 = _INS(_IN2, _IN3); \ + } #define DUP2_ARG3(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _OUT0, _OUT1) \ -{ \ -_OUT0 = _INS(_IN0, _IN1, _IN2); \ -_OUT1 = _INS(_IN3, _IN4, _IN5); \ -} + { \ +_OUT0 = _INS(_IN0, _IN1, _IN2); \ +_OUT1 = _INS(_IN3, _IN4, _IN5); \ + } #define DUP4_ARG1(_INS, _IN0, _IN1, _IN2, _IN3, _OUT0, _OUT1, _OUT2, _OUT3) \ -{ \ -DUP2_ARG1(_INS, _IN0, _IN1, _OUT0, _OUT1); \ -DUP2_ARG1(_INS, _IN2, _IN3, _OUT2, _OUT3); \ -} - -#define DUP4_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _IN6, _IN7, \ - _OUT0, _OUT1, _OUT2, _OUT3) \ -{ \ -DUP2_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _OUT0, _OUT1); \ -DUP2_ARG2(_INS, _IN4, _IN5, _IN6, _IN7, _OUT2, _OUT3); \ -} - -#define DUP4_ARG3(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _IN6, _IN7, \ - _IN8, _IN9, _IN10, _IN11, _OUT0, _OUT1, _OUT2, _OUT3) \ -{ \ -DUP2_ARG3(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _OUT0, _OUT1); \ -DUP2_ARG3(_INS, _IN6, _IN7, _IN8, _IN9, _IN10, _IN11, _OUT2, _OUT3); \ -} + { \ +DUP2_ARG1(_INS, _IN0, _IN1, _OUT0, _OUT1); \ +DUP2_ARG1(_INS, _IN2, _IN3, _OUT2, _OUT3); \ + } + +#define DUP4_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _IN6, _IN7, _OUT0, \ + _OUT1, _OUT2, _OUT3) \ + { \ +DUP2_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _OUT0, _OUT1); \ +DUP2_ARG2(_INS, _IN4, _IN5, _IN6, _IN7, _OUT2, _OUT3); \ + } + +#define DUP4_ARG3(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _IN6, _IN7, _IN8, \ + _IN9, _IN10, _IN11, _OUT0, _OUT1, _OUT2, _OUT3) \ + { \ +DUP2_ARG3(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _OUT0, _OUT1);\ +DUP2_ARG3(_INS, _IN6, _IN7, _IN8, _IN9, _IN10, _IN11, _OUT2, _OUT3); \ + } #ifdef __loongarch_sx #include @@ -94,11 +94,11 @@ * Description : Dot product & addition of byte vector elements * Arguments : Inputs - in_c, in_h, in_l * Outputs - out - * Retrun Type - halfword + * Return Type - halfword * Details : Signed byte elements from in_h are multiplied by * signed byte elements from in_l, and then added adjacent to * each other to get results with the twice size of input. - * Then the results plus to signed half word elements from in_c. + * Then the results plus to signed half-word elements from in_c. * Example : out = __lsx_vdp2add_h_b(in_c, in_h, in_l) *in_c : 1,2,3,4, 1,2,3,4 *in_h : 1,2,3,4, 5,6,7,8, 1,2,3,4, 5,6,7,8 @@ -106,13 +106,13 @@ * out : 23,40,41,26, 23,40,41,26 * = */ -static inline __m128i __lsx_vdp2add_h_b(__m128i i
[FFmpeg-devel] [PATCH v1 4/5] avcodec: [loongarch] Optimize Hevc_mc_bi with LSX.
ffmpeg -i 5_h265_1080p_60fps_3Mbps.mkv -f rawvideo -y /dev/null -an before: 124fps after : 182fps --- libavcodec/loongarch/Makefile |3 +- libavcodec/loongarch/hevc_mc_bi_lsx.c | 2289 + libavcodec/loongarch/hevcdsp_init_loongarch.c | 51 + libavcodec/loongarch/hevcdsp_lsx.h| 57 + 4 files changed, 2399 insertions(+), 1 deletion(-) create mode 100644 libavcodec/loongarch/hevc_mc_bi_lsx.c diff --git a/libavcodec/loongarch/Makefile b/libavcodec/loongarch/Makefile index cfc8e3aaff..620fba7192 100644 --- a/libavcodec/loongarch/Makefile +++ b/libavcodec/loongarch/Makefile @@ -27,4 +27,5 @@ LSX-OBJS-$(CONFIG_VP9_DECODER)+= loongarch/vp9_mc_lsx.o \ loongarch/vp9_idct_lsx.o LSX-OBJS-$(CONFIG_HEVC_DECODER) += loongarch/hevcdsp_lsx.o \ loongarch/hevc_idct_lsx.o \ - loongarch/hevc_lpf_sao_lsx.o + loongarch/hevc_lpf_sao_lsx.o \ + loongarch/hevc_mc_bi_lsx.o diff --git a/libavcodec/loongarch/hevc_mc_bi_lsx.c b/libavcodec/loongarch/hevc_mc_bi_lsx.c new file mode 100644 index 00..9092fdccb2 --- /dev/null +++ b/libavcodec/loongarch/hevc_mc_bi_lsx.c @@ -0,0 +1,2289 @@ +/* + * Copyright (c) 2022 Loongson Technology Corporation Limited + * Contributed by Lu Wang + *Hao Chen + * + * 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 "libavutil/loongarch/loongson_intrinsics.h" +#include "hevcdsp_lsx.h" + +static const uint8_t ff_hevc_mask_arr[16 * 2] __attribute__((aligned(0x40))) = { +/* 8 width cases */ +0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, +0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20 +}; + +static av_always_inline __m128i +hevc_bi_rnd_clip(__m128i in0, __m128i vec0, __m128i in1, __m128i vec1) +{ +__m128i out; + +vec0 = __lsx_vsadd_h(in0, vec0); +vec1 = __lsx_vsadd_h(in1, vec1); +out = __lsx_vssrarni_bu_h(vec1, vec0, 7); +return out; +} + +/* hevc_bi_copy: dst = av_clip_uint8((src0 << 6 + src1) >> 7) */ +static +void hevc_bi_copy_4w_lsx(uint8_t *src0_ptr, int32_t src_stride, + int16_t *src1_ptr, int32_t src2_stride, + uint8_t *dst, int32_t dst_stride, int32_t height) +{ +int32_t loop_cnt = height >> 3; +int32_t res = (height & 0x07) >> 1; +int32_t src_stride_2x = (src_stride << 1); +int32_t dst_stride_2x = (dst_stride << 1); +int32_t src_stride_4x = (src_stride << 2); +int32_t dst_stride_4x = (dst_stride << 2); +int32_t src2_stride_2x = (src2_stride << 1); +int32_t src2_stride_4x = (src2_stride << 2); +int32_t src_stride_3x = src_stride_2x + src_stride; +int32_t dst_stride_3x = dst_stride_2x + dst_stride; +int32_t src2_stride_3x = src2_stride_2x + src2_stride; +__m128i src0, src1; +__m128i zero = __lsx_vldi(0); +__m128i in0, in1, in2, in3; +__m128i tmp0, tmp1, tmp2, tmp3; +__m128i reg0, reg1, reg2, reg3; +__m128i dst0, dst1, dst2, dst3; + +for (;loop_cnt--;) { +reg0 = __lsx_vldrepl_w(src0_ptr, 0); +reg1 = __lsx_vldrepl_w(src0_ptr + src_stride, 0); +reg2 = __lsx_vldrepl_w(src0_ptr + src_stride_2x, 0); +reg3 = __lsx_vldrepl_w(src0_ptr + src_stride_3x, 0); +src0_ptr += src_stride_4x; +DUP2_ARG2(__lsx_vilvl_w, reg1, reg0, reg3, reg2, tmp0, tmp1); +src0 = __lsx_vilvl_d(tmp1, tmp0); +reg0 = __lsx_vldrepl_w(src0_ptr, 0); +reg1 = __lsx_vldrepl_w(src0_ptr + src_stride, 0); +reg2 = __lsx_vldrepl_w(src0_ptr + src_stride_2x, 0); +reg3 = __lsx_vldrepl_w(src0_ptr + src_stride_3x, 0); +DUP2_ARG2(__lsx_vilvl_w, reg1, reg0, reg3, reg2, tmp0, tmp1); +src1 = __lsx_vilvl_d(tmp1, tmp0); +src0_ptr += src_stride_4x; + +tmp0 = __lsx_vldrepl_d(src1_ptr, 0); +tmp1 = __lsx_vldrepl_d(src1_ptr + src2_stride, 0); +tmp2 = __lsx_vldrepl_d(src1_ptr + src2_stride_2x, 0); +tmp3 = __lsx_vldrepl_d(src1_ptr + src2_stride_3x, 0); +src1_ptr += src2_stride_4x; +DUP2_ARG2(__lsx_vilvl_d, tmp1, tmp0, tmp3, tmp2, in0,
[FFmpeg-devel] [PATCH v1 5/5] avcodec: [loongarch] Optimize Hevc_mc_uni/w with LSX.
From: Lu Wang ffmpeg -i 5_h265_1080p_60fps_3Mbps.mkv -f rawvideo -y /dev/null -an before: 182fps after : 191fps --- libavcodec/loongarch/Makefile |4 +- libavcodec/loongarch/hevc_mc_uni_lsx.c| 1423 + libavcodec/loongarch/hevc_mc_uniw_lsx.c | 298 libavcodec/loongarch/hevcdsp_init_loongarch.c | 30 + libavcodec/loongarch/hevcdsp_lsx.h| 59 + 5 files changed, 1813 insertions(+), 1 deletion(-) create mode 100644 libavcodec/loongarch/hevc_mc_uni_lsx.c create mode 100644 libavcodec/loongarch/hevc_mc_uniw_lsx.c diff --git a/libavcodec/loongarch/Makefile b/libavcodec/loongarch/Makefile index 620fba7192..c1b5de5c44 100644 --- a/libavcodec/loongarch/Makefile +++ b/libavcodec/loongarch/Makefile @@ -28,4 +28,6 @@ LSX-OBJS-$(CONFIG_VP9_DECODER)+= loongarch/vp9_mc_lsx.o \ LSX-OBJS-$(CONFIG_HEVC_DECODER) += loongarch/hevcdsp_lsx.o \ loongarch/hevc_idct_lsx.o \ loongarch/hevc_lpf_sao_lsx.o \ - loongarch/hevc_mc_bi_lsx.o + loongarch/hevc_mc_bi_lsx.o \ + loongarch/hevc_mc_uni_lsx.o \ + loongarch/hevc_mc_uniw_lsx.o diff --git a/libavcodec/loongarch/hevc_mc_uni_lsx.c b/libavcodec/loongarch/hevc_mc_uni_lsx.c new file mode 100644 index 00..a15c86268f --- /dev/null +++ b/libavcodec/loongarch/hevc_mc_uni_lsx.c @@ -0,0 +1,1423 @@ +/* + * Copyright (c) 2022 Loongson Technology Corporation Limited + * Contributed by Lu Wang + *Hao Chen + * + * 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 "libavutil/loongarch/loongson_intrinsics.h" +#include "hevcdsp_lsx.h" + +static const uint8_t ff_hevc_mask_arr[16 * 3] __attribute__((aligned(0x40))) = { +/* 8 width cases */ +0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, +/* 4 width cases */ +0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20, +/* 4 width cases */ +8, 9, 9, 10, 10, 11, 11, 12, 24, 25, 25, 26, 26, 27, 27, 28 +}; + +static av_always_inline +void common_hz_8t_64w_lsx(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ +int32_t loop_cnt; +__m128i mask0, mask1, mask2, mask3, out1, out2; +__m128i src0, src1, src2, src3, src4, src5, src6, src7; +__m128i vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; +__m128i filt0, filt1, filt2, filt3; +__m128i res0, res1, res2, res3; + +mask0 = __lsx_vld(ff_hevc_mask_arr, 0); +src -= 3; + +/* rearranging filter */ +DUP4_ARG2(__lsx_vldrepl_h, filter, 0, filter, 2, filter, 4, filter, 6, + filt0, filt1, filt2, filt3); + +DUP2_ARG2(__lsx_vaddi_bu, mask0, 2, mask0, 4, mask1, mask2); +mask3 = __lsx_vaddi_bu(mask0, 6); + +for (loop_cnt = height; loop_cnt--;) { +DUP4_ARG2(__lsx_vld, src, 0, src, 8, src, 16, src, 24, + src0, src1, src2, src3); +DUP4_ARG2(__lsx_vld, src, 32, src, 40, src, 48, src, 56, + src4, src5, src6, src7); +src += src_stride; + +DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask0, src1, src1, mask0, + vec0, vec1); +DUP2_ARG3(__lsx_vshuf_b, src2, src2, mask0, src3, src3, mask0, + vec2, vec3); +DUP4_ARG2(__lsx_vdp2_h_bu_b, vec0, filt0, vec1, filt0, vec2, filt0, + vec3, filt0, res0, res1, res2, res3); +DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask2, src1, src1, mask2, + vec0, vec1); +DUP2_ARG3(__lsx_vshuf_b, src2, src2, mask2, src3, src3, mask2, + vec2, vec3); +DUP4_ARG3(__lsx_vdp2add_h_bu_b, res0, vec0, filt2, res1, vec1, filt2, + res2, vec2, filt2, res3, vec3, filt2, res0, res1, res2, res3); +DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask1, src1, src1, mask1, + vec4, vec5); +DUP2_ARG3(__lsx_vshuf_b, src2, src2, mask1, src3, src3, mask1, + vec6, vec7); +DUP4_ARG3(__lsx_vdp2add_h_bu_b, res0, vec4, filt1, res1, ve
[FFmpeg-devel] [PATCH v2] avformat/img2dec: Option to play sequence backwards
This patch should allow playing an image sequence in backwards direction, without needing to apply a reverse filter. ffmpeg -i sequence%05d.png forward.mkv ffmpeg -reverse 1 -i sequence%05d.png backward.mkv Signed-off-by: Sergio Acereda --- libavformat/img2.h| 1 + libavformat/img2dec.c | 42 +++--- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/libavformat/img2.h b/libavformat/img2.h index 5fd8ff77fc..3d01c00537 100644 --- a/libavformat/img2.h +++ b/libavformat/img2.h @@ -59,6 +59,7 @@ typedef struct VideoDemuxData { #endif int start_number; int start_number_range; +int reverse; int frame_size; int ts_from_file; int export_path_metadata; /**< enabled when set to 1. */ diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index 8608252d83..37efb3d618 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -105,10 +105,12 @@ static int is_glob(const char *path) * @param plast_index pointer to index updated with the last number in the range * @param path path which has to be matched by the image files in the range * @param start_index minimum accepted value for the first index in the range + * @param start_index_range range for looking at the first sequence number + * @param reverse play backwards * @return -1 if no image file could be found */ static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index, -const char *path, int start_index, int start_index_range) +const char *path, int start_index, int start_index_range, int reverse) { char buf[1024]; int range, last_index, range1, first_index; @@ -152,8 +154,13 @@ static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index break; last_index += range; } -*pfirst_index = first_index; -*plast_index = last_index; +if (reverse) { +*pfirst_index = last_index; +*plast_index = first_index; +} else { +*pfirst_index = first_index; +*plast_index = last_index; +} return 0; fail: @@ -274,7 +281,7 @@ int ff_img_read_header(AVFormatContext *s1) } if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) { if (find_image_range(s1->pb, &first_index, &last_index, s->path, - s->start_number, s->start_number_range) < 0) { + s->start_number, s->start_number_range, s->reverse) < 0) { av_log(s1, AV_LOG_ERROR, "Could find no file with path '%s' and index in the range %d-%d\n", s->path, s->start_number, s->start_number + s->start_number_range - 1); @@ -307,7 +314,7 @@ int ff_img_read_header(AVFormatContext *s1) /* compute duration */ if (!s->ts_from_file) { st->start_time = 0; -st->duration = last_index - first_index + 1; +st->duration = FFABS(last_index - first_index) + 1; } } @@ -402,6 +409,13 @@ static int add_filename_as_pkt_side_data(char *filename, AVPacket *pkt) { return 0; } +static int out_bounds(const VideoDemuxData *s) +{ +if (s->reverse) +return s->img_number < s->img_last; +return s->img_number > s->img_last; +} + int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) { VideoDemuxData *s = s1->priv_data; @@ -414,10 +428,10 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) if (!s->is_pipe) { /* loop over input */ -if (s->loop && s->img_number > s->img_last) { +if (s->loop && out_bounds(s)) { s->img_number = s->img_first; } -if (s->img_number > s->img_last) +if (out_bounds(s)) return AVERROR_EOF; if (s->pattern_type == PT_NONE) { av_strlcpy(filename_bytes, s->path, sizeof(filename_bytes)); @@ -554,8 +568,9 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) } goto fail; } else { +int step = s->reverse? -1 : 1; s->img_count++; -s->img_number++; +s->img_number += step; s->pts++; return 0; } @@ -585,6 +600,7 @@ static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp { VideoDemuxData *s1 = s->priv_data; AVStream *st = s->streams[0]; +int span; if (s1->ts_from_file) { int index = av_index_search_timestamp(st, timestamp, flags); @@ -594,10 +610,13 @@ static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp return 0; } -if (timestamp < 0 || !s1->loop && timestamp > s1->img_last - s1->img_first) +span = 1 + FFABS(s1->img_last - s1->img_first); +if (timestamp < 0 || !s1->loop && timestamp > span) return -1; -s1->img_numb
Re: [FFmpeg-devel] [PATCH] libavcodec/qsvenc_hevc: encode RGB format rawvideo
Wenbin Chen: > Add support for hevc_qsv to input RGB format frame. It will > transform frame to yuv inside MediaSDK instead of using auto > scale. Now hevc_qsv supports directly encoding BGRA and X2RGB10 > format. X2RGB10 is only supported in VDENC (-low_power 1). > The X2RGB10 correspond to the A2RGB20 format in MediaSDK. > > Sigend-off-by: Wenbin Chen ^ Are you writing this manually? - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] Long path support for Windows (fixes #8885)
From: nihil-admirari <50202386+nihil-admir...@users.noreply.github.com> Long path support is enabled by adding a manifest to all of fftools. MAX_PATH-sized buffers are replaced with dynamically sized ones. --- compat/w32dlfcn.h| 61 +++- fftools/Makefile | 5 +++ fftools/cmdutils.c | 31 fftools/long_paths_utf8.manifest | 12 +++ fftools/long_paths_utf8.rc | 3 ++ libavformat/avisynth.c | 10 +++--- libavutil/wchar_filename.h | 37 +++ 7 files changed, 139 insertions(+), 20 deletions(-) create mode 100644 fftools/long_paths_utf8.manifest create mode 100644 fftools/long_paths_utf8.rc diff --git a/compat/w32dlfcn.h b/compat/w32dlfcn.h index 52a94ef..ba2330a 100644 --- a/compat/w32dlfcn.h +++ b/compat/w32dlfcn.h @@ -25,6 +25,30 @@ #if (_WIN32_WINNT < 0x0602) || HAVE_WINRT #include "libavutil/wchar_filename.h" #endif + +static inline wchar_t *get_module_filename(const HMODULE module) +{ +wchar_t *path = NULL; +int path_size = 0, path_len = 0; + +do { +path_size = path_size ? 1.5 * path_size : MAX_PATH; +wchar_t *new_path = av_realloc_array(path, path_size, sizeof *path); +if (!new_path) { +av_free(path); +return NULL; +} +path = new_path; +path_len = GetModuleFileNameW(module, path, path_size); +} while (path_len && path_size <= 32768 && path_size <= path_len); + +if (!path_len) { +av_free(path); +return NULL; +} +return path; +} + /** * Safe function used to open dynamic libs. This attempts to improve program security * by removing the current directory from the dll search path. Only dll's found in the @@ -38,24 +62,43 @@ static inline HMODULE win32_dlopen(const char *name) // Need to check if KB2533623 is available if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDefaultDllDirectories")) { HMODULE module = NULL; -wchar_t *path = NULL, *name_w = NULL; -DWORD pathlen; +wchar_t *path = NULL, *new_path = NULL, *name_w = NULL; +DWORD pathlen, pathsize, namelen; if (utf8towchar(name, &name_w)) goto exit; -path = (wchar_t *)av_calloc(MAX_PATH, sizeof(wchar_t)); +namelen = wcslen(name_w); // Try local directory first -pathlen = GetModuleFileNameW(NULL, path, MAX_PATH); -pathlen = wcsrchr(path, '\\') - path; -if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH) +path = get_module_filename(NULL); +if (!path) +goto exit; +new_path = wcsrchr(path, '\\'); +if (!new_path) +goto exit; +pathlen = new_path - path; +pathsize = pathlen + namelen + 2; +new_path = av_realloc_array(path, pathsize, sizeof *path); +if (!new_path) goto exit; -path[pathlen] = '\\'; +path = new_path; wcscpy(path + pathlen + 1, name_w); module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); if (module == NULL) { // Next try System32 directory -pathlen = GetSystemDirectoryW(path, MAX_PATH); -if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH) +pathlen = GetSystemDirectoryW(path, pathsize); +if (!pathlen) goto exit; +if (pathlen + namelen + 2 > pathsize) { +pathsize = pathlen + namelen + 2; +new_path = av_realloc_array(path, pathsize, sizeof *path); +if (!new_path) +goto exit; +path = new_path; +// The buffer might have been not enough for system directory +// in the first place. +pathlen = GetSystemDirectoryW(path, pathsize); +if (!pathlen) +goto exit; +} path[pathlen] = '\\'; wcscpy(path + pathlen + 1, name_w); module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); diff --git a/fftools/Makefile b/fftools/Makefile index da42078..53438b6 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -11,6 +11,11 @@ ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF)) OBJS-ffmpeg+= fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o +# Windows resource files +OBJS-ffmpeg-$(HAVE_GNU_WINDRES) += fftools/long_paths_utf8.o +OBJS-ffplay-$(HAVE_GNU_WINDRES) += fftools/long_paths_utf8.o +OBJS-ffprobe-$(HAVE_GNU_WINDRES) += fftools/long_paths_utf8.o + define DOFFTOOL OBJS-$(1) += fftools/cmdutils.o fftools/$(1).o $(OBJS-$(1)-yes) $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1)) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 4b50e15..ea78897 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -62,6 +62,7 @@ #endif #ifdef _WIN32 #
Re: [FFmpeg-devel] [patch] libavcodec/videotoolbox.c : fix missing AVCodecInternal
On Mon, Feb 14, 2022 at 08:27:39AM +0100, Pascal Massimino wrote: > attached. Just a missing include. I have submit a patch for it already, if you think it's OK, I can push it soon. > > skal/ > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [patch] libavcodec/videotoolbox.c : fix missing AVCodecInternal
lance.lmw...@gmail.com: > On Mon, Feb 14, 2022 at 08:27:39AM +0100, Pascal Massimino wrote: >> attached. Just a missing include. > > I have submit a patch for it already, if you think it's OK, I can push it > soon. > I have already pushed your patch. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [patch] libavcodec/videotoolbox.c : fix missing AVCodecInternal
On Mon, Feb 14, 2022 at 11:05:58AM +0100, Andreas Rheinhardt wrote: > lance.lmw...@gmail.com: > > On Mon, Feb 14, 2022 at 08:27:39AM +0100, Pascal Massimino wrote: > >> attached. Just a missing include. > > > > I have submit a patch for it already, if you think it's OK, I can push it > > soon. > > > > I have already pushed your patch. yeah, haven't notice that, thanks. > > - Andreas > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [patch] libavcodec/videotoolbox.c : fix missing AVCodecInternal
On Mon, Feb 14, 2022 at 11:30 AM wrote: > On Mon, Feb 14, 2022 at 11:05:58AM +0100, Andreas Rheinhardt wrote: > > lance.lmw...@gmail.com: > > > On Mon, Feb 14, 2022 at 08:27:39AM +0100, Pascal Massimino wrote: > > >> attached. Just a missing include. > > > > > > I have submit a patch for it already, if you think it's OK, I can push > it soon. > all good then, thanks Andreas and Lance... skal/ > > > > > > > I have already pushed your patch. > > yeah, haven't notice that, thanks. > > > > > - Andreas > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > > -- > Thanks, > Limin Wang > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 0/2] Some cleanup for header includes
Andreas Schneider: > Just some small header cleanup. > > Andreas Schneider (2): > avcodec/exif: Include bytestream.h for GetByteContext > avcodec/exif: Include tiff_common.h only where needed > > libavcodec/exif.c | 1 + > libavcodec/exif.h | 2 +- > libavcodec/mjpegdec.c | 1 + > libavcodec/webp.c | 1 + > 4 files changed, 4 insertions(+), 1 deletion(-) > Thanks, applied. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/3] configure: check avisynth header version
On 2022-02-14 05:04 am, Stephen Hutchinson wrote: On 2/8/22 6:02 AM, Stephen Hutchinson wrote: The headers from version 3.7.1 are needed in order to support parsing of frame properties. avs/version.h has been generated as part of the AviSynth+ build process for a long time, but was never installed with the includes until version 3.7.1a. Checking for the presence of avs/version.h might have been sufficient, but a version check mechanism might be useful in the future. This does not change the version compatibility with the library itself; previous 3.x versions of AviSynth+ as well as AviSynth 2.6 can still be used with the demuxer. Signed-off-by: Stephen Hutchinson --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 493493b4c5..544d341b49 100755 --- a/configure +++ b/configure @@ -6508,7 +6508,9 @@ for func in $COMPLEX_FUNCS; do done # these are off by default, so fail if requested and not available -enabled avisynth && require_headers "avisynth/avisynth_c.h" +enabled avisynth && { require_headers "avisynth/avisynth_c.h avisynth/avs/version.h" && + { test_cpp_condition avisynth/avs/version.h "AVS_MAJOR_VER >= 3 && AVS_MINOR_VER >= 7 && AVS_BUGFIX_VER >= 1 || AVS_MAJOR_VER >= 3 && AVS_MINOR_VER > 7 || AVS_MAJOR_VER > 3" || + die "ERROR: AviSynth+ header version must be >= 3.7.1"; } } enabled cuda_nvcc && { check_nvcc cuda_nvcc || die "ERROR: failed checking for nvcc."; } enabled chromaprint && require chromaprint chromaprint.h chromaprint_get_version -lchromaprint enabled decklink && { require_headers DeckLinkAPI.h && The advice for AVS+ dlopen consumers is to only build and install AVS+ headers. That does not install version.h and arch.h which are only built with the binary artifacts, not with -DHEADERS_ONLY. For my Windows build, I just manually copied and renamed the template files to make configure succeed. Regards, Gyan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] arm64: Add Armv8.3-A PAC support to assembly files
This patch adds optional support for Arm Pointer Authentication Codes. PAC support is turned on or off at compile time using additional compiler flags. Unless any of these is enabled explicitly, no additional code will be emitted at all. Signed-off-by: André Kempe --- libavcodec/aarch64/fft_neon.S | 3 +- libavcodec/aarch64/mdct_neon.S | 17 - libavcodec/aarch64/synth_filter_neon.S | 2 + libavutil/aarch64/asm.S| 102 +++-- 4 files changed, 113 insertions(+), 11 deletions(-) diff --git a/libavcodec/aarch64/fft_neon.S b/libavcodec/aarch64/fft_neon.S index b4020fc8c7..dd5f55eb87 100644 --- a/libavcodec/aarch64/fft_neon.S +++ b/libavcodec/aarch64/fft_neon.S @@ -340,7 +340,7 @@ endfunc .macro def_fft n, n2, n4 function fft\n\()_neon, align=6 -AARCH64_VALID_JUMP_TARGET +AARCH64_SIGN_LINK_REGISTER sub sp, sp, #16 stp x28, x30, [sp] add x28, x0, #\n4*2*8 @@ -351,6 +351,7 @@ function fft\n\()_neon, align=6 bl fft\n4\()_neon sub x0, x28, #\n4*2*8 ldp x28, x30, [sp], #16 +AARCH64_VALIDATE_LINK_REGISTER movrel x4, X(ff_cos_\n) mov x2, #\n4>>1 b fft_pass_neon diff --git a/libavcodec/aarch64/mdct_neon.S b/libavcodec/aarch64/mdct_neon.S index 1fd199c972..6091e72022 100644 --- a/libavcodec/aarch64/mdct_neon.S +++ b/libavcodec/aarch64/mdct_neon.S @@ -25,6 +25,7 @@ function ff_imdct_half_neon, export=1 sub sp, sp, #32 stp x19, x20, [sp] +AARCH64_SIGN_LINK_REGISTER str x30, [sp, #16] mov x12, #1 ldr w14, [x0, #28] // mdct_bits @@ -121,6 +122,7 @@ function ff_imdct_half_neon, export=1 ldp x19, x20, [sp] ldr x30, [sp, #16] +AARCH64_VALIDATE_LINK_REGISTER add sp, sp, #32 ret @@ -129,6 +131,7 @@ endfunc function ff_imdct_calc_neon, export=1 sub sp, sp, #32 stp x19, x20, [sp] +AARCH64_SIGN_LINK_REGISTER str x30, [sp, #16] ldr w3, [x0, #28] // mdct_bits mov x19, #1 @@ -160,8 +163,10 @@ function ff_imdct_calc_neon, export=1 subsx19, x19, #16 b.gt1b -ldp x19, x20, [sp], #16 -ldr x30, [sp], #16 +ldp x19, x20, [sp] +ldr x30, [sp, #16] +AARCH64_VALIDATE_LINK_REGISTER +add sp, sp, #32 ret endfunc @@ -170,6 +175,7 @@ endfunc function ff_mdct_calc_neon, export=1 sub sp, sp, #32 stp x19, x20, [sp] +AARCH64_SIGN_LINK_REGISTER str x30, [sp, #16] mov x12, #1 @@ -317,7 +323,10 @@ function ff_mdct_calc_neon, export=1 st2 {v4.2s,v5.2s}, [x0] st2 {v6.2s,v7.2s}, [x8] -ldp x19, x20, [sp], #16 -ldr x30, [sp], #16 +ldp x19, x20, [sp] +ldr x30, [sp, #16] +AARCH64_VALIDATE_LINK_REGISTER +add sp, sp, #32 + ret endfunc diff --git a/libavcodec/aarch64/synth_filter_neon.S b/libavcodec/aarch64/synth_filter_neon.S index 8fcd71f252..ba79ba9686 100644 --- a/libavcodec/aarch64/synth_filter_neon.S +++ b/libavcodec/aarch64/synth_filter_neon.S @@ -52,6 +52,7 @@ function ff_synth_filter_float_neon, export=1 stp x5, x1, [sp, #16] and x7, x7, #~63 and w8, w8, #511 +AARCH64_SIGN_LINK_REGISTER stp x7, x30, [sp, #32] str w8, [x2] str s0, [sp, #48] @@ -63,6 +64,7 @@ function ff_synth_filter_float_neon, export=1 ldp x2, x4, [sp] // synct_buf_2, window ldp x13, x9, [sp, #16] // out, synth_buf ldp x0, x30, [sp, #32] // *synth_buf_offset +AARCH64_VALIDATE_LINK_REGISTER ldr s0, [sp, #48] add x3, x2, #16*4 // synct_buf_2 + 16 diff --git a/libavutil/aarch64/asm.S b/libavutil/aarch64/asm.S index bee91d59c3..b817eaab22 100644 --- a/libavutil/aarch64/asm.S +++ b/libavutil/aarch64/asm.S @@ -36,10 +36,79 @@ # define __has_feature(x) 0 #endif -/* Support macros for the Armv8.5-A Branch Target Identification feature which - * requires emitting a .note.gnu.property section with the appropriate - * architecture-dependent feature bits set. - * Read more: "ELF for the Arm® 64-bit Architecture" + +/* Support macros for + * - Armv8.3-A Pointer Authentication and + *
[FFmpeg-devel] [PATCH] configure: move ranlib -D test after setting defaults
In Gentoo and ChromeOS we want to allow pure LLVM builds without using GNU tools, so we block any unwanted mixed GNU/LLVM usages (GNU tools are still kept around in our chroots for projects like glibc which cannot yet be built otherwise). The default ${cross_prefix}${ranlib_default} points to GNU and fails, so move the test a bit later - after the defaults are set and the proper values get overriden - such that ffmpeg configure calls the llvm-ranlib we desire. [1] [1] https://gitweb.gentoo.org/repo/gentoo.git/tree/media-video/ffmpeg/ffmpeg-4.4.1-r1.ebuild?id=7a34377e3277a6a0e2eedd40e90452a44c55f1e6#n477 Signed-off-by: Adrian Ratiu --- configure | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure b/configure index a251e27723..61c150959e 100755 --- a/configure +++ b/configure @@ -4416,11 +4416,7 @@ cc_default="${cross_prefix}${cc_default}" cxx_default="${cross_prefix}${cxx_default}" nm_default="${cross_prefix}${nm_default}" pkg_config_default="${cross_prefix}${pkg_config_default}" -if ${cross_prefix}${ranlib_default} 2>&1 | grep -q "\-D "; then -ranlib_default="${cross_prefix}${ranlib_default} -D" -else -ranlib_default="${cross_prefix}${ranlib_default}" -fi +ranlib_default="${cross_prefix}${ranlib_default}" strip_default="${cross_prefix}${strip_default}" windres_default="${cross_prefix}${windres_default}" @@ -4453,6 +4449,10 @@ set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \ enabled cross_compile || host_cc_default=$cc set_default host_cc +if ${ranlib} 2>&1 | grep -q "\-D "; then +ranlib="${ranlib} -D" +fi + pkg_config_fail_message="" if ! $pkg_config --version >/dev/null 2>&1; then warn "$pkg_config not found, library detection may fail." -- 2.35.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 275/281] avfilter: convert to new channel layout API
Quoting James Almer (2022-01-13 03:09:07) > diff --git a/libavfilter/af_apulsator.c b/libavfilter/af_apulsator.c > index c2a8de0e0b..c3ca752035 100644 > --- a/libavfilter/af_apulsator.c > +++ b/libavfilter/af_apulsator.c > @@ -192,7 +192,7 @@ static int query_formats(AVFilterContext *ctx) > > if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_DBL > )) < 0 || > (ret = ff_set_common_formats (ctx , formats > )) < 0 || > -(ret = ff_add_channel_layout (&layout , > AV_CH_LAYOUT_STEREO)) < 0 || > +(ret = ff_add_channel_layout (&layout , > &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO)) < 0 || completion fail? > diff --git a/libavfilter/af_sofalizer.c b/libavfilter/af_sofalizer.c > index 20b717bdf8..246ddeffb9 100644 > --- a/libavfilter/af_sofalizer.c > +++ b/libavfilter/af_sofalizer.c > @@ -187,25 +187,15 @@ static int preload_sofa(AVFilterContext *ctx, char > *filename, int *samplingrate) > > static int parse_channel_name(AVFilterContext *ctx, char **arg, int > *rchannel) > { > -int len, i, channel_id = 0; > -int64_t layout, layout0; > +int len, channel_id = 0; > char buf[8] = {0}; > > /* try to parse a channel name, e.g. "FL" */ > if (av_sscanf(*arg, "%7[A-Z]%n", buf, &len)) { > -layout0 = layout = av_get_channel_layout(buf); > -/* channel_id <- first set bit in layout */ > -for (i = 32; i > 0; i >>= 1) { > -if (layout >= 1LL << i) { > -channel_id += i; > -layout >>= i; > -} > -} > -/* reject layouts that are not a single channel */ > -if (channel_id >= 64 || layout0 != 1LL << channel_id) { You should keep the range check, because the id gets used as index into vspkrpos[64]. > -av_log(ctx, AV_LOG_WARNING, "Failed to parse \'%s\' as channel > name.\n", buf); > -return AVERROR(EINVAL); > -} > +channel_id = av_channel_from_string(buf); > +if (channel_id < 0) > +return channel_id; > + > *rchannel = channel_id; > *arg += len; > return 0; > @@ -221,7 +211,7 @@ static int parse_channel_name(AVFilterContext *ctx, char > **arg, int *rchannel) > return AVERROR(EINVAL); > } > > -static void parse_speaker_pos(AVFilterContext *ctx, int64_t > in_channel_layout) > +static void parse_speaker_pos(AVFilterContext *ctx) > { > SOFAlizerContext *s = ctx->priv; > char *arg, *tokenizer, *p, *args = av_strdup(s->speakers_pos); > @@ -256,10 +246,10 @@ static int get_speaker_pos(AVFilterContext *ctx, > float *speaker_azim, float *speaker_elev) > { > struct SOFAlizerContext *s = ctx->priv; > -uint64_t channels_layout = ctx->inputs[0]->channel_layout; > +AVChannelLayout *channel_layout = &ctx->inputs[0]->ch_layout; > float azim[64] = { 0 }; > float elev[64] = { 0 }; > -int m, ch, n_conv = ctx->inputs[0]->channels; /* get no. input channels > */ > +int m, ch, n_conv = ctx->inputs[0]->ch_layout.nb_channels; /* get no. > input channels */ > > if (n_conv < 0 || n_conv > 64) > return AVERROR(EINVAL); > @@ -267,45 +257,45 @@ static int get_speaker_pos(AVFilterContext *ctx, > s->lfe_channel = -1; > > if (s->speakers_pos) > -parse_speaker_pos(ctx, channels_layout); > +parse_speaker_pos(ctx); > > /* set speaker positions according to input channel configuration: */ > for (m = 0, ch = 0; ch < n_conv && m < 64; m++) { > -uint64_t mask = channels_layout & (1ULL << m); > - > -switch (mask) { > -case AV_CH_FRONT_LEFT:azim[ch] = 30; break; > -case AV_CH_FRONT_RIGHT: azim[ch] = 330; break; > -case AV_CH_FRONT_CENTER: azim[ch] = 0; break; > -case AV_CH_LOW_FREQUENCY: > -case AV_CH_LOW_FREQUENCY_2: s->lfe_channel = ch; break; > -case AV_CH_BACK_LEFT: azim[ch] = 150; break; > -case AV_CH_BACK_RIGHT:azim[ch] = 210; break; > -case AV_CH_BACK_CENTER: azim[ch] = 180; break; > -case AV_CH_SIDE_LEFT: azim[ch] = 90; break; > -case AV_CH_SIDE_RIGHT:azim[ch] = 270; break; > -case AV_CH_FRONT_LEFT_OF_CENTER: azim[ch] = 15; break; > -case AV_CH_FRONT_RIGHT_OF_CENTER: azim[ch] = 345; break; > -case AV_CH_TOP_CENTER:azim[ch] = 0; > +int chan = av_channel_layout_channel_from_index(channel_layout, m); > + > +switch (chan) { > +case AV_CHAN_FRONT_LEFT: azim[ch] = 30; break; > +case AV_CHAN_FRONT_RIGHT: azim[ch] = 330; break; > +case AV_CHAN_FRONT_CENTER:azim[ch] = 0; break; > +case AV_CHAN_LOW_FREQUENCY: > +case AV_CHAN_LOW_FREQUENCY_2: s->lfe_
Re: [FFmpeg-devel] [PATCH] avformat/gnutls: Use the systems default crypto policy
Quoting Andreas Schneider (2022-02-11 08:34:14) > We should use the systems crypto policy by default. If there is no > system policy, gnutls will use the "NORMAL" policy. > > Signed-off-by: Andreas Schneider > --- > libavformat/tls_gnutls.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c > index 741578a596..2ab38a199b 100644 > --- a/libavformat/tls_gnutls.c > +++ b/libavformat/tls_gnutls.c > @@ -192,7 +192,7 @@ static int tls_open(URLContext *h, const char *uri, int > flags, AVDictionary **op > gnutls_transport_set_pull_function(p->session, gnutls_url_pull); > gnutls_transport_set_push_function(p->session, gnutls_url_push); > gnutls_transport_set_ptr(p->session, p); > -gnutls_priority_set_direct(p->session, "NORMAL", NULL); > +gnutls_set_default_priority(p->session); > do { > if (ff_check_interrupt(&h->interrupt_callback)) { > ret = AVERROR_EXIT; Looks reasonable, will push tomorrow if nobody objects. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avcodec: add ADPCM IMA HVQM4 decoder
tests please, for all of these -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/id3v2: Add Grouping frame to id3v2.4 metadata table
Quoting Wolfgang Müller (2022-02-13 14:46:33) > The ID3v2.4.0 standard defines TIT1 as the "Content group description" > tag [1]. This frame is usually referred to as the "Grouping" tag and in > de-facto use under that name by Vorbis and APEv2 [2]. > > This commit introduces a mapping from "TIT1" to "grouping" in the > id3v2.4 metadata conversion table. This will enable software to access > it using that name. In particular, MPD will now read this tag correctly > when using the ffmpeg decoder plugin. > > [1] https://id3.org/id3v2.4.0-frames (4.2.1) > [2] > https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#grouping-3 > > Signed-off-by: Wolfgang Müller > --- > > As evident from the commit message, I ran into this using MPD with the > ffmpeg decoder plugin. MPD relies on these mappings heavily, and I found > it the easiest place to fix this particular issue, especially if other > pieces of software can also gain from this. > > libavformat/id3v2.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c > index ff27c062e5..0f9bedea02 100644 > --- a/libavformat/id3v2.c > +++ b/libavformat/id3v2.c > @@ -69,6 +69,7 @@ const AVMetadataConv ff_id3v2_4_metadata_conv[] = { > { "TSOA", "album-sort"}, > { "TSOP", "artist-sort" }, > { "TSOT", "title-sort"}, > +{ "TIT1", "grouping" }, > { 0 } > }; > > -- > 2.35.1 Looks ok, will push tomorrow -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3] [WIP] avcodec: add HVQM4 Video decoder
Paul B Mahol: > Signed-off-by: Paul B Mahol > --- > libavcodec/Makefile |1 + > libavcodec/allcodecs.c |1 + > libavcodec/codec_desc.c |7 + > libavcodec/codec_id.h |1 + > libavcodec/hvqm4.c | 1719 +++ > 5 files changed, 1729 insertions(+) > create mode 100644 libavcodec/hvqm4.c > > +static int read_trees(int index, > + int length, > + uint16_t code, > + uint8_t *bits, > + uint16_t *codes, > + uint16_t *symbols, > + GetBitContext *gb, > + const uint32_t tree_signed, > + const uint32_t tree_scale) > +{ > +if (get_bits1(gb) == 0) { // leaf node > +uint8_t byte = get_bits(gb, 8); > +int16_t symbol = byte; > + > +if (tree_signed && byte > 0x7F) Is the check "byte > 0x7F" actually is an improvement? > +symbol = (int8_t)byte; > + > +symbol *= 1 << tree_scale; > +bits[index] = length; > +codes[index] = code; > +symbols[index] = symbol; > +index++; > +return index; > +} else { // recurse > +index = read_trees(index, length + 1, code << 1, bits, codes, > symbols, gb, tree_signed, tree_scale); > +index = read_trees(index, length + 1, (code << 1) + 1, bits, codes, > symbols, gb, tree_signed, tree_scale); > +return index; > +} > +} > + > +static int build_huff(GBCWithVLC *buf, uint32_t is_signed, uint32_t scale) > +{ > +const uint32_t tree_signed = is_signed; > +const uint32_t tree_scale = scale; > +uint8_t bits[256] = { 0 }; > +uint16_t codes[256] = { 0 }; > +uint16_t symbols[256] = { 0 }; > +VLC *vlc = buf->vlc; > +int nb_codes; > + > +ff_free_vlc(vlc); > +nb_codes = read_trees(0, 0, 0, bits, codes, symbols, &buf->gb, > tree_signed, tree_scale); > + > +return ff_init_vlc_sparse(vlc, ff_log2(nb_codes) + 3, nb_codes, bits, 1, > 1, > + codes, 2, 2, symbols, 2, 2, 0); > +} > + 1. The above code does not check against stack overflow or buffer overflow; you are also not checking that your codes fit into 16bits. 2. I also don't get where your ff_log2(nb_codes) + 3 comes from. 3. The nodes are stored from left to right in the tree, so using ff_init_vlc_sparse() is unnecessary; ff_init_vlc_from_lengths() can be used like this (untested): struct HuffTree { int nb_codes; uint8_t bits[256]; uint16_t symbols[256]; } HuffTree; static int read_trees(int length, HuffTree *huff, GetBitContext *gb, const uint32_t tree_signed, const uint32_t tree_scale) { int ret; if (get_bits1(gb) == 0) { // leaf node uint8_t byte = get_bits(gb, 8); int16_t symbol = tree_signed ? (int8_t)byte : byte; symbol *= 1 << tree_scale; if (huff->nb_codes >= FF_ARRAY_ELEMS(huff->bits)) return AVERROR_INVALIDDATA; huff->bits[huff->nb_codes]= length; huff->symbols[huff->nb_codes] = symbol; huff->nb_codes++; return 0; } else { // recurse if (length == 16) return AVERROR_INVALIDDATA; ret = read_trees(length + 1, huff, gb, tree_signed, tree_scale); if (ret < 0) return ret; return read_trees(length + 1, huff, gb, tree_signed, tree_scale); } } static int build_huff(GBCWithVLC *buf, uint32_t is_signed, uint32_t scale) { const uint32_t tree_signed = is_signed; const uint32_t tree_scale = scale; HuffTree huff; VLC *vlc = buf->vlc; int ret; huff.nb_codes = 0; ff_free_vlc(vlc); ret = read_trees(0, &huff, &buf->gb, tree_signed, tree_scale); if (ret < 0) return ret; return ff_init_vlc_from_lengths(vlc, ff_log2(huff.nb_codes) + 3, huff.nb_codes, huff.bits, 1, huff.symbols, 2, 2, 0, 0, NULL); } 4. Is it legal for the tree to consists of only the root (which then has length zero)? Our code for generating VLCs can't handle this at the moment; I always pondered adding support for it (and somewhere I have a stash entry for it), but never did it. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [Patch] libavfilter/vf_fftfilt.c : fix missing include for av_cpu_max_align symbol
Attached. skal/ 0001-fix-missing-cpu.h-include.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [Patch] libavfilter/vf_fftfilt.c : fix missing include for av_cpu_max_align symbol
Pascal Massimino: > Attached. > > skal/ > Applied with a commit message that is more in line with our conventions. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avutil/x86/emms: Don't unnecessarily include lavu/cpu.h
Only include it if it is needed, namely if __MMX__ is undefined. X86 is currently the only arch where lavu/cpu.h is basically automatically included (for internal development): #if ARCH_X86 is true, lavu/internal.h (which is basically included everywhere) includes lavu/x86/emms.h which can mask missing inclusions of lavu/cpu.h if the developer works on x86/x64. This has happened in 8e825ec3ab09d877f12dcf05d76902a8bb9c8b11 and also earlier (see 6d2365882f281f9452b31b91edb2e6a2d4f5ff08). By including said header only if necessary ordinary developer machines will behave like non-x86 arches, so that missing inclusions of cpu.h won't go unnoticed any more. Signed-off-by: Andreas Rheinhardt --- libavutil/x86/emms.h | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavutil/x86/emms.h b/libavutil/x86/emms.h index c21e34b451..8ceec110cf 100644 --- a/libavutil/x86/emms.h +++ b/libavutil/x86/emms.h @@ -21,11 +21,14 @@ #include "config.h" #include "libavutil/attributes.h" -#include "libavutil/cpu.h" void avpriv_emms_asm(void); #if HAVE_MMX_INLINE +#ifndef __MMX__ +#include "libavutil/cpu.h" +#endif + # define emms_c emms_c /** * Empty mmx state. -- 2.32.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] avformat: add Argonaut Games CVG muxer
On Mon, May 03, 2021 at 09:31:57PM +1000, Zane van Iperen wrote: > Signed-off-by: Zane van Iperen > --- > Changelog| 1 + > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/argo_cvg.c | 149 ++- > libavformat/version.h| 2 +- > 5 files changed, 152 insertions(+), 2 deletions(-) > > diff --git a/Changelog b/Changelog > index 9567009d63..41b1690dfd 100644 > --- a/Changelog > +++ b/Changelog > @@ -5,6 +5,7 @@ version : > - ADPCM IMA Westwood encoder > - Westwood AUD muxer > - Argonaut Games CVG demuxer > +- Argonaut Games CVG muxer > > > version 4.4: > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 0dca1ffd77..c9ef564523 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -108,6 +108,7 @@ OBJS-$(CONFIG_ARGO_ASF_DEMUXER) += argo_asf.o > OBJS-$(CONFIG_ARGO_ASF_MUXER)+= argo_asf.o > OBJS-$(CONFIG_ARGO_BRP_DEMUXER) += argo_brp.o argo_asf.o > OBJS-$(CONFIG_ARGO_CVG_DEMUXER) += argo_cvg.o > +OBJS-$(CONFIG_ARGO_CVG_MUXER)+= argo_cvg.o > OBJS-$(CONFIG_ASF_DEMUXER) += asfdec_f.o asf.o asfcrypt.o \ > avlanguage.o > OBJS-$(CONFIG_ASF_O_DEMUXER) += asfdec_o.o asf.o asfcrypt.o \ > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index 923af3f649..111ca3cbf0 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -67,6 +67,7 @@ extern const AVInputFormat ff_argo_asf_demuxer; > extern const AVOutputFormat ff_argo_asf_muxer; > extern const AVInputFormat ff_argo_brp_demuxer; > extern const AVInputFormat ff_argo_cvg_demuxer; > +extern const AVOutputFormat ff_argo_cvg_muxer; > extern const AVInputFormat ff_asf_demuxer; > extern const AVOutputFormat ff_asf_muxer; > extern const AVInputFormat ff_asf_o_demuxer; > diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c > index 2851c1649f..f0d9f3e076 100644 > --- a/libavformat/argo_cvg.c > +++ b/libavformat/argo_cvg.c > @@ -1,5 +1,5 @@ > /* > - * Argonaut Games CVG demuxer > + * Argonaut Games CVG (de)muxer > * > * Copyright (C) 2021 Zane van Iperen (z...@zanevaniperen.com) > * > @@ -21,6 +21,7 @@ > */ > #include "avformat.h" > #include "internal.h" > +#include "libavutil/opt.h" > #include "libavutil/intreadwrite.h" > > /* > @@ -53,6 +54,14 @@ typedef struct ArgoCVGDemuxContext { > uint32_t blocks_read; > } ArgoCVGDemuxContext; > > +typedef struct ArgoCVGMuxContext { > +const AVClass *class; > +int skip_rate_check; > +uint32_t checksum; > +size_tsize; > +} ArgoCVGMuxContext; > + > +#if CONFIG_ARGO_CVG_DEMUXER > /* "Special" files that are played at a different rate. */ > static ArgoCVGOverride overrides[] = { > { "CRYS.CVG", { 23592, 0, 1 }, 2495499, 88200 }, /* Beta */ > @@ -243,3 +252,141 @@ const AVInputFormat ff_argo_cvg_demuxer = { > .read_packet= argo_cvg_read_packet, > .read_seek = argo_cvg_seek, > }; > +#endif > + > +#if CONFIG_ARGO_CVG_MUXER > +static int argo_cvg_write_init(AVFormatContext *s) > +{ > +ArgoCVGMuxContext *ctx = s->priv_data; > +const AVCodecParameters *par; > + > +if (s->nb_streams != 1) { > +av_log(s, AV_LOG_ERROR, "CVG files have exactly one stream\n"); > +return AVERROR(EINVAL); > +} > + > +par = s->streams[0]->codecpar; > + > +if (par->codec_id != AV_CODEC_ID_ADPCM_PSX) { > +av_log(s, AV_LOG_ERROR, "%s codec not supported\n", > + avcodec_get_name(par->codec_id)); > +return AVERROR(EINVAL); > +} > + > +if (par->channels != 1) { > +av_log(s, AV_LOG_ERROR, "CVG files only support 1 channel\n"); > +return AVERROR(EINVAL); > +} > + > +if (par->block_align != ARGO_CVG_BLOCK_ALIGN) > +return AVERROR(EINVAL); > + > +if (!ctx->skip_rate_check && par->sample_rate != 22050) { > +av_log(s, AV_LOG_ERROR, "Sample rate must be 22050\n"); > +return AVERROR(EINVAL); > +} > + > +if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) { > +av_log(s, AV_LOG_ERROR, "Stream not seekable, unable to write output > file\n"); > +return AVERROR(EINVAL); > +} > + > +return 0; > +} > + > +static int argo_cvg_write_header(AVFormatContext *s) > +{ > +ArgoCVGMuxContext *ctx = s->priv_data; > + > +avio_wl32(s->pb, 0); /* Size, fixed later. */ > +avio_wl32(s->pb, 0); > +avio_wl32(s->pb, 1); > + > +ctx->checksum = 1; > +ctx->size = 8; > +return 0; > +} > + > +static int argo_cvg_write_packet(AVFormatContext *s, AVPacket *pkt) > +{ > +ArgoCVGMuxContext *ctx = s->priv_data; > +AVCodecParameters *par = s->streams[0]->codecpar; > + > +if (pkt->size % par->block_align != 0) > +return AVERROR_INVALIDDATA; > + > +avio_write(s->pb, pkt->data, pkt->size); > + > +ctx->siz
[FFmpeg-devel] [PATCH 1/4] avformat/matroskadec: Check duration
Fixes: -nan is outside the range of representable values of type 'long' Fixes: 44614/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6216204841254912 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/matroskadec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 91f3567692..8f0c53a6bc 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3065,6 +3065,8 @@ static int matroska_read_header(AVFormatContext *s) if (!matroska->time_scale) matroska->time_scale = 100; +if (isnan(matroska->duration)) +matroska->duration = 0; if (matroska->duration) matroska->ctx->duration = matroska->duration * matroska->time_scale * 1000 / AV_TIME_BASE; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/4] avformat/argo_asf: Fix order of operations in error check in argo_asf_write_trailer()
Signed-off-by: Michael Niedermayer --- libavformat/argo_asf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c index 2b3569ebc3..d26844d1e2 100644 --- a/libavformat/argo_asf.c +++ b/libavformat/argo_asf.c @@ -423,7 +423,7 @@ static int argo_asf_write_trailer(AVFormatContext *s) ArgoASFMuxContext *ctx = s->priv_data; int64_t ret; -if ((ret = avio_seek(s->pb, ASF_FILE_HEADER_SIZE, SEEK_SET) < 0)) +if ((ret = avio_seek(s->pb, ASF_FILE_HEADER_SIZE, SEEK_SET)) < 0) return ret; avio_wl32(s->pb, (uint32_t)ctx->nb_blocks); -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/4] avcodec/movtextdec: add () to CMP() macro to avoid unexpected behavior
Signed-off-by: Michael Niedermayer --- libavcodec/movtextdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 825632ca9b..dc30fdc698 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -263,7 +263,7 @@ static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, uint64_t size) static int styles_equivalent(const StyleBox *a, const StyleBox *b) { -#define CMP(field) a->field == b->field +#define CMP(field) ((a)->field == (b)->field) return CMP(bold) && CMP(italic) && CMP(underline) && CMP(color) && CMP(alpha) && CMP(fontsize) && CMP(font_id); #undef CMP -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/4] avformat/argo_cvg:: Fix order of operations in error check in argo_cvg_write_trailer()
Signed-off-by: Michael Niedermayer --- libavformat/argo_cvg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c index e1854b4493..c5da32536d 100644 --- a/libavformat/argo_cvg.c +++ b/libavformat/argo_cvg.c @@ -350,7 +350,7 @@ static int argo_cvg_write_trailer(AVFormatContext *s) */ avio_wl32(s->pb, ctx->checksum); -if ((ret = avio_seek(s->pb, 0, SEEK_SET) < 0)) +if ((ret = avio_seek(s->pb, 0, SEEK_SET)) < 0) return ret; avio_wl32(s->pb, (uint32_t)ctx->size); -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/4] avcodec/movtextdec: add () to CMP() macro to avoid unexpected behavior
Michael Niedermayer: > Signed-off-by: Michael Niedermayer > --- > libavcodec/movtextdec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c > index 825632ca9b..dc30fdc698 100644 > --- a/libavcodec/movtextdec.c > +++ b/libavcodec/movtextdec.c > @@ -263,7 +263,7 @@ static int decode_hclr(const uint8_t *tsmb, > MovTextContext *m, uint64_t size) > > static int styles_equivalent(const StyleBox *a, const StyleBox *b) > { > -#define CMP(field) a->field == b->field > +#define CMP(field) ((a)->field == (b)->field) > return CMP(bold) && CMP(italic) && CMP(underline) && CMP(color) && > CMP(alpha) && CMP(fontsize) && CMP(font_id); > #undef CMP LGTM. (Did you find the issues in patches 2-4 by code inspection or by a static analyzer?) - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] avformat/matroskadec: Check duration
Michael Niedermayer: > Fixes: -nan is outside the range of representable values of type 'long' > Fixes: > 44614/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6216204841254912 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavformat/matroskadec.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c > index 91f3567692..8f0c53a6bc 100644 > --- a/libavformat/matroskadec.c > +++ b/libavformat/matroskadec.c > @@ -3065,6 +3065,8 @@ static int matroska_read_header(AVFormatContext *s) > > if (!matroska->time_scale) > matroska->time_scale = 100; > +if (isnan(matroska->duration)) > +matroska->duration = 0; > if (matroska->duration) > matroska->ctx->duration = matroska->duration * matroska->time_scale * >1000 / AV_TIME_BASE; LGTM. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/3] configure: check avisynth header version
On 2/14/22 6:56 AM, Gyan Doshi wrote: On 2022-02-14 05:04 am, Stephen Hutchinson wrote: On 2/8/22 6:02 AM, Stephen Hutchinson wrote: The headers from version 3.7.1 are needed in order to support parsing of frame properties. avs/version.h has been generated as part of the AviSynth+ build process for a long time, but was never installed with the includes until version 3.7.1a. Checking for the presence of avs/version.h might have been sufficient, but a version check mechanism might be useful in the future. This does not change the version compatibility with the library itself; previous 3.x versions of AviSynth+ as well as AviSynth 2.6 can still be used with the demuxer. Signed-off-by: Stephen Hutchinson --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 493493b4c5..544d341b49 100755 --- a/configure +++ b/configure @@ -6508,7 +6508,9 @@ for func in $COMPLEX_FUNCS; do done # these are off by default, so fail if requested and not available -enabled avisynth && require_headers "avisynth/avisynth_c.h" +enabled avisynth && { require_headers "avisynth/avisynth_c.h avisynth/avs/version.h" && + { test_cpp_condition avisynth/avs/version.h "AVS_MAJOR_VER >= 3 && AVS_MINOR_VER >= 7 && AVS_BUGFIX_VER >= 1 || AVS_MAJOR_VER >= 3 && AVS_MINOR_VER > 7 || AVS_MAJOR_VER > 3" || + die "ERROR: AviSynth+ header version must be >= 3.7.1"; } } enabled cuda_nvcc && { check_nvcc cuda_nvcc || die "ERROR: failed checking for nvcc."; } enabled chromaprint && require chromaprint chromaprint.h chromaprint_get_version -lchromaprint enabled decklink && { require_headers DeckLinkAPI.h && The advice for AVS+ dlopen consumers is to only build and install AVS+ headers. That does not install version.h and arch.h which are only built with the binary artifacts, not with -DHEADERS_ONLY. For my Windows build, I just manually copied and renamed the template files to make configure succeed. Regards, Gyan Should be fixed in https://github.com/AviSynth/AviSynthPlus/commit/0e583378116c857372232e9886c599df2fb8da85 with the caveat (noted in AviSynth+'s README.md) that the `make install` step now needs to explicitly invoke the VersionGen target, `make VersionGen install`. I fiddled with it for a while, but I couldn't get the install process to invoke it automatically. Related, the older GNUmakefile method is not set up to generate version.h and arch.h (especially considering both of those use *.cmake scripts), so it's now pretty clearly deprecated. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/6] ffmpeg: flush delayed frames in codec copy scenarios
Bitstream filters inserted between the input and output were never drained, resulting packets being lost if the bsf had any buffered. Signed-off-by: James Almer --- fftools/ffmpeg.c| 11 +++ fftools/ffmpeg.h| 1 + fftools/ffmpeg_filter.c | 1 + fftools/ffmpeg_opt.c| 4 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 7beea11933..6aa0986f02 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2733,7 +2733,9 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo } ist->pts = ist->dts; ist->next_pts = ist->next_dts; -} +} else if (!ist->decoding_needed) +eof_reached = 1; + for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; @@ -4213,11 +4215,12 @@ static int process_input(int file_index) for (i = 0; i < ifile->nb_streams; i++) { ist = input_streams[ifile->ist_index + i]; avctx = ist->dec_ctx; -if (ist->decoding_needed) { +if (ist->processing_needed) { ret = process_input_packet(ist, NULL, 1); if (ret>0) return 0; -avcodec_flush_buffers(avctx); +if (ist->decoding_needed) +avcodec_flush_buffers(avctx); } } #if HAVE_THREADS @@ -4247,7 +4250,7 @@ static int process_input(int file_index) for (i = 0; i < ifile->nb_streams; i++) { ist = input_streams[ifile->ist_index + i]; -if (ist->decoding_needed) { +if (ist->processing_needed) { ret = process_input_packet(ist, NULL, 0); if (ret>0) return 0; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 81ec4d5970..1b8bbace3f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -307,6 +307,7 @@ typedef struct InputStream { int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */ #define DECODING_FOR_OST1 #define DECODING_FOR_FILTER 2 +int processing_needed; /* non zero if the packets must be processed */ AVCodecContext *dec_ctx; const AVCodec *dec; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 41d87377c7..8ec1f0ffaf 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -277,6 +277,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) ist->discard = 0; ist->decoding_needed |= DECODING_FOR_FILTER; +ist->processing_needed = 1; ist->st->discard = AVDISCARD_NONE; ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 3102851885..bf1bbcae4c 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2610,6 +2610,7 @@ loop_end: if (ost->encoding_needed && ost->source_index >= 0) { InputStream *ist = input_streams[ost->source_index]; ist->decoding_needed |= DECODING_FOR_OST; +ist->processing_needed = 1; if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { @@ -2622,6 +2623,9 @@ loop_end: exit_program(1); } } +} else if (ost->stream_copy && ost->source_index >= 0) { +InputStream *ist = input_streams[ost->source_index]; +ist->processing_needed = 1; } /* set the filter output constraints */ -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/6] avcodec/bsf: add a capabilities field to AVBitStreamFilter
And a first flag to signal that the bsf buffers packets and needs to be drained Signed-off-by: James Almer --- Missing APIChanges entry and version bump. libavcodec/bsf.h | 12 1 file changed, 12 insertions(+) diff --git a/libavcodec/bsf.h b/libavcodec/bsf.h index 8c5355d186..798c6470ee 100644 --- a/libavcodec/bsf.h +++ b/libavcodec/bsf.h @@ -87,6 +87,12 @@ typedef struct AVBSFContext { AVRational time_base_out; } AVBSFContext; +/** + * The bitstream filter requires flushing with NULL input at the end in order + * to drain all buffered packets and give the complete and correct output. + */ +#define AV_BSF_CAP_DELAY (1 << 0) + typedef struct AVBitStreamFilter { const char *name; @@ -108,6 +114,12 @@ typedef struct AVBitStreamFilter { */ const AVClass *priv_class; +/** + * Filter capabilities. + * see AV_BSF_CAP_* + */ +int capabilities; + /* * No fields below this line are part of the public API. They * may not be used outside of libavcodec and can be changed and -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/6] avcodec/bsf: set delay capability on the list filter
AVBitStreamFilter structures are const, so we can't set its capabilities based on the filters added to the list. Set the delay cap to ensure correct behavior if any bsf in the list sets it. Signed-off-by: James Almer --- libavcodec/bsf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index 8ba021cb47..a78495 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -406,6 +406,7 @@ static const AVBitStreamFilter list_bsf = { .filter = bsf_list_filter, .flush = bsf_list_flush, .close = bsf_list_close, +.capabilities = AV_BSF_CAP_DELAY, }; struct AVBSFList { -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/6] ffmpeg: don't skip packets before a keyframe was seen if a bsf with delay is used
A keyframe could be buffered in the bsf and not be output until more packets had been fed to it. Signed-off-by: James Almer --- fftools/ffmpeg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6aa0986f02..48d9016b4c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2026,7 +2026,8 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p } if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && -!ost->copy_initial_nonkeyframes) +!ost->copy_initial_nonkeyframes && +!(ost->bsf_ctx && ost->bsf_ctx->filter->capabilities & AV_BSF_CAP_DELAY)) return; if (!ost->frame_number && !ost->copy_prior_start) { -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/6] avcodec/setts_bsf: add NEXT_PTS/DTS expression constants
They correspond to the relevant fields in the packet that follows the one where the expressions are being applied to. Signed-off-by: James Almer --- Missing doc changes. libavcodec/setts_bsf.c | 76 -- 1 file changed, 51 insertions(+), 25 deletions(-) diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c index d604f91f71..35266ee251 100644 --- a/libavcodec/setts_bsf.c +++ b/libavcodec/setts_bsf.c @@ -37,6 +37,8 @@ static const char *const var_names[] = { "PREV_INDTS", ///< previous input DTS "PREV_OUTPTS", ///< previous output PTS "PREV_OUTDTS", ///< previous output DTS +"NEXT_PTS",///< next input PTS +"NEXT_DTS",///< next input DTS "PTS", ///< original PTS in the file of the frame "DTS", ///< original DTS in the file of the frame "STARTPTS",///< PTS at start of movie @@ -55,6 +57,8 @@ enum var_name { VAR_PREV_INDTS, VAR_PREV_OUTPTS, VAR_PREV_OUTDTS, +VAR_NEXT_PTS, +VAR_NEXT_DTS, VAR_PTS, VAR_DTS, VAR_STARTPTS, @@ -76,16 +80,16 @@ typedef struct SetTSContext { int64_t start_pts; int64_t start_dts; -int64_t prev_inpts; -int64_t prev_indts; -int64_t prev_outpts; -int64_t prev_outdts; double var_values[VAR_VARS_NB]; AVExpr *ts_expr; AVExpr *pts_expr; AVExpr *dts_expr; + +AVPacket *prev_inpkt; +AVPacket *prev_outpkt; +AVPacket *cur_pkt; } SetTSContext; static int setts_init(AVBSFContext *ctx) @@ -93,6 +97,12 @@ static int setts_init(AVBSFContext *ctx) SetTSContext *s = ctx->priv_data; int ret; +s->prev_inpkt = av_packet_alloc(); +s->prev_outpkt = av_packet_alloc(); +s->cur_pkt = av_packet_alloc(); +if (!s->prev_inpkt || !s->prev_outpkt || !s->cur_pkt) +return AVERROR(ENOMEM); + if ((ret = av_expr_parse(&s->ts_expr, s->ts_str, var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) { av_log(ctx, AV_LOG_ERROR, "Error while parsing ts expression '%s'\n", s->ts_str); @@ -118,10 +128,6 @@ static int setts_init(AVBSFContext *ctx) s->frame_number= 0; s->start_pts = AV_NOPTS_VALUE; s->start_dts = AV_NOPTS_VALUE; -s->prev_inpts = AV_NOPTS_VALUE; -s->prev_indts = AV_NOPTS_VALUE; -s->prev_outpts = AV_NOPTS_VALUE; -s->prev_outdts = AV_NOPTS_VALUE; s->var_values[VAR_NOPTS] = AV_NOPTS_VALUE; return 0; @@ -134,24 +140,31 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt) int ret; ret = ff_bsf_get_packet_ref(ctx, pkt); -if (ret < 0) +if (ret < 0 && (ret != AVERROR_EOF || !s->cur_pkt->data)) return ret; +if (!s->cur_pkt->data) { + av_packet_move_ref(s->cur_pkt, pkt); + return AVERROR(EAGAIN); +} + if (s->start_pts == AV_NOPTS_VALUE) -s->start_pts = pkt->pts; +s->start_pts = s->cur_pkt->pts; if (s->start_dts == AV_NOPTS_VALUE) -s->start_dts = pkt->dts; +s->start_dts = s->cur_pkt->dts; s->var_values[VAR_N] = s->frame_number++; -s->var_values[VAR_TS] = pkt->dts; -s->var_values[VAR_POS] = pkt->pos; -s->var_values[VAR_PTS] = pkt->pts; -s->var_values[VAR_DTS] = pkt->dts; -s->var_values[VAR_PREV_INPTS] = s->prev_inpts; -s->var_values[VAR_PREV_INDTS] = s->prev_indts; -s->var_values[VAR_PREV_OUTPTS] = s->prev_outpts; -s->var_values[VAR_PREV_OUTDTS] = s->prev_outdts; +s->var_values[VAR_TS] = s->cur_pkt->dts; +s->var_values[VAR_POS] = s->cur_pkt->pos; +s->var_values[VAR_PTS] = s->cur_pkt->pts; +s->var_values[VAR_DTS] = s->cur_pkt->dts; +s->var_values[VAR_PREV_INPTS] = s->prev_inpkt->pts; +s->var_values[VAR_PREV_INDTS] = s->prev_inpkt->dts; +s->var_values[VAR_PREV_OUTPTS] = s->prev_outpkt->pts; +s->var_values[VAR_PREV_OUTDTS] = s->prev_outpkt->dts; +s->var_values[VAR_NEXT_PTS]= pkt->pts; +s->var_values[VAR_NEXT_DTS]= pkt->dts; s->var_values[VAR_STARTPTS]= s->start_pts; s->var_values[VAR_STARTDTS]= s->start_dts; s->var_values[VAR_TB] = ctx->time_base_out.den ? av_q2d(ctx->time_base_out) : 0; @@ -160,27 +173,35 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt) new_ts = llrint(av_expr_eval(s->ts_expr, s->var_values, NULL)); if (s->pts_str) { -s->var_values[VAR_TS] = pkt->pts; +s->var_values[VAR_TS] = s->cur_pkt->pts; new_pts = llrint(av_expr_eval(s->pts_expr, s->var_values, NULL)); } else { new_pts = new_ts; } if (s->dts_str) { -s->var_values[VAR_TS] = pkt->dts; +s->var_values[VAR_TS] = s->cur_pkt->dts; new_dts = llrint(av_expr_eval(s->dts_expr, s->var_values, NULL)); } else { new_dts = new_ts; } -s->prev_inpts = pkt->pts; -s->prev_indts = pkt->dts; -s->prev_outpts
[FFmpeg-devel] [PATCH 6/6] avcodec/setts_bsf: add constants to modify packet duration
Signed-off-by: James Almer --- Missing doc changes. libavcodec/setts_bsf.c | 25 - 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c index 35266ee251..46f9a30103 100644 --- a/libavcodec/setts_bsf.c +++ b/libavcodec/setts_bsf.c @@ -35,12 +35,16 @@ static const char *const var_names[] = { "POS", ///< original position in the file of the frame "PREV_INPTS", ///< previous input PTS "PREV_INDTS", ///< previous input DTS +"PREV_INDURATION", ///< previous input duration "PREV_OUTPTS", ///< previous output PTS "PREV_OUTDTS", ///< previous output DTS +"PREV_OUTDURATION", ///< previous output duration "NEXT_PTS",///< next input PTS "NEXT_DTS",///< next input DTS +"NEXT_DURATION", ///< next input duration "PTS", ///< original PTS in the file of the frame "DTS", ///< original DTS in the file of the frame +"DURATION",///< original duration in the file of the frame "STARTPTS",///< PTS at start of movie "STARTDTS",///< DTS at start of movie "TB", ///< timebase of the stream @@ -55,12 +59,16 @@ enum var_name { VAR_POS, VAR_PREV_INPTS, VAR_PREV_INDTS, +VAR_PREV_INDUR, VAR_PREV_OUTPTS, VAR_PREV_OUTDTS, +VAR_PREV_OUTDUR, VAR_NEXT_PTS, VAR_NEXT_DTS, +VAR_NEXT_DUR, VAR_PTS, VAR_DTS, +VAR_DURATION, VAR_STARTPTS, VAR_STARTDTS, VAR_TB, @@ -75,6 +83,7 @@ typedef struct SetTSContext { char *ts_str; char *pts_str; char *dts_str; +char *duration_str; int64_t frame_number; @@ -86,6 +95,7 @@ typedef struct SetTSContext { AVExpr *ts_expr; AVExpr *pts_expr; AVExpr *dts_expr; +AVExpr *duration_expr; AVPacket *prev_inpkt; AVPacket *prev_outpkt; @@ -109,6 +119,12 @@ static int setts_init(AVBSFContext *ctx) return ret; } +if ((ret = av_expr_parse(&s->duration_expr, s->duration_str, + var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) { +av_log(ctx, AV_LOG_ERROR, "Error while parsing duration expression '%s'\n", s->duration_str); +return ret; +} + if (s->pts_str) { if ((ret = av_expr_parse(&s->pts_expr, s->pts_str, var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) { @@ -136,7 +152,7 @@ static int setts_init(AVBSFContext *ctx) static int setts_filter(AVBSFContext *ctx, AVPacket *pkt) { SetTSContext *s = ctx->priv_data; -int64_t new_ts, new_pts, new_dts; +int64_t new_ts, new_pts, new_dts, new_duration; int ret; ret = ff_bsf_get_packet_ref(ctx, pkt); @@ -159,18 +175,23 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt) s->var_values[VAR_POS] = s->cur_pkt->pos; s->var_values[VAR_PTS] = s->cur_pkt->pts; s->var_values[VAR_DTS] = s->cur_pkt->dts; +s->var_values[VAR_DURATION]= s->cur_pkt->duration; s->var_values[VAR_PREV_INPTS] = s->prev_inpkt->pts; s->var_values[VAR_PREV_INDTS] = s->prev_inpkt->dts; +s->var_values[VAR_PREV_INDUR] = s->prev_inpkt->duration; s->var_values[VAR_PREV_OUTPTS] = s->prev_outpkt->pts; s->var_values[VAR_PREV_OUTDTS] = s->prev_outpkt->dts; +s->var_values[VAR_PREV_OUTDUR] = s->prev_outpkt->duration; s->var_values[VAR_NEXT_PTS]= pkt->pts; s->var_values[VAR_NEXT_DTS]= pkt->dts; +s->var_values[VAR_NEXT_DUR]= pkt->duration; s->var_values[VAR_STARTPTS]= s->start_pts; s->var_values[VAR_STARTDTS]= s->start_dts; s->var_values[VAR_TB] = ctx->time_base_out.den ? av_q2d(ctx->time_base_out) : 0; s->var_values[VAR_SR] = ctx->par_in->sample_rate; new_ts = llrint(av_expr_eval(s->ts_expr, s->var_values, NULL)); +new_duration = llrint(av_expr_eval(s->duration_expr, s->var_values, NULL)); if (s->pts_str) { s->var_values[VAR_TS] = s->cur_pkt->pts; @@ -197,6 +218,7 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt) pkt->pts = new_pts; pkt->dts = new_dts; +pkt->duration = new_duration; ret = av_packet_ref(s->prev_outpkt, pkt); if (ret < 0) @@ -228,6 +250,7 @@ static const AVOption options[] = { { "ts", "set expression for packet PTS and DTS", OFFSET(ts_str), AV_OPT_TYPE_STRING, {.str="TS"}, 0, 0, FLAGS }, { "pts", "set expression for packet PTS", OFFSET(pts_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, { "dts", "set expression for packet DTS", OFFSET(dts_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, +{ "duration", "set expression for packet duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str="DURATION"}, 0, 0, FLAGS }, { NULL }, }; -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-de
[FFmpeg-devel] [PATCH 1/4] avutil: add support for CUVA HDR Vivid metadata
From: Limin Wang Signed-off-by: Limin Wang --- libavutil/Makefile | 2 + libavutil/frame.c | 1 + libavutil/frame.h | 7 + libavutil/hdr_dynamic_vivid_metadata.c | 47 ++ libavutil/hdr_dynamic_vivid_metadata.h | 285 + libavutil/version.h| 2 +- 6 files changed, 343 insertions(+), 1 deletion(-) create mode 100644 libavutil/hdr_dynamic_vivid_metadata.c create mode 100644 libavutil/hdr_dynamic_vivid_metadata.h diff --git a/libavutil/Makefile b/libavutil/Makefile index d17876d..a8d7587 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -34,6 +34,7 @@ HEADERS = adler32.h \ frame.h \ hash.h\ hdr_dynamic_metadata.h\ + hdr_dynamic_vivid_metadata.h \ hmac.h\ hwcontext.h \ hwcontext_cuda.h \ @@ -130,6 +131,7 @@ OBJS = adler32.o \ frame.o \ hash.o \ hdr_dynamic_metadata.o \ + hdr_dynamic_vivid_metadata.o \ hmac.o \ hwcontext.o \ imgutils.o \ diff --git a/libavutil/frame.c b/libavutil/frame.c index 8997c85..b035e28 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -723,6 +723,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) case AV_FRAME_DATA_SPHERICAL: return "Spherical Mapping"; case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile"; case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata SMPTE2094-40 (HDR10+)"; +case AV_FRAME_DATA_DYNAMIC_HDR_VIVID: return "HDR Dynamic Metadata CUVA 005.1 2021 (Vivid)"; case AV_FRAME_DATA_REGIONS_OF_INTEREST: return "Regions Of Interest"; case AV_FRAME_DATA_VIDEO_ENC_PARAMS:return "Video encoding parameters"; case AV_FRAME_DATA_SEI_UNREGISTERED:return "H.26[45] User Data Unregistered SEI message"; diff --git a/libavutil/frame.h b/libavutil/frame.h index 18e239f..32cde3c 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -158,6 +158,13 @@ enum AVFrameSideDataType { AV_FRAME_DATA_DYNAMIC_HDR_PLUS, /** + * HDR Vivid dynamic metadata associated with a video frame. The payload is + * an AVDynamicHDRVivid type and contains information for color + * volume transform - CUVA 005.1-2021. + */ +AV_FRAME_DATA_DYNAMIC_HDR_VIVID, + +/** * Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of * array element is implied by AVFrameSideData.size / AVRegionOfInterest.self_size. */ diff --git a/libavutil/hdr_dynamic_vivid_metadata.c b/libavutil/hdr_dynamic_vivid_metadata.c new file mode 100644 index 000..32da01f --- /dev/null +++ b/libavutil/hdr_dynamic_vivid_metadata.c @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2021 Limin Wang + * + * 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 "hdr_dynamic_vivid_metadata.h" +#include "mem.h" + +AVDynamicHDRVivid *av_dynamic_hdr_vivid_alloc(size_t *size) +{ +AVDynamicHDRVivid *hdr_vivid = av_mallocz(sizeof(AVDynamicHDRVivid)); +if (!hdr_vivid) +return NULL; + +if (size) +*size = sizeof(*hdr_vivid); + +return hdr_vivid; +} + +AVDynamicHDRVivid *av_dynamic_hdr_vivid_create_side_data(AVFrame *frame) +{ +AVFrameSideData *side_data = av_frame_new_side_data(frame, + AV_FRAME_D
[FFmpeg-devel] [PATCH 2/4] avcodec: support for CUVA HDR Vivid metadata
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/Makefile| 2 +- libavcodec/dynamic_hdr_vivid.c | 139 + libavcodec/dynamic_hdr_vivid.h | 35 +++ libavcodec/hevc_sei.c | 48 +- libavcodec/hevc_sei.h | 5 ++ libavcodec/hevcdec.c | 15 + 6 files changed, 241 insertions(+), 3 deletions(-) create mode 100644 libavcodec/dynamic_hdr_vivid.c create mode 100644 libavcodec/dynamic_hdr_vivid.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index cfc70a3..1910137 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -96,7 +96,7 @@ OBJS-$(CONFIG_H264PARSE) += h264_parse.o h2645_parse.o h264_ps.o OBJS-$(CONFIG_H264PRED)+= h264pred.o OBJS-$(CONFIG_H264QPEL)+= h264qpel.o OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o h2645_parse.o hevc_ps.o hevc_sei.o hevc_data.o \ - dynamic_hdr10_plus.o + dynamic_hdr10_plus.o dynamic_hdr_vivid.o OBJS-$(CONFIG_HPELDSP) += hpeldsp.o OBJS-$(CONFIG_HUFFMAN) += huffman.o OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c new file mode 100644 index 000..7d0bd43 --- /dev/null +++ b/libavcodec/dynamic_hdr_vivid.c @@ -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 + */ + +#include "dynamic_hdr_vivid.h" +#include "get_bits.h" + +static const int32_t maxrgb_den = 4095; +static const int32_t color_saturation_gain_den = 128; +static const int32_t maximum_luminance_den = 4095; +static const int32_t base_param_m_p_den = 16383; +static const int32_t base_param_m_m_den = 10; +static const int32_t base_param_m_a_den = 1023; +static const int32_t base_param_m_b_den = 1023; +static const int32_t base_param_m_n_den = 10; +static const int32_t base_param_Delta_den = 127; + +int ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t *data, + int size) +{ +GetBitContext gbc, *gb = &gbc; +int ret; + +if (!s) +return AVERROR(ENOMEM); + +ret = init_get_bits8(gb, data, size); +if (ret < 0) +return ret; + +if (get_bits_left(gb) < 8) +return AVERROR_INVALIDDATA; + +s->system_start_code = get_bits(gb, 8); +if (s->system_start_code == 0x01) { +s->num_windows = 1; + +if (get_bits_left(gb) < 12 * 4 * s->num_windows) +return AVERROR_INVALIDDATA; +for (int w = 0; w < s->num_windows; w++) { +AVHDRVividColorTransformParams *params = &s->params[w]; + +params->minimum_maxrgb = (AVRational){get_bits(gb, 12), maxrgb_den}; +params->average_maxrgb = (AVRational){get_bits(gb, 12), maxrgb_den}; +params->variance_maxrgb = (AVRational){get_bits(gb, 12), maxrgb_den}; +params->maximum_maxrgb = (AVRational){get_bits(gb, 12), maxrgb_den}; +} + +if (get_bits_left(gb) < 2 * s->num_windows) +return AVERROR_INVALIDDATA; +for (int w = 0; w < s->num_windows; w++) { +AVHDRVividColorTransformParams *params = &s->params[w]; + +params->tone_mapping_mode_flag = get_bits(gb, 1); +if (params->tone_mapping_mode_flag) { +if (get_bits_left(gb) < 1 ) +return AVERROR_INVALIDDATA; +params->tone_mapping_param_num = get_bits(gb, 1) + 1; +for (int i = 0; i < params->tone_mapping_param_num; i++) { +AVHDRVividColorToneMappingParams *tm_params = ¶ms->tm_params[i]; + +if (get_bits_left(gb) < 13) +return AVERROR_INVALIDDATA; +tm_params->targeted_system_display_maximum_luminance = (AVRational){get_bits(gb, 12), maximum_luminance_den}; +tm_params->base_enable_flag = get_bits(gb, 1); +if (tm_params->base_enable_flag) { +if (get_bits_left(gb) < (14 + 6 + 10 + 10 + 6 + 8 + 10)) +return AVERROR_INVALIDDATA; +
[FFmpeg-devel] [PATCH 3/4] avfilter: support for CUVA HDR Vivid metadata
From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_showinfo.c | 86 +++ 1 file changed, 86 insertions(+) diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index 71728bc..bee84b2 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -32,6 +32,7 @@ #include "libavutil/internal.h" #include "libavutil/film_grain_params.h" #include "libavutil/hdr_dynamic_metadata.h" +#include "libavutil/hdr_dynamic_vivid_metadata.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/spherical.h" @@ -307,6 +308,88 @@ static void dump_dynamic_hdr_plus(AVFilterContext *ctx, AVFrameSideData *sd) } } +static void dump_dynamic_hdr_vivid(AVFilterContext *ctx, AVFrameSideData *sd) +{ +AVDynamicHDRVivid *hdr_vivid; + +av_log(ctx, AV_LOG_INFO, "HDR Vivid metadata: "); +if (sd->size < sizeof(*hdr_vivid)) { +av_log(ctx, AV_LOG_ERROR, "invalid hdr vivid data\n"); +return; +} + +hdr_vivid = (AVDynamicHDRVivid *)sd->data; +av_log(ctx, AV_LOG_INFO, "system_start_code: %d, ", hdr_vivid->system_start_code); +av_log(ctx, AV_LOG_INFO, "num_windows: %d, ", hdr_vivid->num_windows); +for (int w = 0; w < hdr_vivid->num_windows; w++) { +const AVHDRVividColorTransformParams *params = &hdr_vivid->params[w]; + +av_log(ctx, AV_LOG_INFO, "minimum_maxrgb[%d]: %.4f, ", w, av_q2d(params->minimum_maxrgb)); +av_log(ctx, AV_LOG_INFO, "average_maxrgb[%d]: %.4f, ", w, av_q2d(params->average_maxrgb)); +av_log(ctx, AV_LOG_INFO, "variance_maxrgb[%d]:%.4f, ", w, av_q2d(params->variance_maxrgb)); +av_log(ctx, AV_LOG_INFO, "maximum_maxrgb[%d]: %.4f, ", w, av_q2d(params->maximum_maxrgb)); +} + +for (int w = 0; w < hdr_vivid->num_windows; w++) { +const AVHDRVividColorTransformParams *params = &hdr_vivid->params[w]; + +av_log(ctx, AV_LOG_INFO, "tone_mapping_mode_flag[%d]: %d, ", w, params->tone_mapping_mode_flag); +av_log(ctx, AV_LOG_INFO, "tone_mapping_param_num[%d]: %d, ", w, params->tone_mapping_param_num); +if (params->tone_mapping_mode_flag) { +for (int i = 0; i < params->tone_mapping_param_num; i++) { +const AVHDRVividColorToneMappingParams *tm_params = ¶ms->tm_params[i]; + +av_log(ctx, AV_LOG_INFO, "targeted_system_display_maximum_luminance[%d][%d]: %.4f, ", + w, i, av_q2d(tm_params->targeted_system_display_maximum_luminance)); +av_log(ctx, AV_LOG_INFO, "base_enable_flag[%d][%d]: %d, ", + w, i, tm_params->base_enable_flag); +if (tm_params->base_enable_flag) { +av_log(ctx, AV_LOG_INFO, "base_param_m_p[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_m_p)); +av_log(ctx, AV_LOG_INFO, "base_param_m_m[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_m_m)); +av_log(ctx, AV_LOG_INFO, "base_param_m_a[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_m_a)); +av_log(ctx, AV_LOG_INFO, "base_param_m_b[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_m_b)); +av_log(ctx, AV_LOG_INFO, "base_param_m_n[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_m_n)); +av_log(ctx, AV_LOG_INFO, "base_param_k1[%d][%d]: %d, ", w, i, tm_params->base_param_k1); +av_log(ctx, AV_LOG_INFO, "base_param_k2[%d][%d]: %d, ", w, i, tm_params->base_param_k2); +av_log(ctx, AV_LOG_INFO, "base_param_k3[%d][%d]: %d, ", w, i, tm_params->base_param_k3); +av_log(ctx, AV_LOG_INFO, "base_param_Delta_enable_mode[%d][%d]: %d, ", w, i, + tm_params->base_param_Delta_enable_mode); +av_log(ctx, AV_LOG_INFO, "base_param_Delta[%d][%d]: %.4f, ", w, i, av_q2d(tm_params->base_param_Delta)); +} +if (tm_params->three_Spline_flag) { +av_log(ctx, AV_LOG_INFO, "3Spline_flag[%d][%d]: %d, ", w, i, tm_params->three_Spline_flag); +av_log(ctx, AV_LOG_INFO, "3Spline_TH_mode[%d][%d]: %d, ", w, i, tm_params->three_Spline_TH_mode); + +for (int j = 0; j < tm_params->three_Spline_num; j++) { +av_log(ctx, AV_LOG_INFO, "3Spline_TH_enable_MB[%d][%d][%d]: %.4f, ", +w, i, j, av_q2d(tm_params->three_Spline_TH_enable_MB)); +av_log(ctx, AV_LOG_INFO, "3Spline_TH[%d][%d][%d]: %.4f, ", +w, i, j, av_q2d(tm_params->three_Spline_TH)); +av_log(ctx, AV_LOG_INFO, "3Spline_TH_Delta1[%d][%d][%d]: %.4f, ", +w, i, j, av_q2d(tm_params->three_Spline_TH_Delta1)); +av_log(ctx, AV_LOG_INFO, "3Spline_TH_Delta2[%d][%d][%d]: %.4f, ", +
[FFmpeg-devel] [PATCH 4/4] fftool/ffprobe: support for CUVA HDR Vivid metadata
From: Limin Wang Signed-off-by: Limin Wang --- fftools/ffprobe.c | 70 +++ 1 file changed, 70 insertions(+) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 8a8e3de..0e8f1d5 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -38,6 +38,7 @@ #include "libavutil/hash.h" #include "libavutil/hdr_dynamic_metadata.h" #include "libavutil/mastering_display_metadata.h" +#include "libavutil/hdr_dynamic_vivid_metadata.h" #include "libavutil/dovi_meta.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" @@ -2118,6 +2119,72 @@ static void print_dynamic_hdr10_plus(WriterContext *w, const AVDynamicHDRPlus *m } } +static void print_dynamic_hdr_vivid(WriterContext *w, const AVDynamicHDRVivid *metadata) +{ +if (!metadata) +return; +print_int("system_start_code", metadata->system_start_code); +print_int("num_windows", metadata->num_windows); + +for (int n = 0; n < metadata->num_windows; n++) { +const AVHDRVividColorTransformParams *params = &metadata->params[n]; + +print_q("minimum_maxrgb", params->minimum_maxrgb, '/'); +print_q("average_maxrgb", params->average_maxrgb, '/'); +print_q("variance_maxrgb", params->variance_maxrgb, '/'); +print_q("maximum_maxrgb", params->maximum_maxrgb, '/'); +} + +for (int n = 0; n < metadata->num_windows; n++) { +const AVHDRVividColorTransformParams *params = &metadata->params[n]; + +print_int("tone_mapping_mode_flag", params->tone_mapping_mode_flag); +print_int("tone_mapping_param_num", params->tone_mapping_param_num); +if (params->tone_mapping_mode_flag) { +for (int i = 0; i < params->tone_mapping_param_num; i++) { +const AVHDRVividColorToneMappingParams *tm_params = ¶ms->tm_params[i]; + +print_q("targeted_system_display_maximum_luminance", +tm_params->targeted_system_display_maximum_luminance, '/'); +if (tm_params->base_enable_flag) { +print_q("base_param_m_p", tm_params->base_param_m_p, '/'); +print_q("base_param_m_m", tm_params->base_param_m_m, '/'); +print_q("base_param_m_a", tm_params->base_param_m_a, '/'); +print_q("base_param_m_b", tm_params->base_param_m_b, '/'); +print_q("base_param_m_n", tm_params->base_param_m_n, '/'); + +print_int("base_param_k1", tm_params->base_param_k1); +print_int("base_param_k2", tm_params->base_param_k2); +print_int("base_param_k3", tm_params->base_param_k3); +print_int("base_param_Delta_enable_mode", + tm_params->base_param_Delta_enable_mode); +print_q("base_param_Delta", tm_params->base_param_Delta, '/'); +} +if (tm_params->three_Spline_flag) { +print_int("3Spline_num", tm_params->three_Spline_num); +print_int("3Spline_TH_mode", tm_params->three_Spline_TH_mode); + +for (int j = 0; j < tm_params->three_Spline_num; j++) { +print_q("3Spline_TH_enable_MB", tm_params->three_Spline_TH_enable_MB, '/'); +print_q("3Spline_TH", tm_params->three_Spline_TH, '/'); +print_q("3Spline_TH_Delta1", tm_params->three_Spline_TH_Delta1, '/'); +print_q("3Spline_TH_Delta2", tm_params->three_Spline_TH_Delta2, '/'); +print_q("3Spline_enable_Strength", tm_params->three_Spline_enable_Strength, '/'); +} +} +} +} + +print_int("color_saturation_mapping_flag", params->color_saturation_mapping_flag); +if (params->color_saturation_mapping_flag) { +print_int("color_saturation_num", params->color_saturation_num); +for (int i = 0; i < params->color_saturation_num; i++) { +print_q("color_saturation_gain", params->color_saturation_gain[i], '/'); +} +} +} +} + static void print_pkt_side_data(WriterContext *w, AVCodecParameters *par, const AVPacketSideData *side_data, @@ -2537,6 +2604,9 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, print_int("size", sd->size); } else if (sd->type == AV_FRAME_DATA_DOVI_METADATA) { print_dovi_metadata(w, (const AVDOVIMetadata *)sd->data); +} else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) { +AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data; +print_dynamic_hdr_vivid(w, metadata); } writer_print_section_footer(w); } -- 1.8.3.1 _
Re: [FFmpeg-devel] [PATCH 4/4] avformat: add Argonaut Games CVG muxer
On 15/2/22 05:32, Michael Niedermayer wrote: +static int argo_cvg_write_trailer(AVFormatContext *s) +{ +ArgoCVGMuxContext *ctx = s->priv_data; +int64_t ret; + +av_log(s, AV_LOG_TRACE, "size = %zu\n", ctx->size); +av_log(s, AV_LOG_TRACE, "checksum = %u\n", ctx->checksum); + +/* + * NB: This is wrong. We're always slightly under the original. + * Verified by remuxing. For reference (orig - remuxed): + * - TCLD.CVG: 4706074 - 4705696 = 378 + * - DANLOOP1.CVG: 5684641 - 5684212 = 429 + * - CRYS.CVG: 2495499 - 2495367 = 132 + * - PICKUP88.CVG: 1348091 - 1347937 = 154 + * - SELECT1.CVG: 549987 - 549752 = 235 Are these files available somewhere ? Yup, here you go: https://0x0.st/o8NK.xz That's a .tar.xz, the extension was stripped. Zane ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Optimize HEVC decoding for loongarch
> 2022年2月14日 下午4:25,Hao Chen 写道: > > ffmpeg -i 5_h265_1080p_60fps_3Mbps.mkv -f rawvideo -y /dev/null -an > before: 94fps > after : 191fps > > [PATCH v1 1/5] avutil: [loongarch] Update loongson_intrinsics.h to > [PATCH v1 2/5] avcodec: [loongarch] Optimize Hevcdsp with LSX. > [PATCH v1 3/5] avcodec: [loongarch] Optimize Hevc_idct/lpf with LSX. > [PATCH v1 4/5] avcodec: [loongarch] Optimize Hevc_mc_bi with LSX. > [PATCH v1 5/5] avcodec: [loongarch] Optimize Hevc_mc_uni/w with LSX. > LGTM ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavcodec/qsvenc_hevc: encode RGB format rawvideo
> Wenbin Chen: > > Add support for hevc_qsv to input RGB format frame. It will > > transform frame to yuv inside MediaSDK instead of using auto > > scale. Now hevc_qsv supports directly encoding BGRA and X2RGB10 > > format. X2RGB10 is only supported in VDENC (-low_power 1). > > The X2RGB10 correspond to the A2RGB20 format in MediaSDK. > > > > Sigend-off-by: Wenbin Chen > ^ > Are you writing this manually? I always thought it is manually writing. I just searched and found that there is a "-s" option. Will fix this. Thanks for your reminder. > > - Andreas > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] libavcodec/qsvenc_hevc: encode RGB format rawvideo
Add support for hevc_qsv to input RGB format frame. It will transform frame to yuv inside MediaSDK instead of using auto scale. Now hevc_qsv supports directly encoding BGRA and X2RGB10 format. X2RGB10 is only supported in VDENC (-low_power 1). The X2RGB10 correspond to the A2RGB20 format in MediaSDK. Signed-off-by: Wenbin Chen --- libavcodec/qsv.c | 16 libavcodec/qsvenc.c | 13 + libavcodec/qsvenc_hevc.c | 6 ++ 3 files changed, 35 insertions(+) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 1a432dbd82..b75877e698 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -189,6 +189,12 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc) case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12; case MFX_FOURCC_P010: return AV_PIX_FMT_P010; case MFX_FOURCC_P8: return AV_PIX_FMT_PAL8; +#if QSV_VERSION_ATLEAST(1, 9) +case MFX_FOURCC_A2RGB10: return AV_PIX_FMT_X2RGB10; +#endif +#if QSV_VERSION_ATLEAST(1, 17) +case MFX_FOURCC_RGB4: return AV_PIX_FMT_BGRA; +#endif #if CONFIG_VAAPI case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422; #if QSV_VERSION_ATLEAST(1, 27) @@ -211,6 +217,16 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc) case AV_PIX_FMT_P010: *fourcc = MFX_FOURCC_P010; return AV_PIX_FMT_P010; +#if QSV_VERSION_ATLEAST(1, 9) +case AV_PIX_FMT_X2RGB10: +*fourcc = MFX_FOURCC_A2RGB10; +return AV_PIX_FMT_X2RGB10; +#endif +#if QSV_VERSION_ATLEAST(1, 17) +case AV_PIX_FMT_BGRA: +*fourcc = MFX_FOURCC_RGB4; +return AV_PIX_FMT_BGRA; +#endif #if CONFIG_VAAPI case AV_PIX_FMT_YUV422P: case AV_PIX_FMT_YUYV422: diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 07be4287b7..104133fc59 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -715,6 +715,11 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) if (ret < 0) return AVERROR_BUG; +if (sw_format == AV_PIX_FMT_X2RGB10 && q->low_power != 1) { +av_log(avctx, AV_LOG_ERROR, "Only VDENC support encoding x2rgb10\n"); +return AVERROR(EINVAL); +} + q->param.mfx.FrameInfo.CropX = 0; q->param.mfx.FrameInfo.CropY = 0; q->param.mfx.FrameInfo.CropW = avctx->width; @@ -1616,6 +1621,14 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame, qf->surface.Data.V = qf->surface.Data.UV + 2; break; +case AV_PIX_FMT_X2RGB10: +case AV_PIX_FMT_BGRA: +qf->surface.Data.B = qf->frame->data[0]; +qf->surface.Data.G = qf->frame->data[0] + 1; +qf->surface.Data.R = qf->frame->data[0] + 2; +qf->surface.Data.A = qf->frame->data[0] + 3; +break; + default: /* should not reach here */ av_assert0(0); diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 5cac141c4d..ade546d4ca 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -304,6 +304,12 @@ const AVCodec ff_hevc_qsv_encoder = { .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, AV_PIX_FMT_P010, AV_PIX_FMT_QSV, +#if QSV_VERSION_ATLEAST(1, 17) +AV_PIX_FMT_BGRA, +#endif +#if QSV_VERSION_ATLEAST(1, 9) +AV_PIX_FMT_X2RGB10, +#endif AV_PIX_FMT_NONE }, .priv_class = &class, .defaults = qsv_enc_defaults, -- 2.32.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] avutil: add support for CUVA HDR Vivid metadata
lance.lmw...@gmail.com: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavutil/Makefile | 2 + > libavutil/frame.c | 1 + > libavutil/frame.h | 7 + > libavutil/hdr_dynamic_vivid_metadata.c | 47 ++ > libavutil/hdr_dynamic_vivid_metadata.h | 285 > + > libavutil/version.h| 2 +- > 6 files changed, 343 insertions(+), 1 deletion(-) > create mode 100644 libavutil/hdr_dynamic_vivid_metadata.c > create mode 100644 libavutil/hdr_dynamic_vivid_metadata.h > > diff --git a/libavutil/Makefile b/libavutil/Makefile > index d17876d..a8d7587 100644 > --- a/libavutil/Makefile > +++ b/libavutil/Makefile > @@ -34,6 +34,7 @@ HEADERS = adler32.h > \ >frame.h \ >hash.h\ >hdr_dynamic_metadata.h\ > + hdr_dynamic_vivid_metadata.h \ >hmac.h\ >hwcontext.h \ >hwcontext_cuda.h \ > @@ -130,6 +131,7 @@ OBJS = adler32.o > \ > frame.o \ > hash.o \ > hdr_dynamic_metadata.o \ > + hdr_dynamic_vivid_metadata.o \ > hmac.o \ > hwcontext.o \ > imgutils.o \ > diff --git a/libavutil/frame.c b/libavutil/frame.c > index 8997c85..b035e28 100644 > --- a/libavutil/frame.c > +++ b/libavutil/frame.c > @@ -723,6 +723,7 @@ const char *av_frame_side_data_name(enum > AVFrameSideDataType type) > case AV_FRAME_DATA_SPHERICAL: return "Spherical > Mapping"; > case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile"; > case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata > SMPTE2094-40 (HDR10+)"; > +case AV_FRAME_DATA_DYNAMIC_HDR_VIVID: return "HDR Dynamic Metadata CUVA > 005.1 2021 (Vivid)"; > case AV_FRAME_DATA_REGIONS_OF_INTEREST: return "Regions Of Interest"; > case AV_FRAME_DATA_VIDEO_ENC_PARAMS:return "Video encoding > parameters"; > case AV_FRAME_DATA_SEI_UNREGISTERED:return "H.26[45] User > Data Unregistered SEI message"; > diff --git a/libavutil/frame.h b/libavutil/frame.h > index 18e239f..32cde3c 100644 > --- a/libavutil/frame.h > +++ b/libavutil/frame.h > @@ -158,6 +158,13 @@ enum AVFrameSideDataType { > AV_FRAME_DATA_DYNAMIC_HDR_PLUS, > > /** > + * HDR Vivid dynamic metadata associated with a video frame. The payload > is > + * an AVDynamicHDRVivid type and contains information for color > + * volume transform - CUVA 005.1-2021. > + */ > +AV_FRAME_DATA_DYNAMIC_HDR_VIVID, > + Always add at the end. You are breaking ABI otherwise. > +/** > * Regions Of Interest, the data is an array of AVRegionOfInterest type, > the number of > * array element is implied by AVFrameSideData.size / > AVRegionOfInterest.self_size. > */ ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] avutil: add support for CUVA HDR Vivid metadata
On Tue, Feb 15, 2022 at 08:08:51AM +0100, Andreas Rheinhardt wrote: > lance.lmw...@gmail.com: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavutil/Makefile | 2 + > > libavutil/frame.c | 1 + > > libavutil/frame.h | 7 + > > libavutil/hdr_dynamic_vivid_metadata.c | 47 ++ > > libavutil/hdr_dynamic_vivid_metadata.h | 285 > > + > > libavutil/version.h| 2 +- > > 6 files changed, 343 insertions(+), 1 deletion(-) > > create mode 100644 libavutil/hdr_dynamic_vivid_metadata.c > > create mode 100644 libavutil/hdr_dynamic_vivid_metadata.h > > > > diff --git a/libavutil/Makefile b/libavutil/Makefile > > index d17876d..a8d7587 100644 > > --- a/libavutil/Makefile > > +++ b/libavutil/Makefile > > @@ -34,6 +34,7 @@ HEADERS = adler32.h > > \ > >frame.h \ > >hash.h\ > >hdr_dynamic_metadata.h\ > > + hdr_dynamic_vivid_metadata.h \ > >hmac.h\ > >hwcontext.h \ > >hwcontext_cuda.h \ > > @@ -130,6 +131,7 @@ OBJS = adler32.o > > \ > > frame.o \ > > hash.o \ > > hdr_dynamic_metadata.o \ > > + hdr_dynamic_vivid_metadata.o \ > > hmac.o \ > > hwcontext.o \ > > imgutils.o \ > > diff --git a/libavutil/frame.c b/libavutil/frame.c > > index 8997c85..b035e28 100644 > > --- a/libavutil/frame.c > > +++ b/libavutil/frame.c > > @@ -723,6 +723,7 @@ const char *av_frame_side_data_name(enum > > AVFrameSideDataType type) > > case AV_FRAME_DATA_SPHERICAL: return "Spherical > > Mapping"; > > case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile"; > > case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata > > SMPTE2094-40 (HDR10+)"; > > +case AV_FRAME_DATA_DYNAMIC_HDR_VIVID: return "HDR Dynamic Metadata > > CUVA 005.1 2021 (Vivid)"; > > case AV_FRAME_DATA_REGIONS_OF_INTEREST: return "Regions Of Interest"; > > case AV_FRAME_DATA_VIDEO_ENC_PARAMS:return "Video encoding > > parameters"; > > case AV_FRAME_DATA_SEI_UNREGISTERED:return "H.26[45] User > > Data Unregistered SEI message"; > > diff --git a/libavutil/frame.h b/libavutil/frame.h > > index 18e239f..32cde3c 100644 > > --- a/libavutil/frame.h > > +++ b/libavutil/frame.h > > @@ -158,6 +158,13 @@ enum AVFrameSideDataType { > > AV_FRAME_DATA_DYNAMIC_HDR_PLUS, > > > > /** > > + * HDR Vivid dynamic metadata associated with a video frame. The > > payload is > > + * an AVDynamicHDRVivid type and contains information for color > > + * volume transform - CUVA 005.1-2021. > > + */ > > +AV_FRAME_DATA_DYNAMIC_HDR_VIVID, > > + > > Always add at the end. You are breaking ABI otherwise. Thanks for the comments, will fix it in the next version. > > > +/** > > * Regions Of Interest, the data is an array of AVRegionOfInterest > > type, the number of > > * array element is implied by AVFrameSideData.size / > > AVRegionOfInterest.self_size. > > */ > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".