[FFmpeg-devel] [PATCH] api-h264-slice-test: use av_be2ne16 instead of ntohs
avformat/network.h is not required here. --- tests/api/api-h264-slice-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/api/api-h264-slice-test.c b/tests/api/api-h264-slice-test.c index be03e80049..c6614da34d 100644 --- a/tests/api/api-h264-slice-test.c +++ b/tests/api/api-h264-slice-test.c @@ -41,10 +41,10 @@ #include #include -#include "libavformat/network.h" #include "libavcodec/avcodec.h" #include "libavutil/pixdesc.h" #include "libavutil/hash.h" +#include "libavutil/bswap.h" static int header = 0; @@ -191,7 +191,7 @@ int main(int argc, char **argv) if (ret != sizeof(uint16_t)) break; -size = ntohs(size); +size = av_be2ne16(size); ret = fread(p, 1, size, file); if (ret != size) { perror("Couldn't read data"); -- 2.17.1 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCHv2] avfilter/graphmonitor: use SIZE_SPECIFIER for size_t type
--- libavfilter/f_graphmonitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c index 7052c84d9b..c001835364 100644 --- a/libavfilter/f_graphmonitor.c +++ b/libavfilter/f_graphmonitor.c @@ -211,7 +211,7 @@ static void draw_items(AVFilterContext *ctx, AVFrame *out, snprintf(buffer, sizeof(buffer)-1, " | queue: "); drawtext(out, xpos, ypos, buffer, s->white); xpos += strlen(buffer) * 8; -snprintf(buffer, sizeof(buffer)-1, "%"PRId64, frames); +snprintf(buffer, sizeof(buffer)-1, "%"SIZE_SPECIFIER, frames); drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white); xpos += strlen(buffer) * 8; } -- 2.17.1 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/3] lavc/libdavs2: fix function return value error
Signed-off-by: hwrenx --- libavcodec/libdavs2.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c index 3b8666f..b7f7d65 100644 --- a/libavcodec/libdavs2.c +++ b/libavcodec/libdavs2.c @@ -58,7 +58,7 @@ static av_cold int davs2_init(AVCodecContext *avctx) return 0; } -static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, +static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, int *got_frame, davs2_seq_info_t *headerset, int ret_type, AVFrame *frame) { DAVS2Context *cad= avctx->priv_data; @@ -66,8 +66,10 @@ static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, int plane = 0; int line = 0; -if (!headerset) +if (!headerset) { +*got_frame = 0; return 0; +} if (!pic || ret_type == DAVS2_GOT_HEADER) { avctx->width = headerset->width; @@ -76,6 +78,7 @@ static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, AV_PIX_FMT_YUV420P10 : AV_PIX_FMT_YUV420P; avctx->framerate = av_d2q(headerset->frame_rate,4096); +*got_frame = 0; return 0; } @@ -122,7 +125,8 @@ static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, frame->pts = cad->out_frame.pts; frame->format= avctx->pix_fmt; -return 1; +*got_frame = 1; +return 0; } static int send_delayed_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame) @@ -136,7 +140,7 @@ static int send_delayed_frame(AVCodecContext *avctx, AVFrame *frame, int *got_fr return AVERROR_EXTERNAL; } if (ret == DAVS2_GOT_FRAME) { -*got_frame = davs2_dump_frames(avctx, >out_frame, >headerset, ret, frame); +ret = davs2_dump_frames(avctx, >out_frame, got_frame, >headerset, ret, frame); davs2_decoder_frame_unref(cad->decoder, >out_frame); } return ret; @@ -185,11 +189,11 @@ static int davs2_decode_frame(AVCodecContext *avctx, void *data, ret = davs2_decoder_recv_frame(cad->decoder, >headerset, >out_frame); if (ret != DAVS2_DEFAULT) { -*got_frame = davs2_dump_frames(avctx, >out_frame, >headerset, ret, frame); +ret = davs2_dump_frames(avctx, >out_frame, got_frame, >headerset, ret, frame); davs2_decoder_frame_unref(cad->decoder, >out_frame); } -return buf_size; +return ret == 0 ? buf_size : ret; } AVCodec ff_libdavs2_decoder = { -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/3] libdavs2: update api version and enable avx option
Signed-off-by: hwrenx --- configure | 2 +- libavcodec/libdavs2.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/configure b/configure index b4f944c..1a9f874 100755 --- a/configure +++ b/configure @@ -6076,7 +6076,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && enabled libcaca && require_pkg_config libcaca caca caca.h caca_create_canvas enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create -lcodec2 enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.0.1" "dav1d/dav1d.h" dav1d_version -enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.5.115" davs2.h davs2_decoder_open +enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.6.0" davs2.h davs2_decoder_open enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h drmGetVersion enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen || diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c index 874f2f0..9a905b8 100644 --- a/libavcodec/libdavs2.c +++ b/libavcodec/libdavs2.c @@ -40,11 +40,14 @@ typedef struct DAVS2Context { static av_cold int davs2_init(AVCodecContext *avctx) { DAVS2Context *cad = avctx->priv_data; +int cpu_flags = av_get_cpu_flags(); /* init the decoder */ cad->param.threads = avctx->thread_count; cad->param.info_level = 0; cad->decoder= davs2_decoder_open(>param); +cad->param.disable_avx = !(cpu_flags & AV_CPU_FLAG_AVX && +cpu_flags & AV_CPU_FLAG_AVX2); if (!cad->decoder) { av_log(avctx, AV_LOG_ERROR, "decoder created error."); -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/3] lavc/libdavs2: output delayed frames
Signed-off-by: hwrenx --- libavcodec/libdavs2.c | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c index 9a905b8..3b8666f 100644 --- a/libavcodec/libdavs2.c +++ b/libavcodec/libdavs2.c @@ -125,6 +125,23 @@ static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, return 1; } +static int send_delayed_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame) +{ +DAVS2Context *cad = avctx->priv_data; +int ret = DAVS2_DEFAULT; + +ret = davs2_decoder_flush(cad->decoder, >headerset, >out_frame); +if (ret == DAVS2_ERROR) { +av_log(avctx, AV_LOG_ERROR, "Decoder error: can't flush delayed frame\n"); +return AVERROR_EXTERNAL; +} +if (ret == DAVS2_GOT_FRAME) { +*got_frame = davs2_dump_frames(avctx, >out_frame, >headerset, ret, frame); +davs2_decoder_frame_unref(cad->decoder, >out_frame); +} +return ret; +} + static av_cold int davs2_end(AVCodecContext *avctx) { DAVS2Context *cad = avctx->priv_data; @@ -147,8 +164,9 @@ static int davs2_decode_frame(AVCodecContext *avctx, void *data, AVFrame *frame= data; int ret = DAVS2_DEFAULT; +/* end of stream, output what is still in the buffers */ if (!buf_size) { -return 0; +return send_delayed_frame(avctx, frame, got_frame); } cad->packet.data = buf_ptr; -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2] libavfilter: add transpose_vaapi filter
The patch optimized the ffmpeg transcode pipeline, it saves hwdownload/hwupload filters in the pipeline. It can get about 2.7x performance against software transpose filter as my test on 1080P. time ffmpeg -loglevel verbose -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i crowd_run_1080p.264 -vf transpose_vaapi=rotate=90:vflip -c:v h264_vaapi -y out-a.h264 real0m3.326s user0m1.225s sys 0m0.744s time ffmpeg -loglevel verbose -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i crowd_run_1080p.264 -vf hwdownload,transpose=clock_flip,format=nv12,hwupload -c:v h264_vaapi -y out-b.h264 real0m4.132s user0m4.815s sys0m0.534s (/ (+ 4.815 0.534) (+ 1.225 0.744)) = 2.7166074149314374 > -Original Message- > From: Zhou, Zachary > Sent: Wednesday, November 14, 2018 9:37 AM > To: ffmpeg-devel@ffmpeg.org > Cc: Zhou, Zachary > Subject: [PATCH v2] libavfilter: add transpose_vaapi filter > > It supports clockwise rotation by 0/90/180/270 degrees and mirroring by > horizontal/vertical. video size is changed when rotation by 90/270. > > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 - > hwaccel_output_format vaapi -i input.264 -vf > "transpose_vaapi=rotate=90:mirror=1" > -c:v h264_vaapi output.h264 > > Signed-off-by: Zachary Zhou > --- > configure| 2 + > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/vf_transpose_vaapi.c | 337 +++ > 4 files changed, 341 insertions(+) > create mode 100644 libavfilter/vf_transpose_vaapi.c > > diff --git a/configure b/configure > index 85d5dd5962..f62d2a27ca 100755 > --- a/configure > +++ b/configure > @@ -3439,6 +3439,7 @@ scale_filter_deps="swscale" > scale_qsv_filter_deps="libmfx" > select_filter_select="pixelutils" > sharpness_vaapi_filter_deps="vaapi" > +transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags" > showcqt_filter_deps="avcodec avformat swscale" > showcqt_filter_suggest="libfontconfig libfreetype" > showcqt_filter_select="fft" > @@ -5961,6 +5962,7 @@ check_type "d3d9.h dxva2api.h" > DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602 > > check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC" > check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth > +check_struct "va/va.h" "VAProcPipelineCaps" rotation_flags > check_type "va/va.h va/va_enc_hevc.h" > "VAEncPictureParameterBufferHEVC" > check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG" > check_type "va/va.h va/va_enc_vp8.h" "VAEncPictureParameterBufferVP8" > diff --git a/libavfilter/Makefile b/libavfilter/Makefile index > 62cc2f561f..813b174ddd 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -346,6 +346,7 @@ OBJS-$(CONFIG_SETRANGE_FILTER) += > vf_setparams.o > OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o > OBJS-$(CONFIG_SETTB_FILTER) += settb.o > OBJS-$(CONFIG_SHARPNESS_VAAPI_FILTER)+= vf_misc_vaapi.o > vaapi_vpp.o > +OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER)+= vf_transpose_vaapi.o > vaapi_vpp.o > OBJS-$(CONFIG_SHOWINFO_FILTER) += vf_showinfo.o > OBJS-$(CONFIG_SHOWPALETTE_FILTER)+= vf_showpalette.o > OBJS-$(CONFIG_SHUFFLEFRAMES_FILTER) += vf_shuffleframes.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index > 5e72803b13..e5b0571aa8 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -330,6 +330,7 @@ extern AVFilter ff_vf_setrange; extern AVFilter > ff_vf_setsar; extern AVFilter ff_vf_settb; extern AVFilter > ff_vf_sharpness_vaapi; > +extern AVFilter ff_vf_transpose_vaapi; > extern AVFilter ff_vf_showinfo; > extern AVFilter ff_vf_showpalette; > extern AVFilter ff_vf_shuffleframes; > diff --git a/libavfilter/vf_transpose_vaapi.c > b/libavfilter/vf_transpose_vaapi.c > new file mode 100644 > index 00..fcb99fc866 > --- /dev/null > +++ b/libavfilter/vf_transpose_vaapi.c > @@ -0,0 +1,337 @@ > +/* > + * 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 > + > +#include
Re: [FFmpeg-devel] [PATCH 2/3] avcodec/truemotion2: fix integer overflows in tm2_low_chroma()
On Mon, Nov 19, 2018 at 09:37:28AM +0100, Tomas Härdin wrote: > mån 2018-11-19 klockan 02:02 +0100 skrev Michael Niedermayer: > > On Sun, Nov 18, 2018 at 11:32:21PM +0100, Tomas Härdin wrote: > > > lör 2018-11-17 klockan 03:01 +0100 skrev Michael Niedermayer: > > > > Fixes: > > > > 11295/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2_fuzzer-4888953459572736 > > > > > > > > Found-by: continuous fuzzing process > > > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > > > > Signed-off-by: Michael Niedermayer > > > > > > > > --- > > > > libavcodec/truemotion2.c | 6 +++--- > > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c > > > > index 58a577f53c..c583ff4032 100644 > > > > --- a/libavcodec/truemotion2.c > > > > +++ b/libavcodec/truemotion2.c > > > > @@ -484,7 +484,7 @@ static inline void tm2_high_chroma(int *data, int > > > > stride, int *last, unsigned *C > > > > } > > > > } > > > > > > > > -static inline void tm2_low_chroma(int *data, int stride, int *clast, > > > > int *CD, int *deltas, int bx) > > > > +static inline void tm2_low_chroma(int *data, int stride, int *clast, > > > > unsigned *CD, int *deltas, int bx) > > > > { > > > > int t; > > > > int l; > > > > @@ -494,8 +494,8 @@ static inline void tm2_low_chroma(int *data, int > > > > stride, int *clast, int *CD, in > > > > prev = clast[-3]; > > > > else > > > > prev = 0; > > > > -t= (CD[0] + CD[1]) >> 1; > > > > -l= (prev - CD[0] - CD[1] + clast[1]) >> 1; > > > > +t= (int)(CD[0] + CD[1]) >> 1; > > > > > > I presume the old code would overflow for sums exceeding INT_MAX. > > > > There were overflows in the sense of undefined behavior, yes > > > > > > > Why > > > then is there a cast to int before the shift and not after? > > > > because shifts of signed and unsigned values produce different results > > > > maybe the unsigned type confused you. CD is signed in a semantic sense its > > stored in a unsigned type because otherwise this code has undefined > > behavior. > > It would be better to use a type with different name but that had lead to > > long arguments that went nowhere in the past. So i tend to use plain > > unsigned now for these kind of cases as it seems that is what most people > > prefer. > > So signed overflow is intended? Huh, weird format. it occurs in the fuzzed sample used here. i do not know if it occurs in normal samples, i would suspect it does not. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When the tyrant has disposed of foreign enemies by conquest or treaty, and there is nothing more to fear from them, then he is always stirring up some war or other, in order that the people may require a leader. -- Plato signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec/truemotion2: Check huffman code max bits
Fixes: Timeout Fixes: 10984/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2_fuzzer-6643310750859264 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/truemotion2.c | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index 58a577f53c..6d58483a77 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -112,9 +112,13 @@ typedef struct TM2Huff { int *lens; ///< codelengths } TM2Huff; +/** + * + * @returns the length of the longest code or an AVERROR code + */ static int tm2_read_tree(TM2Context *ctx, uint32_t prefix, int length, TM2Huff *huff) { -int ret; +int ret, ret2; if (length > huff->max_bits) { av_log(ctx->avctx, AV_LOG_ERROR, "Tree exceeded its given depth (%i)\n", huff->max_bits); @@ -133,14 +137,14 @@ static int tm2_read_tree(TM2Context *ctx, uint32_t prefix, int length, TM2Huff * huff->bits[huff->num] = prefix; huff->lens[huff->num] = length; huff->num++; -return 0; +return length; } else { /* non-terminal node */ -if ((ret = tm2_read_tree(ctx, prefix << 1, length + 1, huff)) < 0) -return ret; +if ((ret2 = tm2_read_tree(ctx, prefix << 1, length + 1, huff)) < 0) +return ret2; if ((ret = tm2_read_tree(ctx, (prefix << 1) | 1, length + 1, huff)) < 0) return ret; } -return 0; +return FFMAX(ret, ret2); } static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code) @@ -183,6 +187,11 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code) res = tm2_read_tree(ctx, 0, 0, ); +if (res >= 0 && res != huff.max_bits) { +av_log(ctx->avctx, AV_LOG_ERROR, "Got less bits than expected: %i of %i\n", + res, huff.max_bits); +res = AVERROR_INVALIDDATA; +} if (huff.num != huff.max_num) { av_log(ctx->avctx, AV_LOG_ERROR, "Got less codes than expected: %i of %i\n", huff.num, huff.max_num); -- 2.19.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/mpeg_er: fix clearing chroma blocks for 422 and 444
On Sun, 18 Nov 2018, Michael Niedermayer wrote: On Sat, Nov 17, 2018 at 11:39:08PM +0100, Marton Balint wrote: Fixes ticket #7494. Signed-off-by: Marton Balint --- libavcodec/mpeg_er.c | 2 ++ 1 file changed, 2 insertions(+) probably ok Thanks, applied and backported to 4.1. a fate test covering this case if its stable should be added too. I think the project should pay somebody to create fate tests from fixed tickets, or offer doing this as a project for outreachy/whatever, because even less experienced developers can do it and it improves quality a lot. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/vf_freezedetect: add filter to detect frozen input
On Sun, 18 Nov 2018, Marton Balint wrote: On Sat, 17 Nov 2018, Paul B Mahol wrote: On 11/17/18, Marton Balint wrote: On Sun, 11 Nov 2018, Paul B Mahol wrote: On 11/11/18, Marton Balint wrote: Signed-off-by: Marton Balint --- Changelog | 1 + configure | 1 + doc/filters.texi | 29 + libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 2 +- libavfilter/vf_freezedetect.c | 282 ++ 7 files changed, 316 insertions(+), 1 deletion(-) create mode 100644 libavfilter/vf_freezedetect.c diff --git a/Changelog b/Changelog index e38a607025..0eba82b477 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ releases are sorted from youngest to oldest. version : - tpad filter - AV1 decoding support through libdav1d +- freezedetect filter [...] +AVFILTER_DEFINE_CLASS(freezedetect); + +static int query_formats(AVFilterContext *ctx) +{ +static const enum AVPixelFormat pix_fmts[] = { +AV_PIX_FMT_YUV420P, +AV_PIX_FMT_YUYV422, +AV_PIX_FMT_RGB24, +AV_PIX_FMT_BGR24, +AV_PIX_FMT_YUV422P, +AV_PIX_FMT_YUV444P, +AV_PIX_FMT_YUV410P, +AV_PIX_FMT_YUV411P, +AV_PIX_FMT_GRAY8, +AV_PIX_FMT_YUVJ420P, +AV_PIX_FMT_YUVJ422P, +AV_PIX_FMT_YUVJ444P, +AV_PIX_FMT_UYVY422, +AV_PIX_FMT_NV12, +AV_PIX_FMT_NV21, +AV_PIX_FMT_ARGB, +AV_PIX_FMT_RGBA, +AV_PIX_FMT_ABGR, +AV_PIX_FMT_BGRA, +AV_PIX_FMT_GRAY16, +AV_PIX_FMT_YUV440P, +AV_PIX_FMT_YUVJ440P, +AV_PIX_FMT_YUVA420P, +AV_PIX_FMT_YUV420P16, +AV_PIX_FMT_YUV422P16, +AV_PIX_FMT_YUV444P16, +AV_PIX_FMT_YA8, +AV_PIX_FMT_YUV420P9, +AV_PIX_FMT_YUV420P10, +AV_PIX_FMT_YUV422P10, +AV_PIX_FMT_YUV444P9, +AV_PIX_FMT_YUV444P10, +AV_PIX_FMT_YUV422P9, +AV_PIX_FMT_GBRP, +AV_PIX_FMT_GBRP9, +AV_PIX_FMT_GBRP10, +AV_PIX_FMT_GBRP16, +AV_PIX_FMT_YUVA422P, +AV_PIX_FMT_YUVA444P, +AV_PIX_FMT_YUVA420P9, +AV_PIX_FMT_YUVA422P9, +AV_PIX_FMT_YUVA444P9, +AV_PIX_FMT_YUVA420P10, +AV_PIX_FMT_YUVA422P10, +AV_PIX_FMT_YUVA444P10, +AV_PIX_FMT_YUVA420P16, +AV_PIX_FMT_YUVA422P16, +AV_PIX_FMT_YUVA444P16, +AV_PIX_FMT_NV16, +AV_PIX_FMT_YVYU422, +AV_PIX_FMT_GBRAP, +AV_PIX_FMT_GBRAP16, +AV_PIX_FMT_YUV420P12, +AV_PIX_FMT_YUV420P14, +AV_PIX_FMT_YUV422P12, +AV_PIX_FMT_YUV422P14, +AV_PIX_FMT_YUV444P12, +AV_PIX_FMT_YUV444P14, +AV_PIX_FMT_GBRP12, +AV_PIX_FMT_GBRP14, +AV_PIX_FMT_YUVJ411P, +AV_PIX_FMT_YUV440P10, +AV_PIX_FMT_YUV440P12, +AV_PIX_FMT_GBRAP12, +AV_PIX_FMT_GBRAP10, +AV_PIX_FMT_GRAY12, +AV_PIX_FMT_GRAY10, +AV_PIX_FMT_GRAY9, +AV_PIX_FMT_GRAY14, +AV_PIX_FMT_NONE Please make this list more compact, make use of several items per line. Ok. I will apply the patch soon. You sure that packed and semi-planar formats like nv21 work with filter? Yes, because every plane they use have continous data and every component is calculated equally into the sum of absolute differences. Applied. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/5] fftools/ffprobe: fix max_bit_rate dump.
On Mon, Nov 19, 2018 at 08:40:07AM +0800, myp...@gmail.com wrote: > On Mon, Nov 19, 2018 at 6:03 AM Moritz Barsnick wrote: > > > > > +if (dec_ctx->rc_max_rate > 0) print_val ("max_bit_rate", > > > dec_ctx->rc_max_rate, unit_bit_per_second_str); > > > +else print_str_opt("max_bit_rate", "N/A"); > > > if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) > > > print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample); > > > > If the (now) second condition needs to check for validity of dec_ctx, > > shouldn't the new first one also need to check? > > > > > Ha, I guess I missed the check, will update, Thanks this failure shows up in fate btw: (unless this was some other issue in this patch) make: *** [fate-mpegts-probe-pmt-merge] Error 139 make: *** [fate-mxf-probe-dnxhd] Error 139 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] [HLS] Add LANGUAGE attribute to #EXT-X-MEDIA tag for audio-only variant streams.
... I just noticed the langEntry var name. Here's an update. Sorry... Even after checking the guidelines twice, apparently I still miss things. I'll try to do better next time. I really expect this to be the last update. (at the very least concerning coding style issues) Sorry, Philippe Op ma 19 nov. 2018 om 21:21 schreef Philippe Symons < philippe.sym...@gmail.com>: > Hello everyone, > > I've updated the patch based on the feedback from Moritz. Thanks, btw! I > apologize if I wasted your time with this. > > I've updated the patch based on your feedback. I hope I got it right this > time. > > Looking forward to your feedback, > > Best regards, > > Philippe Symons > > Op za 17 nov. 2018 om 11:20 schreef Moritz Barsnick : > >> On Thu, Nov 15, 2018 at 00:29:00 +0100, Philippe Symons wrote: >> > Here is the new version of the patch in which the comments on the curly >> > braces have been resolved as well. >> >> Style-wise, there are other issues. (I'm not judging technically here.) >> >> > Subject: [PATCH] [HLS] Add LANGUAGE attribute to #EXT-X-MEDIA tag for >> > audio-only variant streams. >> >> The project prefers: >> avformat/hls,dash: add LANGUAGE attribute to #EXT-X-MEDIA tag for >> audio-only variant streams >> >> (i.e. source hierarchy, no trailing dot, ...) >> >> > set_http_options(s, , hls); >> > - >> > ret = hlsenc_io_open(s, >m3u8_out, hls->master_m3u8_url, >> ); >> >> Don't add extra lines, please. >> >> > for (i = 0; i < hls->nb_varstreams; i++) { >> > +AVFormatContext* var_context; >> > +char* language = NULL; >> >> Please read >> https://www.ffmpeg.org/developer.html#Coding-Rules-1 >> >> abouts brackets and indentation, and look at other code sections.. >> Furthermore, the "pointer specifier" (or whatever that's called) sticks >> to the variable, not the type, in ffmpeg declarations: >> >> char *language = NULL; >> >> Same in other places. >> >> > +if(var_context && var_context->nb_streams > 0) { >> >> Bracket / whitspace style: "if (var_context [...]" >> >> > +if(langEntry) { >> Same here: if (langEntry) >> And in other places. >> >> > +language = langEntry->value; >> > +} >> >> Some developers prefer you to drop the curly brackets around one-liner >> blocks. >> >> No review of the technical implications, sorry. >> >> Cheers, >> Moritz >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > From 1efe99216f48ae5afb98c3d98f57c19494f0fa20 Mon Sep 17 00:00:00 2001 From: Philippe Symons Date: Mon, 19 Nov 2018 21:32:36 +0100 Subject: [PATCH] avformat/hls,dash: add LANGUAGE attribute to #EXT-X-MEDIA tag for audio-only variant streams Signed-off-by: Philippe Symons --- libavformat/dashenc.c | 2 +- libavformat/hlsenc.c | 20 +++- libavformat/hlsplaylist.c | 6 +- libavformat/hlsplaylist.h | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index d151921175..eca7525bf0 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -898,7 +898,7 @@ static int write_manifest(AVFormatContext *s, int final) if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) continue; get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i); -ff_hls_write_audio_rendition(c->m3u8_out, (char *)audio_group, +ff_hls_write_audio_rendition(c->m3u8_out, (char *)audio_group, NULL, playlist_file, i, is_default); max_audio_bitrate = FFMAX(st->codecpar->bit_rate + os->muxer_overhead, max_audio_bitrate); diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 24b678efe0..58c6d3ae34 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1228,12 +1228,30 @@ static int create_master_playlist(AVFormatContext *s, /* For audio only variant streams add #EXT-X-MEDIA tag with attributes*/ for (i = 0; i < hls->nb_varstreams; i++) { +AVFormatContext *var_context; +char *language = NULL; + vs = &(hls->var_streams[i]); +var_context = vs->avf; if (vs->has_video || vs->has_subtitle || !vs->agroup) continue; m3u8_name_size = strlen(vs->m3u8_name) + 1; + +/* + * Try to obtain the language code of the audio stream. + * -if available- it will be used to write the LANGUAGE + * attribute in the #EXT-X-MEDIA tag + */ +if (var_context && var_context->nb_streams > 0) { +AVDictionary *meta_dict = vs->streams[0]->metadata; +AVDictionaryEntry *lang_entry = av_dict_get(meta_dict, "language", NULL, 0); + +if (lang_entry) +language = lang_entry->value; +} + m3u8_rel_name
Re: [FFmpeg-devel] [PATCH] [HLS] Add LANGUAGE attribute to #EXT-X-MEDIA tag for audio-only variant streams.
Hello everyone, I've updated the patch based on the feedback from Moritz. Thanks, btw! I apologize if I wasted your time with this. I've updated the patch based on your feedback. I hope I got it right this time. Looking forward to your feedback, Best regards, Philippe Symons Op za 17 nov. 2018 om 11:20 schreef Moritz Barsnick : > On Thu, Nov 15, 2018 at 00:29:00 +0100, Philippe Symons wrote: > > Here is the new version of the patch in which the comments on the curly > > braces have been resolved as well. > > Style-wise, there are other issues. (I'm not judging technically here.) > > > Subject: [PATCH] [HLS] Add LANGUAGE attribute to #EXT-X-MEDIA tag for > > audio-only variant streams. > > The project prefers: > avformat/hls,dash: add LANGUAGE attribute to #EXT-X-MEDIA tag for > audio-only variant streams > > (i.e. source hierarchy, no trailing dot, ...) > > > set_http_options(s, , hls); > > - > > ret = hlsenc_io_open(s, >m3u8_out, hls->master_m3u8_url, > ); > > Don't add extra lines, please. > > > for (i = 0; i < hls->nb_varstreams; i++) { > > +AVFormatContext* var_context; > > +char* language = NULL; > > Please read > https://www.ffmpeg.org/developer.html#Coding-Rules-1 > > abouts brackets and indentation, and look at other code sections.. > Furthermore, the "pointer specifier" (or whatever that's called) sticks > to the variable, not the type, in ffmpeg declarations: > > char *language = NULL; > > Same in other places. > > > +if(var_context && var_context->nb_streams > 0) { > > Bracket / whitspace style: "if (var_context [...]" > > > +if(langEntry) { > Same here: if (langEntry) > And in other places. > > > +language = langEntry->value; > > +} > > Some developers prefer you to drop the curly brackets around one-liner > blocks. > > No review of the technical implications, sorry. > > Cheers, > Moritz > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > From 97a9d2ebf2abde9c61cadb355cfe2ca2f960c5c7 Mon Sep 17 00:00:00 2001 From: Philippe Symons Date: Mon, 19 Nov 2018 20:34:36 +0100 Subject: [PATCH] avformat/hls,dash: add LANGUAGE attribute to #EXT-X-MEDIA tag for audio-only variant streams Signed-off-by: Philippe Symons --- libavformat/dashenc.c | 2 +- libavformat/hlsenc.c | 20 +++- libavformat/hlsplaylist.c | 6 +- libavformat/hlsplaylist.h | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index d151921175..17465c1917 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -898,7 +898,7 @@ static int write_manifest(AVFormatContext *s, int final) if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) continue; get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i); -ff_hls_write_audio_rendition(c->m3u8_out, (char *)audio_group, +ff_hls_write_audio_rendition(c->m3u8_out, (char *)audio_group, NULL, playlist_file, i, is_default); max_audio_bitrate = FFMAX(st->codecpar->bit_rate + os->muxer_overhead, max_audio_bitrate); diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 24b678efe0..6b937c244e 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1228,12 +1228,30 @@ static int create_master_playlist(AVFormatContext *s, /* For audio only variant streams add #EXT-X-MEDIA tag with attributes*/ for (i = 0; i < hls->nb_varstreams; i++) { +AVFormatContext *var_context; +char *language = NULL; + vs = &(hls->var_streams[i]); +var_context = vs->avf; if (vs->has_video || vs->has_subtitle || !vs->agroup) continue; m3u8_name_size = strlen(vs->m3u8_name) + 1; + +/* + * Try to obtain the language code of the audio stream. + * -if available- it will be used to write the LANGUAGE + * attribute in the #EXT-X-MEDIA tag + */ +if (var_context && var_context->nb_streams > 0) { +AVDictionary *meta_dict = vs->streams[0]->metadata; +AVDictionaryEntry *langEntry = av_dict_get(meta_dict, "language", NULL, 0); + +if (langEntry) +language = langEntry->value; +} + m3u8_rel_name = av_malloc(m3u8_name_size); if (!m3u8_rel_name) { ret = AVERROR(ENOMEM); @@ -1247,7 +1265,7 @@ static int create_master_playlist(AVFormatContext *s, goto fail; } -ff_hls_write_audio_rendition(hls->m3u8_out, vs->agroup, m3u8_rel_name, 0, 1); +ff_hls_write_audio_rendition(hls->m3u8_out, vs->agroup, language, m3u8_rel_name, 0, 1); av_freep(_rel_name); } diff --git
Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip func
On 19/11/18 09:04, Jing SUN wrote: > frame-skip is required to implement network > bandwidth self-adaptive vaapi encoding. > To make a frame skipped, allocate its frame > side data of AV_FRAME_DATA_SKIP_FRAME type > and set its value to 1. So if I'm reading this correctly the idea is to implement partial VFR by having a special new side-data type which indicates where frames would have been had the input actually matched the configured CFR behaviour? Why is the user meant to create these special frames? It seems to me that the existing method of looking at the timestamps would be a better way to find any gaps. (Or, even better, add timestamps to VAAPI so that it can support VFR in a sensible way rather than adding hacks like this to allow partial VFR with weird constraints.) > Signed-off-by: Jing SUN > --- > libavcodec/vaapi_encode.c | 142 > -- > libavcodec/vaapi_encode.h | 5 ++ > libavutil/frame.c | 1 + > libavutil/frame.h | 5 ++ > 4 files changed, 149 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c > index 2fe8501..a401d61 100644 > --- a/libavcodec/vaapi_encode.c > +++ b/libavcodec/vaapi_encode.c > @@ -23,6 +23,7 @@ > #include "libavutil/common.h" > #include "libavutil/log.h" > #include "libavutil/pixdesc.h" > +#include "libavutil/intreadwrite.h" > > #include "vaapi_encode.h" > #include "avcodec.h" > @@ -103,6 +104,47 @@ static int vaapi_encode_make_param_buffer(AVCodecContext > *avctx, > return 0; > } > > +static int vaapi_encode_check_if_skip(AVCodecContext *avctx, > + VAAPIEncodePicture *pic) > +{ > +AVFrameSideData *fside = NULL; > +VAAPIEncodeContext *ctx = avctx->priv_data; > +VAAPIEncodePicture *cur = NULL; > +int i = 0; > + > +if (!pic || !pic->input_image) > +return AVERROR(EINVAL); > + > +fside = av_frame_get_side_data(pic->input_image, > AV_FRAME_DATA_SKIP_FRAME); > +if (fside) > +pic->skipped_flag = AV_RL8(fside->data); > +else > +pic->skipped_flag = 0; > + > +if (0 == pic->skipped_flag) > +return 0; > + > +if ((pic->type == PICTURE_TYPE_IDR) || (pic->type == PICTURE_TYPE_I)) { > +av_log(avctx, AV_LOG_INFO, "Can't skip IDR/I pic > %"PRId64"/%"PRId64".\n", > + pic->display_order, pic->encode_order); > +pic->skipped_flag = 0; > +return 0; > +} > + > +for (cur = ctx->pic_start; cur; cur = cur->next) { > +for (i=0; i < cur->nb_refs; ++i) { > +if (cur->refs[i] == pic) { > +av_log(avctx, AV_LOG_INFO, "Can't skip ref pic > %"PRId64"/%"PRId64".\n", > + pic->display_order, pic->encode_order); > +pic->skipped_flag = 0; > +return 0; > +} > +} > +} > + > +return 0; > +} > + > static int vaapi_encode_wait(AVCodecContext *avctx, > VAAPIEncodePicture *pic) > { > @@ -418,6 +460,69 @@ static int vaapi_encode_issue(AVCodecContext *avctx, > } > } > > +err = vaapi_encode_check_if_skip(avctx, pic); > +if (err != 0) > +av_log(avctx, AV_LOG_ERROR, "Fail to check if skip.\n"); > + > +#ifdef VAEncMiscParameterSkipFrame > +if (pic->skipped_flag) { > +av_log(avctx, AV_LOG_INFO, "Skip pic %"PRId64"/%"PRId64" as > requested.\n", > + pic->display_order, pic->encode_order); > + > +++ctx->skipped_pic_count; > +pic->encode_issued = 1; > + > +return 0; > +} else if (ctx->skipped_pic_count > 0) { > +VABufferID skip_param_id; > +VAEncMiscParameterBuffer *misc_param; > +VAEncMiscParameterSkipFrame *skip_param; > + > +err = vaapi_encode_make_param_buffer(avctx, pic, > + VAEncMiscParameterBufferType, NULL, > + (sizeof(VAEncMiscParameterBuffer) + > + sizeof(VAEncMiscParameterSkipFrame))); > +if (err < 0) > +goto fail; > + > +skip_param_id = pic->param_buffers[pic->nb_param_buffers-1]; > + > +vas = vaMapBuffer(ctx->hwctx->display, > + skip_param_id, > + (void **)_param); > +if (vas != VA_STATUS_SUCCESS) { > +av_log(avctx, AV_LOG_ERROR, "Failed to map skip-frame buffer: " > + "%d (%s).\n", vas, vaErrorStr(vas)); > +err = AVERROR(EIO); > +goto fail; > +} > + > +misc_param->type = > (VAEncMiscParameterType)VAEncMiscParameterTypeSkipFrame; You need to check VAConfigAttribEncSkipFrame to make sure this type is actually supported before using it. > +skip_param = (VAEncMiscParameterSkipFrame *)misc_param->data; > +skip_param->skip_frame_flag = 1; > +skip_param->num_skip_frames = ctx->skipped_pic_count; > +
Re: [FFmpeg-devel] [PATCH] avcodec/libvpxenc: add VP8 temporal scalability configuration options
On Fri, Nov 16, 2018 at 8:59 PM James Zern wrote: > > On Wed, Nov 14, 2018 at 12:56 PM Ard Oerlemans > wrote: > > > > This commit adds configuration options to libvpxenc.c that can be used to > > enable VP8 temporal scalability. It also adds a way to programmatically set > > the > > per-frame encoding flags which can be used to control usage and updates of > > reference frames while encoding with temporal scalability enabled. > > --- > > doc/encoders.texi | 28 +++ > > libavcodec/libvpxenc.c | 81 ++ > > 2 files changed, 109 insertions(+) > > > > lgtm. I'll submit this soon if there aren't any further comments. > applied, thanks for the patch. > > [...] > > +while (token && dest_idx < max_entries) > > +{ > > This should be joined with the previous line. I have a fix for it locally. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip func
2018-11-19 10:04 GMT+01:00, Jing SUN : > diff --git a/libavutil/frame.h b/libavutil/frame.h > index 66f27f4..8ef6475 100644 > --- a/libavutil/frame.h > +++ b/libavutil/frame.h > @@ -166,6 +166,11 @@ enum AVFrameSideDataType { > * function in libavutil/timecode.c. > */ > AV_FRAME_DATA_S12M_TIMECODE, > + > +/** > + * VAAPI Encode skip-frame indicator. > + */ > +AV_FRAME_DATA_SKIP_FRAME, I suspect this needs a minor version bump and should be a separate commit but please wait for an actual review. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Add 16-bit Depth pixel format
2018-11-19 18:41 GMT+01:00, Carl Eugen Hoyos : > 2018-11-19 18:21 GMT+01:00, Pablo Rubio Fernández : > >> It's my first time here. I want to create a patch to add Z16 pixel >> format. >> I have did some changes, and I want to know if I'll need change any other >> file. > > Isn't attached poc sufficient? After adding the missing ","... Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Add 16-bit Depth pixel format
2018-11-19 18:21 GMT+01:00, Pablo Rubio Fernández : > It's my first time here. I want to create a patch to add Z16 pixel format. > I have did some changes, and I want to know if I'll need change any other > file. Isn't attached poc sufficient? Carl Eugen diff --git a/libavdevice/v4l2-common.c b/libavdevice/v4l2-common.c index 2d6bfac..4da6044 100644 --- a/libavdevice/v4l2-common.c +++ b/libavdevice/v4l2-common.c @@ -64,6 +64,9 @@ const struct fmt_map ff_fmt_conversion_table[] = { { AV_PIX_FMT_BAYER_GRBG8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SGRBG8 }, { AV_PIX_FMT_BAYER_RGGB8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SRGGB8 }, #endif +#ifdef V4L2_PIX_FMT_Z16 +{ AV_PIX_FMT_GRAY16LE AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_Z16}, +#endif { AV_PIX_FMT_NONE,AV_CODEC_ID_NONE, 0}, }; ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Add 16-bit Depth pixel format
On 11/19/18, Pablo Rubio Fernández wrote: > Hi all! > It's my first time here. I want to create a patch to add Z16 pixel format. > I have did some changes, and I want to know if I'll need change any other > file. > I attach my current patch. > Thanks in advance. > Isn't this same as gray16? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Add 16-bit Depth pixel format
Hi all! It's my first time here. I want to create a patch to add Z16 pixel format. I have did some changes, and I want to know if I'll need change any other file. I attach my current patch. Thanks in advance. From 7f3e028198c510fd8cf14c087d4a223bd7e94422 Mon Sep 17 00:00:00 2001 From: prubio Date: Fri, 16 Nov 2018 11:55:00 +0100 Subject: [PATCH] Add 16-bit Depth z16 pixel format --- libavdevice/v4l2-common.c | 3 +++ libavutil/pixdesc.c | 9 + libavutil/pixfmt.h| 2 ++ libswscale/input.c| 3 +++ libswscale/utils.c| 2 ++ 5 files changed, 19 insertions(+) diff --git a/libavdevice/v4l2-common.c b/libavdevice/v4l2-common.c index 2d6bfac..337bb08 100644 --- a/libavdevice/v4l2-common.c +++ b/libavdevice/v4l2-common.c @@ -46,6 +46,9 @@ const struct fmt_map ff_fmt_conversion_table[] = { #ifdef V4L2_PIX_FMT_Y16 { AV_PIX_FMT_GRAY16LE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_Y16 }, #endif +#ifdef V4L2_PIX_FMT_Z16 +{ AV_PIX_FMT_Z16, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_Z16 }, +#endif { AV_PIX_FMT_NV12,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV12}, { AV_PIX_FMT_NONE,AV_CODEC_ID_MJPEG,V4L2_PIX_FMT_MJPEG }, { AV_PIX_FMT_NONE,AV_CODEC_ID_MJPEG,V4L2_PIX_FMT_JPEG}, diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 1c36577..9ede616 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2268,6 +2268,15 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .flags = AV_PIX_FMT_FLAG_FLOAT, .alias = "yf32le", }, +[AV_PIX_FMT_Z16] = { +.name = "z16", +.nb_components = 1, +.log2_chroma_w = 0, +.log2_chroma_h = 0, +.comp = { +{ 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ +}, +}, }; #if FF_API_PLUS1_MINUS1 FF_ENABLE_DEPRECATION_WARNINGS diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 6815f8d..d8a7119 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -300,6 +300,8 @@ enum AVPixelFormat { AV_PIX_FMT_P016LE, ///< like NV12, with 16bpp per component, little-endian AV_PIX_FMT_P016BE, ///< like NV12, with 16bpp per component, big-endian +AV_PIX_FMT_Z16, ///< 16 bit Depth (little-endian) + /** * Hardware surfaces for Direct3D11. * diff --git a/libswscale/input.c b/libswscale/input.c index 4099c19..7178307 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -1448,6 +1448,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) c->alpToYV12 = bswap16Y_c; break; #endif +case AV_PIX_FMT_Z16: +c->lumToYV12 = bswap16Y_c; +break; case AV_PIX_FMT_YA16LE: c->lumToYV12 = read_ya16le_gray_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index d5913ed..2e18e2d 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -260,6 +260,7 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = { [AV_PIX_FMT_P016BE] = { 1, 1 }, [AV_PIX_FMT_GRAYF32LE] = { 1, 1 }, [AV_PIX_FMT_GRAYF32BE] = { 1, 1 }, +[AV_PIX_FMT_Z16] = { 1, 1 }, }; int sws_isSupportedInput(enum AVPixelFormat pix_fmt) @@ -1034,6 +1035,7 @@ static int handle_jpeg(enum AVPixelFormat *format) case AV_PIX_FMT_GRAY16BE: case AV_PIX_FMT_YA16BE: case AV_PIX_FMT_YA16LE: +case AV_PIX_FMT_Z16: return 1; default: return 0; -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 1/3] configure: update api version of libxavs2
2018-11-18 8:19 GMT+01:00, hwrenx : > From: hwrenx > > abolish parameter IntraPeriod && > replaced by IntraPeriodMax/Min > ... > > more detials could be found in xavs2-git > https://github.com/pkuvcl/xavs2 > > Signed-off-by: hwrenx > --- > configure | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/configure b/configure > index 9bc4cf3..dee901d 100755 > --- a/configure > +++ b/configure > @@ -6191,7 +6191,7 @@ enabled libx264 && { check_pkg_config > libx264 x264 "stdint.h x264.h" x > enabled libx265 && require_pkg_config libx265 x265 x265.h > x265_api_get && > require_cpp_condition libx265 x265.h > "X265_BUILD >= 68" > enabled libxavs && require libxavs "stdint.h xavs.h" > xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs" > -enabled libxavs2 && require_pkg_config libxavs2 "xavs2 >= 1.2.77" > "stdint.h xavs2.h" xavs2_api_get > +enabled libxavs2 && require_pkg_config libxavs2 "xavs2 >= 1.3.0" > "stdint.h xavs2.h" xavs2_api_get Patch applied. Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 3/3] lavc/libdavs2: add disable_avx into decoder parameter
2018-11-18 8:19 GMT+01:00, hwrenx : > From: hwrenx > > Signed-off-by: hwrenx > --- > libavcodec/libdavs2.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c > index cadf995..8cef49d 100644 > --- a/libavcodec/libdavs2.c > +++ b/libavcodec/libdavs2.c > @@ -42,11 +42,14 @@ typedef struct DAVS2Context { > static av_cold int davs2_init(AVCodecContext *avctx) > { > DAVS2Context *cad = avctx->priv_data; > +int cpu_flags = av_get_cpu_flags(); > > /* init the decoder */ > cad->param.threads = avctx->thread_count; > cad->param.info_level = 0; > cad->decoder= davs2_decoder_open(>param); > +cad->param.disable_avx = !(cpu_flags & AV_CPU_FLAG_AVX && > +cpu_flags & AV_CPU_FLAG_AVX2); Please merge this with the patch changing minimal version in configure. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/graphmonitor: use %z when printing size_t
On Mon, Nov 19, 2018 at 3:38 PM James Almer wrote: > > On 11/19/2018 9:34 AM, Hendrik Leppkes wrote: > > On Mon, Nov 19, 2018 at 12:27 PM Peter Ross wrote: > >> > >> --- > >> 32-bit target compiler warning. > >> > >> libavfilter/f_graphmonitor.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c > >> index 7052c84d9b..3cb8f73dd3 100644 > >> --- a/libavfilter/f_graphmonitor.c > >> +++ b/libavfilter/f_graphmonitor.c > >> @@ -211,7 +211,7 @@ static void draw_items(AVFilterContext *ctx, AVFrame > >> *out, > >> snprintf(buffer, sizeof(buffer)-1, " | queue: "); > >> drawtext(out, xpos, ypos, buffer, s->white); > >> xpos += strlen(buffer) * 8; > >> -snprintf(buffer, sizeof(buffer)-1, "%"PRId64, frames); > >> +snprintf(buffer, sizeof(buffer)-1, "%zd", frames); > > > > "%" SIZE_SPECIFIER to be portable. > > Do recent msvc versions still need this? We don't really support 2012 > and older anymore, so maybe %zu (and not %zd as size_t is unsigned) is > enough. > As far as I can tell, 2015 still needs it. 2017 supports z. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/graphmonitor: use %z when printing size_t
Carl Eugen Hoyos (2018-11-19): > This happened when you (and others) agreed to a patch adding a > function that returns size_t. ff_inlink_queued_frames() is not public > so the alternative to this patch is to change the return type or make > frames 64bit which seems less straight-forward. > (Or it happened when FFFrameQueue->queued was defined size_t.) size_t is the correct type for a large number of objects that coexist in memory. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/graphmonitor: use %z when printing size_t
On 11/19/2018 9:34 AM, Hendrik Leppkes wrote: > On Mon, Nov 19, 2018 at 12:27 PM Peter Ross wrote: >> >> --- >> 32-bit target compiler warning. >> >> libavfilter/f_graphmonitor.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c >> index 7052c84d9b..3cb8f73dd3 100644 >> --- a/libavfilter/f_graphmonitor.c >> +++ b/libavfilter/f_graphmonitor.c >> @@ -211,7 +211,7 @@ static void draw_items(AVFilterContext *ctx, AVFrame >> *out, >> snprintf(buffer, sizeof(buffer)-1, " | queue: "); >> drawtext(out, xpos, ypos, buffer, s->white); >> xpos += strlen(buffer) * 8; >> -snprintf(buffer, sizeof(buffer)-1, "%"PRId64, frames); >> +snprintf(buffer, sizeof(buffer)-1, "%zd", frames); > > "%" SIZE_SPECIFIER to be portable. Do recent msvc versions still need this? We don't really support 2012 and older anymore, so maybe %zu (and not %zd as size_t is unsigned) is enough. > >> drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? >> frames >= 50 ? s->red : s->yellow : s->green : s->white); >> xpos += strlen(buffer) * 8; >> } >> -- >> 2.17.1 >> >> -- Peter >> (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/graphmonitor: use %z when printing size_t
2018-11-19 12:34 GMT+01:00, Paul B Mahol : > On 11/19/18, Peter Ross wrote: >> --- >> 32-bit target compiler warning. >> >> libavfilter/f_graphmonitor.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) > > Not acceptable. Where this happens? This happened when you (and others) agreed to a patch adding a function that returns size_t. ff_inlink_queued_frames() is not public so the alternative to this patch is to change the return type or make frames 64bit which seems less straight-forward. (Or it happened when FFFrameQueue->queued was defined size_t.) Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avfilter: add maskfun filter
Signed-off-by: Paul B Mahol --- doc/filters.texi | 27 libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_maskfun.c | 279 +++ 4 files changed, 308 insertions(+) create mode 100644 libavfilter/vf_maskfun.c diff --git a/doc/filters.texi b/doc/filters.texi index a697d3db14..0cbd2ac69c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -11808,6 +11808,33 @@ copied from first stream. By default value 0xf, all planes will be processed. @end table +@section maskfun +Create mask from input video. + +For example it is useful to create motion masks after @code{tblend} filter. + +This filter accepts the following options: + +@table @option +@item low +Set low threshold. Any pixel component lower or exact than this value will be set to 0. + +@item high +Set high threshold. Any pixel component higher than this value will be set to max value +allowed for current pixel format. + +@item planes +Set planes to filter, by default all available planes are filtered. + +@item fill +Fill all frame pixels with this value. + +@item sum +Set max average pixel value for frame. If sum of all pixel components is higher that this +average, output frame will be completely filled with value set by @var{fill} option. +Typically useful for scene changes when used in combination with @code{tblend} filter. +@end table + @section mcdeint Apply motion-compensation deinterlacing. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 6058fb97bc..fe2f42e360 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -277,6 +277,7 @@ OBJS-$(CONFIG_LUTRGB_FILTER) += vf_lut.o OBJS-$(CONFIG_LUTYUV_FILTER) += vf_lut.o OBJS-$(CONFIG_MASKEDCLAMP_FILTER)+= vf_maskedclamp.o framesync.o OBJS-$(CONFIG_MASKEDMERGE_FILTER)+= vf_maskedmerge.o framesync.o +OBJS-$(CONFIG_MASKFUN_FILTER)+= vf_maskfun.o OBJS-$(CONFIG_MCDEINT_FILTER)+= vf_mcdeint.o OBJS-$(CONFIG_MERGEPLANES_FILTER)+= vf_mergeplanes.o framesync.o OBJS-$(CONFIG_MESTIMATE_FILTER) += vf_mestimate.o motion_estimation.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 8dfa572fde..7cd2f187fe 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -263,6 +263,7 @@ extern AVFilter ff_vf_lutrgb; extern AVFilter ff_vf_lutyuv; extern AVFilter ff_vf_maskedclamp; extern AVFilter ff_vf_maskedmerge; +extern AVFilter ff_vf_maskfun; extern AVFilter ff_vf_mcdeint; extern AVFilter ff_vf_mergeplanes; extern AVFilter ff_vf_mestimate; diff --git a/libavfilter/vf_maskfun.c b/libavfilter/vf_maskfun.c new file mode 100644 index 00..a8c6466d22 --- /dev/null +++ b/libavfilter/vf_maskfun.c @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2018 Paul B Mahol + * + * 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/imgutils.h" +#include "libavutil/pixdesc.h" +#include "libavutil/opt.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" + +typedef struct MaskFunContext { +const AVClass *class; + +int low, high; +int planes; +int fill; +int sum; + +int linesize[4]; +int width[4], height[4]; +int nb_planes; +int depth; +int max; +uint64_t max_sum; + +AVFrame *empty; +int (*getsum)(AVFilterContext *ctx, AVFrame *out); +int (*maskfun)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); +} MaskFunContext; + +#define OFFSET(x) offsetof(MaskFunContext, x) +#define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM + +static const AVOption maskfun_options[] = { +{ "low","set low threshold", OFFSET(low),AV_OPT_TYPE_INT, {.i64=10}, 0, UINT16_MAX, VF }, +{ "high", "set high threshold", OFFSET(high), AV_OPT_TYPE_INT, {.i64=10}, 0, UINT16_MAX, VF }, +{ "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF,VF }, +{ "fill", "set fill value", OFFSET(fill), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT16_MAX, VF }, +{ "sum","set sum value", OFFSET(sum),AV_OPT_TYPE_INT, {.i64=10}, 0, UINT16_MAX, VF }, +{ NULL } +}; +
Re: [FFmpeg-devel] [PATCH] avfilter/graphmonitor: use %z when printing size_t
On Mon, Nov 19, 2018 at 12:27 PM Peter Ross wrote: > > --- > 32-bit target compiler warning. > > libavfilter/f_graphmonitor.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c > index 7052c84d9b..3cb8f73dd3 100644 > --- a/libavfilter/f_graphmonitor.c > +++ b/libavfilter/f_graphmonitor.c > @@ -211,7 +211,7 @@ static void draw_items(AVFilterContext *ctx, AVFrame *out, > snprintf(buffer, sizeof(buffer)-1, " | queue: "); > drawtext(out, xpos, ypos, buffer, s->white); > xpos += strlen(buffer) * 8; > -snprintf(buffer, sizeof(buffer)-1, "%"PRId64, frames); > +snprintf(buffer, sizeof(buffer)-1, "%zd", frames); "%" SIZE_SPECIFIER to be portable. > drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames > >= 50 ? s->red : s->yellow : s->green : s->white); > xpos += strlen(buffer) * 8; > } > -- > 2.17.1 > > -- Peter > (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/graphmonitor: use %z when printing size_t
On 11/19/18, Peter Ross wrote: > --- > 32-bit target compiler warning. > > libavfilter/f_graphmonitor.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Not acceptable. Where this happens? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avfilter/graphmonitor: use %z when printing size_t
--- 32-bit target compiler warning. libavfilter/f_graphmonitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c index 7052c84d9b..3cb8f73dd3 100644 --- a/libavfilter/f_graphmonitor.c +++ b/libavfilter/f_graphmonitor.c @@ -211,7 +211,7 @@ static void draw_items(AVFilterContext *ctx, AVFrame *out, snprintf(buffer, sizeof(buffer)-1, " | queue: "); drawtext(out, xpos, ypos, buffer, s->white); xpos += strlen(buffer) * 8; -snprintf(buffer, sizeof(buffer)-1, "%"PRId64, frames); +snprintf(buffer, sizeof(buffer)-1, "%zd", frames); drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white); xpos += strlen(buffer) * 8; } -- 2.17.1 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [FFmpeg-cvslog] lavu: add locale-independent sscanf implementation
Paul B Mahol (2018-11-16): > +off_t shlim, shcnt; All these off_t should have been size_t, or possibly ptrdiff_t. off_t is for offsets in files. Regards, -- Nicolas George ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add chromashift filter
On 11/17/18, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > doc/filters.texi | 17 +++ > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/vf_chromashift.c | 251 +++ > 4 files changed, 270 insertions(+) > create mode 100644 libavfilter/vf_chromashift.c Will apply soon, also with rgbashift. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/3] avcodec/truemotion2: fix integer overflows in tm2_low_chroma()
mån 2018-11-19 klockan 02:02 +0100 skrev Michael Niedermayer: > On Sun, Nov 18, 2018 at 11:32:21PM +0100, Tomas Härdin wrote: > > lör 2018-11-17 klockan 03:01 +0100 skrev Michael Niedermayer: > > > Fixes: > > > 11295/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2_fuzzer-4888953459572736 > > > > > > Found-by: continuous fuzzing process > > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > > > Signed-off-by: Michael Niedermayer > > > > > > --- > > > libavcodec/truemotion2.c | 6 +++--- > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c > > > index 58a577f53c..c583ff4032 100644 > > > --- a/libavcodec/truemotion2.c > > > +++ b/libavcodec/truemotion2.c > > > @@ -484,7 +484,7 @@ static inline void tm2_high_chroma(int *data, int > > > stride, int *last, unsigned *C > > > } > > > } > > > > > > -static inline void tm2_low_chroma(int *data, int stride, int *clast, int > > > *CD, int *deltas, int bx) > > > +static inline void tm2_low_chroma(int *data, int stride, int *clast, > > > unsigned *CD, int *deltas, int bx) > > > { > > > int t; > > > int l; > > > @@ -494,8 +494,8 @@ static inline void tm2_low_chroma(int *data, int > > > stride, int *clast, int *CD, in > > > prev = clast[-3]; > > > else > > > prev = 0; > > > -t= (CD[0] + CD[1]) >> 1; > > > -l= (prev - CD[0] - CD[1] + clast[1]) >> 1; > > > +t= (int)(CD[0] + CD[1]) >> 1; > > > > I presume the old code would overflow for sums exceeding INT_MAX. > > There were overflows in the sense of undefined behavior, yes > > > > Why > > then is there a cast to int before the shift and not after? > > because shifts of signed and unsigned values produce different results > > maybe the unsigned type confused you. CD is signed in a semantic sense its > stored in a unsigned type because otherwise this code has undefined behavior. > It would be better to use a type with different name but that had lead to > long arguments that went nowhere in the past. So i tend to use plain > unsigned now for these kind of cases as it seems that is what most people > prefer. So signed overflow is intended? Huh, weird format. /Tomas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip func
frame-skip is required to implement network bandwidth self-adaptive vaapi encoding. To make a frame skipped, allocate its frame side data of AV_FRAME_DATA_SKIP_FRAME type and set its value to 1. Signed-off-by: Jing SUN --- libavcodec/vaapi_encode.c | 142 -- libavcodec/vaapi_encode.h | 5 ++ libavutil/frame.c | 1 + libavutil/frame.h | 5 ++ 4 files changed, 149 insertions(+), 4 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 2fe8501..a401d61 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -23,6 +23,7 @@ #include "libavutil/common.h" #include "libavutil/log.h" #include "libavutil/pixdesc.h" +#include "libavutil/intreadwrite.h" #include "vaapi_encode.h" #include "avcodec.h" @@ -103,6 +104,47 @@ static int vaapi_encode_make_param_buffer(AVCodecContext *avctx, return 0; } +static int vaapi_encode_check_if_skip(AVCodecContext *avctx, + VAAPIEncodePicture *pic) +{ +AVFrameSideData *fside = NULL; +VAAPIEncodeContext *ctx = avctx->priv_data; +VAAPIEncodePicture *cur = NULL; +int i = 0; + +if (!pic || !pic->input_image) +return AVERROR(EINVAL); + +fside = av_frame_get_side_data(pic->input_image, AV_FRAME_DATA_SKIP_FRAME); +if (fside) +pic->skipped_flag = AV_RL8(fside->data); +else +pic->skipped_flag = 0; + +if (0 == pic->skipped_flag) +return 0; + +if ((pic->type == PICTURE_TYPE_IDR) || (pic->type == PICTURE_TYPE_I)) { +av_log(avctx, AV_LOG_INFO, "Can't skip IDR/I pic %"PRId64"/%"PRId64".\n", + pic->display_order, pic->encode_order); +pic->skipped_flag = 0; +return 0; +} + +for (cur = ctx->pic_start; cur; cur = cur->next) { +for (i=0; i < cur->nb_refs; ++i) { +if (cur->refs[i] == pic) { +av_log(avctx, AV_LOG_INFO, "Can't skip ref pic %"PRId64"/%"PRId64".\n", + pic->display_order, pic->encode_order); +pic->skipped_flag = 0; +return 0; +} +} +} + +return 0; +} + static int vaapi_encode_wait(AVCodecContext *avctx, VAAPIEncodePicture *pic) { @@ -418,6 +460,69 @@ static int vaapi_encode_issue(AVCodecContext *avctx, } } +err = vaapi_encode_check_if_skip(avctx, pic); +if (err != 0) +av_log(avctx, AV_LOG_ERROR, "Fail to check if skip.\n"); + +#ifdef VAEncMiscParameterSkipFrame +if (pic->skipped_flag) { +av_log(avctx, AV_LOG_INFO, "Skip pic %"PRId64"/%"PRId64" as requested.\n", + pic->display_order, pic->encode_order); + +++ctx->skipped_pic_count; +pic->encode_issued = 1; + +return 0; +} else if (ctx->skipped_pic_count > 0) { +VABufferID skip_param_id; +VAEncMiscParameterBuffer *misc_param; +VAEncMiscParameterSkipFrame *skip_param; + +err = vaapi_encode_make_param_buffer(avctx, pic, + VAEncMiscParameterBufferType, NULL, + (sizeof(VAEncMiscParameterBuffer) + + sizeof(VAEncMiscParameterSkipFrame))); +if (err < 0) +goto fail; + +skip_param_id = pic->param_buffers[pic->nb_param_buffers-1]; + +vas = vaMapBuffer(ctx->hwctx->display, + skip_param_id, + (void **)_param); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to map skip-frame buffer: " + "%d (%s).\n", vas, vaErrorStr(vas)); +err = AVERROR(EIO); +goto fail; +} + +misc_param->type = (VAEncMiscParameterType)VAEncMiscParameterTypeSkipFrame; +skip_param = (VAEncMiscParameterSkipFrame *)misc_param->data; +skip_param->skip_frame_flag = 1; +skip_param->num_skip_frames = ctx->skipped_pic_count; +skip_param->size_skip_frames = 0; + +vas = vaUnmapBuffer(ctx->hwctx->display, skip_param_id); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to unmap skip-frame buffer: " + "%d (%s).\n", vas, vaErrorStr(vas)); +err = AVERROR(EIO); +goto fail; +} + +ctx->skipped_pic_count = 0; +} +#else +if (pic->skipped_flag) { +av_log(avctx, AV_LOG_INFO, "Skip-frame isn't supported and pic %"PRId64"/%"PRId64" isn't skipped.\n", + pic->display_order, pic->encode_order); + +pic->skipped_flag = 0; +ctx->skipped_pic_count = 0; +} +#endif + vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context, pic->input_surface); if (vas != VA_STATUS_SUCCESS) { @@ -500,9 +605,28 @@ static int vaapi_encode_output(AVCodecContext *avctx, VAStatus vas; int err; -err =