[FFmpeg-cvslog] avfilter/vf_pixscope: also show standard deviation of zoomed area

2020-04-26 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Apr 26 12:15:12 
2020 +0200| [f53fc935b8b75cd301e8beb8ab8e276034cd3442] | committer: Paul B Mahol

avfilter/vf_pixscope: also show standard deviation of zoomed area

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f53fc935b8b75cd301e8beb8ab8e276034cd3442
---

 libavfilter/vf_datascope.c | 31 ---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_datascope.c b/libavfilter/vf_datascope.c
index e83f04c697..35f60aa2f6 100644
--- a/libavfilter/vf_datascope.c
+++ b/libavfilter/vf_datascope.c
@@ -452,6 +452,8 @@ typedef struct PixscopeContext {
 FFDrawColor   red;
 FFDrawColor  *colors[4];
 
+uint16_t values[4][80][80];
+
 void (*pick_color)(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, 
int x, int y, int *value);
 } PixscopeContext;
 
@@ -526,6 +528,8 @@ static int pixscope_config_input(AVFilterLink *inlink)
 return 0;
 }
 
+#define SQR(x) ((x)*(x))
+
 static int pixscope_filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx  = inlink->dst;
@@ -534,7 +538,7 @@ static int pixscope_filter_frame(AVFilterLink *inlink, 
AVFrame *in)
 AVFrame *out = ff_get_video_buffer(outlink, in->width, in->height);
 int max[4] = { 0 }, min[4] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX };
 float average[4] = { 0 };
-double rms[4] = { 0 };
+double std[4] = { 0 }, rms[4] = { 0 };
 const char rgba[4] = { 'R', 'G', 'B', 'A' };
 const char yuva[4] = { 'Y', 'U', 'V', 'A' };
 int x, y, X, Y, i, w, h;
@@ -591,6 +595,7 @@ static int pixscope_filter_frame(AVFilterLink *inlink, 
AVFrame *in)
 ff_fill_rectangle(&s->draw, &color, out->data, out->linesize,
   x * w + (s->ww - 4 - (s->w * w)) / 2 + X, y * h 
+ 2 + Y, w, h);
 for (i = 0; i < 4; i++) {
+s->values[i][x][y] = value[i];
 rms[i] += (double)value[i] * (double)value[i];
 average[i] += value[i];
 min[i]  = FFMIN(min[i], value[i]);
@@ -637,13 +642,33 @@ static int pixscope_filter_frame(AVFilterLink *inlink, 
AVFrame *in)
 average[i] /= s->w * s->h;
 }
 
+for (y = 0; y < s->h; y++) {
+for (x = 0; x < s->w; x++) {
+for (i = 0; i < 4; i++)
+std[i] += SQR(s->values[i][x][y] - average[i]);
+}
+}
+
+for (i = 0; i < 4; i++) {
+std[i] /= s->w * s->h;
+std[i]  = sqrt(std[i]);
+}
+
 snprintf(text, sizeof(text), "CH   AVGMINMAXRMS\n");
-draw_text(&s->draw, out, &s->white,X + 28, Y + s->ww + 20, 
  text, 0);
+draw_text(&s->draw, out, &s->white,X + 28, Y + s->ww +  5, 
  text, 0);
 for (i = 0; i < s->nb_comps; i++) {
 int c = s->rgba_map[i];
 
 snprintf(text, sizeof(text), "%c  %07.1f %05d %05d %07.1f\n", 
s->is_rgb ? rgba[i] : yuva[i], average[c], min[c], max[c], rms[c]);
-draw_text(&s->draw, out, s->colors[i], X + 28, Y + s->ww + 20 * (i + 
2), text, 0);
+draw_text(&s->draw, out, s->colors[i], X + 28, Y + s->ww + 15 * (i + 
1), text, 0);
+}
+snprintf(text, sizeof(text), "CH   STD\n");
+draw_text(&s->draw, out, &s->white,X + 28, Y + s->ww + 15 * (0 + 
5), text, 0);
+for (i = 0; i < s->nb_comps; i++) {
+int c = s->rgba_map[i];
+
+snprintf(text, sizeof(text), "%c  %07.2f\n", s->is_rgb ? rgba[i] : 
yuva[i], std[c]);
+draw_text(&s->draw, out, s->colors[i], X + 28, Y + s->ww + 15 * (i + 
6), text, 0);
 }
 
 av_frame_free(&in);

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

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

[FFmpeg-cvslog] avformat/movenc: cosmetics

2020-04-26 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Sat Apr 25 
22:29:03 2020 +0800| [0b11ad51727a71f1660b4ed6b7926ea600b05cc7] | committer: 
Michael Niedermayer

avformat/movenc: cosmetics

Signed-off-by: Limin Wang 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0b11ad51727a71f1660b4ed6b7926ea600b05cc7
---

 libavformat/movenc.c | 138 +--
 1 file changed, 69 insertions(+), 69 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 556dd06309..32e8109268 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5738,87 +5738,87 @@ err:
 
 static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
 {
-MOVMuxContext *mov = s->priv_data;
-MOVTrack *trk = &mov->tracks[pkt->stream_index];
-AVCodecParameters *par = trk->par;
-int64_t frag_duration = 0;
-int size = pkt->size;
-
-int ret = check_pkt(s, pkt);
-if (ret < 0)
-return ret;
+MOVMuxContext *mov = s->priv_data;
+MOVTrack *trk = &mov->tracks[pkt->stream_index];
+AVCodecParameters *par = trk->par;
+int64_t frag_duration = 0;
+int size = pkt->size;
 
-if (mov->flags & FF_MOV_FLAG_FRAG_DISCONT) {
-int i;
-for (i = 0; i < s->nb_streams; i++)
-mov->tracks[i].frag_discont = 1;
-mov->flags &= ~FF_MOV_FLAG_FRAG_DISCONT;
-}
+int ret = check_pkt(s, pkt);
+if (ret < 0)
+return ret;
 
-if (mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS) {
-if (trk->dts_shift == AV_NOPTS_VALUE)
-trk->dts_shift = pkt->pts - pkt->dts;
-pkt->dts += trk->dts_shift;
-}
+if (mov->flags & FF_MOV_FLAG_FRAG_DISCONT) {
+int i;
+for (i = 0; i < s->nb_streams; i++)
+mov->tracks[i].frag_discont = 1;
+mov->flags &= ~FF_MOV_FLAG_FRAG_DISCONT;
+}
+
+if (mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS) {
+if (trk->dts_shift == AV_NOPTS_VALUE)
+trk->dts_shift = pkt->pts - pkt->dts;
+pkt->dts += trk->dts_shift;
+}
 
-if (trk->par->codec_id == AV_CODEC_ID_MP4ALS ||
+if (trk->par->codec_id == AV_CODEC_ID_MP4ALS ||
 trk->par->codec_id == AV_CODEC_ID_AAC ||
 trk->par->codec_id == AV_CODEC_ID_AV1 ||
 trk->par->codec_id == AV_CODEC_ID_FLAC) {
-int side_size = 0;
-uint8_t *side = av_packet_get_side_data(pkt, 
AV_PKT_DATA_NEW_EXTRADATA, &side_size);
-if (side && side_size > 0 && (side_size != par->extradata_size || 
memcmp(side, par->extradata, side_size))) {
-void *newextra = av_mallocz(side_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!newextra)
-return AVERROR(ENOMEM);
-av_free(par->extradata);
-par->extradata = newextra;
-memcpy(par->extradata, side, side_size);
-par->extradata_size = side_size;
-if (!pkt->size) // Flush packet
-mov->need_rewrite_extradata = 1;
-}
+int side_size = 0;
+uint8_t *side = av_packet_get_side_data(pkt, 
AV_PKT_DATA_NEW_EXTRADATA, &side_size);
+if (side && side_size > 0 && (side_size != par->extradata_size || 
memcmp(side, par->extradata, side_size))) {
+void *newextra = av_mallocz(side_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
+if (!newextra)
+return AVERROR(ENOMEM);
+av_free(par->extradata);
+par->extradata = newextra;
+memcpy(par->extradata, side, side_size);
+par->extradata_size = side_size;
+if (!pkt->size) // Flush packet
+mov->need_rewrite_extradata = 1;
 }
+}
 
-if (!pkt->size) {
-if (trk->start_dts == AV_NOPTS_VALUE && trk->frag_discont) {
-trk->start_dts = pkt->dts;
-if (pkt->pts != AV_NOPTS_VALUE)
-trk->start_cts = pkt->pts - pkt->dts;
-else
-trk->start_cts = 0;
-}
-
-return 0; /* Discard 0 sized packets */
+if (!pkt->size) {
+if (trk->start_dts == AV_NOPTS_VALUE && trk->frag_discont) {
+trk->start_dts = pkt->dts;
+if (pkt->pts != AV_NOPTS_VALUE)
+trk->start_cts = pkt->pts - pkt->dts;
+else
+trk->start_cts = 0;
 }
 
-if (trk->entry && pkt->stream_index < s->nb_streams)
-frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts,
- 
s->streams[pkt->stream_index]->time_base,
- AV_TIME_BASE_Q);
-if ((mov->max_fragment_duration &&
- frag_duration >= mov->max_fragment_duration) ||
- (mov->max_fragment_size &

[FFmpeg-cvslog] avcodec/cbs_h265_syntax_template: Check num_negative/positive_pics when inter_ref_pic_set_prediction_flag is set

2020-04-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Sun 
Apr  5 00:11:15 2020 +0200| [588114cea4ee434c9c61353ed91ffc817d2965f5] | 
committer: Michael Niedermayer

avcodec/cbs_h265_syntax_template: Check num_negative/positive_pics when 
inter_ref_pic_set_prediction_flag is set

Fixes: out of array access
Fixes: 
20446/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-5707770718584832

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=588114cea4ee434c9c61353ed91ffc817d2965f5
---

 libavcodec/cbs_h265_syntax_template.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 180a045c34..5f5531944c 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -601,6 +601,8 @@ static int FUNC(st_ref_pic_set)(CodedBitstreamContext *ctx, 
RWContext *rw,
 }
 }
 
+if (i > 15)
+return AVERROR_INVALIDDATA;
 infer(num_negative_pics, i);
 for (i = 0; i < current->num_negative_pics; i++) {
 infer(delta_poc_s0_minus1[i],
@@ -630,6 +632,8 @@ static int FUNC(st_ref_pic_set)(CodedBitstreamContext *ctx, 
RWContext *rw,
 }
 }
 
+if (i + current->num_negative_pics > 15)
+return AVERROR_INVALIDDATA;
 infer(num_positive_pics, i);
 for (i = 0; i < current->num_positive_pics; i++) {
 infer(delta_poc_s1_minus1[i],

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

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

[FFmpeg-cvslog] avcodec/intrax8: Check for end of bitstream in ff_intrax8_decode_picture()

2020-04-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Feb  6 00:33:40 2020 +0100| [0a9ccc2514da82812584b0e49a30625151d225e9] | 
committer: Michael Niedermayer

avcodec/intrax8: Check for end of bitstream in ff_intrax8_decode_picture()

Fixes: Timeout (105sec -> 1sec)
Fixes: 
20479/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5769846937878528

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0a9ccc2514da82812584b0e49a30625151d225e9
---

 libavcodec/intrax8.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index d46f97c7a4..f385423dc1 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -801,6 +801,8 @@ int ff_intrax8_decode_picture(IntraX8Context *w, Picture 
*pict,
 for (w->mb_y = 0; w->mb_y < w->mb_height * 2; w->mb_y++) {
 x8_init_block_index(w, w->frame);
 mb_xy = (w->mb_y >> 1) * (w->mb_width + 1);
+if (get_bits_left(gb) < 1)
+goto error;
 for (w->mb_x = 0; w->mb_x < w->mb_width * 2; w->mb_x++) {
 x8_get_prediction(w);
 if (x8_setup_spatial_predictor(w, 0))

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

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

[FFmpeg-cvslog] lavc/qsvenc: Add hardware config metadata

2020-04-26 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Mon Apr 13 16:33:16 
2020 +0100| [5a1ff449071fefa7913858fbe2d084f698443e57] | committer: Mark 
Thompson

lavc/qsvenc: Add hardware config metadata

All of these encoders can accept libmfx surfaces directly in a hardware
frames context, or they can accept software frames if a suitable device
is supplied to use.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5a1ff449071fefa7913858fbe2d084f698443e57
---

 libavcodec/qsvenc.c   | 7 +++
 libavcodec/qsvenc.h   | 3 +++
 libavcodec/qsvenc_h264.c  | 1 +
 libavcodec/qsvenc_hevc.c  | 1 +
 libavcodec/qsvenc_jpeg.c  | 1 +
 libavcodec/qsvenc_mpeg2.c | 1 +
 libavcodec/qsvenc_vp9.c   | 1 +
 7 files changed, 15 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index afab8fd715..9ec0636dde 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1652,3 +1652,10 @@ int ff_qsv_enc_close(AVCodecContext *avctx, 
QSVEncContext *q)
 
 return 0;
 }
+
+const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[] = {
+HW_CONFIG_ENCODER_FRAMES(QSV,  QSV),
+HW_CONFIG_ENCODER_DEVICE(NV12, QSV),
+HW_CONFIG_ENCODER_DEVICE(P010, QSV),
+NULL,
+};
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 6609171af3..4f579d1db1 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -32,6 +32,7 @@
 #include "libavutil/fifo.h"
 
 #include "avcodec.h"
+#include "hwconfig.h"
 #include "qsv_internal.h"
 
 #define QSV_HAVE_CO2 QSV_VERSION_ATLEAST(1, 6)
@@ -97,6 +98,8 @@
 { "forced_idr", "Forcing I frames as IDR frames", 
OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 = 0  },  0,  1, VE 
}, \
 { "low_power", "enable low power mode(experimental: many limitations by mfx 
version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = 
0}, 0, 1, VE},\
 
+extern const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[];
+
 typedef int SetEncodeCtrlCB (AVCodecContext *avctx,
  const AVFrame *frame, mfxEncodeCtrl* enc_ctrl);
 typedef struct QSVEncContext {
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 27f36b9f7b..364975bea5 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -197,4 +197,5 @@ AVCodec ff_h264_qsv_encoder = {
 .defaults   = qsv_enc_defaults,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .wrapper_name   = "qsv",
+.hw_configs = ff_qsv_enc_hw_configs,
 };
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 27e2232a9f..36e5ef6052 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -288,4 +288,5 @@ AVCodec ff_hevc_qsv_encoder = {
 .defaults   = qsv_enc_defaults,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .wrapper_name   = "qsv",
+.hw_configs = ff_qsv_enc_hw_configs,
 };
diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c
index 1619a335c7..f76af9486b 100644
--- a/libavcodec/qsvenc_jpeg.c
+++ b/libavcodec/qsvenc_jpeg.c
@@ -95,4 +95,5 @@ AVCodec ff_mjpeg_qsv_encoder = {
 .priv_class = &class,
 .defaults   = qsv_enc_defaults,
 .wrapper_name   = "qsv",
+.hw_configs = ff_qsv_enc_hw_configs,
 };
diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c
index e4ade56d62..0e34bb75dc 100644
--- a/libavcodec/qsvenc_mpeg2.c
+++ b/libavcodec/qsvenc_mpeg2.c
@@ -112,4 +112,5 @@ AVCodec ff_mpeg2_qsv_encoder = {
 .defaults   = qsv_enc_defaults,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .wrapper_name   = "qsv",
+.hw_configs = ff_qsv_enc_hw_configs,
 };
diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c
index 9402f806b1..ce44c09397 100644
--- a/libavcodec/qsvenc_vp9.c
+++ b/libavcodec/qsvenc_vp9.c
@@ -110,4 +110,5 @@ AVCodec ff_vp9_qsv_encoder = {
 .defaults   = qsv_enc_defaults,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .wrapper_name   = "qsv",
+.hw_configs = ff_qsv_enc_hw_configs,
 };

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

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

[FFmpeg-cvslog] ffmpeg: Make filter hardware device selection clearer

2020-04-26 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Mon Apr 13 16:33:19 
2020 +0100| [e2542124059f5960ac2bbd94183012814263f20d] | committer: Mark 
Thompson

ffmpeg: Make filter hardware device selection clearer

Also move it into a dedicated function in the hardware file.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e2542124059f5960ac2bbd94183012814263f20d
---

 fftools/ffmpeg.h|  1 +
 fftools/ffmpeg_filter.c | 14 +++---
 fftools/ffmpeg_hw.c | 28 
 3 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index fbaae15377..43b5040f73 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -661,6 +661,7 @@ void hw_device_free_all(void);
 
 int hw_device_setup_for_decode(InputStream *ist);
 int hw_device_setup_for_encode(OutputStream *ost);
+int hw_device_setup_for_filter(FilterGraph *fg);
 
 int hwaccel_decode_init(AVCodecContext *avctx);
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index b66faa50b5..8b5b157be7 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1061,17 +1061,9 @@ int configure_filtergraph(FilterGraph *fg)
 if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, 
&outputs)) < 0)
 goto fail;
 
-if (filter_hw_device || hw_device_ctx) {
-AVBufferRef *device = filter_hw_device ? filter_hw_device->device_ref
-   : hw_device_ctx;
-for (i = 0; i < fg->graph->nb_filters; i++) {
-fg->graph->filters[i]->hw_device_ctx = av_buffer_ref(device);
-if (!fg->graph->filters[i]->hw_device_ctx) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-}
-}
+ret = hw_device_setup_for_filter(fg);
+if (ret < 0)
+goto fail;
 
 if (simple && (!inputs || inputs->next || !outputs || outputs->next)) {
 const char *num_inputs;
diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c
index 962d8f7d5a..40739fc320 100644
--- a/fftools/ffmpeg_hw.c
+++ b/fftools/ffmpeg_hw.c
@@ -480,3 +480,31 @@ int hwaccel_decode_init(AVCodecContext *avctx)
 
 return 0;
 }
+
+int hw_device_setup_for_filter(FilterGraph *fg)
+{
+HWDevice *dev;
+int i;
+
+// If the user has supplied exactly one hardware device then just
+// give it straight to every filter for convenience.  If more than
+// one device is available then the user needs to pick one explcitly
+// with the filter_hw_device option.
+if (filter_hw_device)
+dev = filter_hw_device;
+else if (nb_hw_devices == 1)
+dev = hw_devices[0];
+else
+dev = NULL;
+
+if (dev) {
+for (i = 0; i < fg->graph->nb_filters; i++) {
+fg->graph->filters[i]->hw_device_ctx =
+av_buffer_ref(dev->device_ref);
+if (!fg->graph->filters[i]->hw_device_ctx)
+return AVERROR(ENOMEM);
+}
+}
+
+return 0;
+}

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

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

[FFmpeg-cvslog] lavc: Extend hardware config metadata to encoders

2020-04-26 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Mon Apr 13 16:33:15 
2020 +0100| [858eba0ca4b680ce23c4eebd1460db333989b0a4] | committer: Mark 
Thompson

lavc: Extend hardware config metadata to encoders

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=858eba0ca4b680ce23c4eebd1460db333989b0a4
---

 libavcodec/avcodec.h  | 11 ++-
 libavcodec/hwconfig.h | 18 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b79b025e53..2bce39f94b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2541,6 +2541,10 @@ enum {
  * AVCodecContext.hw_frames_ctx should be set to a suitable frames
  * context inside the get_format() callback.  The frames context
  * must have been created on a device of the specified type.
+ *
+ * When selecting this format for an encoder,
+ * AVCodecContext.hw_frames_ctx should be set to the context which
+ * will be used for the input frames before calling avcodec_open2().
  */
 AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02,
 /**
@@ -2563,7 +2567,12 @@ enum {
 
 typedef struct AVCodecHWConfig {
 /**
- * A hardware pixel format which the codec can use.
+ * For decoders, a hardware pixel format which that decoder may be
+ * able to decode to if suitable hardware is available.
+ *
+ * For encoders, a pixel format which the encoder may be able to
+ * accept.  If set to AV_PIX_FMT_NONE, this applies to all pixel
+ * formats supported by the codec.
  */
 enum AVPixelFormat pix_fmt;
 /**
diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h
index 4199ffdd50..f421dc909f 100644
--- a/libavcodec/hwconfig.h
+++ b/libavcodec/hwconfig.h
@@ -81,4 +81,22 @@ typedef struct AVCodecHWConfigInternal {
 #define HWACCEL_XVMC(codec) \
 HW_CONFIG_HWACCEL(0, 0, 1, XVMC, NONE, ff_ ## codec ## 
_xvmc_hwaccel)
 
+#define HW_CONFIG_ENCODER(device, frames, ad_hoc, format, device_type_) \
+&(const AVCodecHWConfigInternal) { \
+.public  = { \
+.pix_fmt = AV_PIX_FMT_ ## format, \
+.methods = (device ? AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX : 
0) | \
+   (frames ? AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX : 
0) | \
+   (ad_hoc ? AV_CODEC_HW_CONFIG_METHOD_AD_HOC: 
0),  \
+.device_type = AV_HWDEVICE_TYPE_ ## device_type_, \
+}, \
+.hwaccel = NULL, \
+}
+
+#define HW_CONFIG_ENCODER_DEVICE(format, device_type_) \
+HW_CONFIG_ENCODER(1, 0, 0, format, device_type_)
+
+#define HW_CONFIG_ENCODER_FRAMES(format, device_type_) \
+HW_CONFIG_ENCODER(0, 1, 0, format, device_type_)
+
 #endif /* AVCODEC_HWCONFIG_H */

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

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

[FFmpeg-cvslog] ffmpeg: Remove the hw_device_ctx global

2020-04-26 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Mon Apr 13 16:33:21 
2020 +0100| [79c173cc1900c735b1e256f5755b3e434a080a4f] | committer: Mark 
Thompson

ffmpeg: Remove the hw_device_ctx global

The ad-hoc libmfx setup code is the only place its still used, so move it
into that file.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79c173cc1900c735b1e256f5755b3e434a080a4f
---

 fftools/ffmpeg.c |  1 -
 fftools/ffmpeg.h |  1 -
 fftools/ffmpeg_opt.c | 11 ++-
 fftools/ffmpeg_qsv.c |  1 +
 4 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 2287af59f0..cf64837b8a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4759,7 +4759,6 @@ static int transcode(void)
 }
 }
 
-av_buffer_unref(&hw_device_ctx);
 hw_device_free_all();
 
 /* finished ! */
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 43b5040f73..98700f24e5 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -615,7 +615,6 @@ extern const AVIOInterruptCB int_cb;
 
 extern const OptionDef options[];
 extern const HWAccel hwaccels[];
-extern AVBufferRef *hw_device_ctx;
 #if CONFIG_QSV
 extern char *qsv_device;
 #endif
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 680f0f1dfb..16e321b5a3 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -139,7 +139,6 @@ const HWAccel hwaccels[] = {
 #endif
 { 0 },
 };
-AVBufferRef *hw_device_ctx;
 HWDevice *filter_hw_device;
 
 char *vstats_filename;
@@ -536,21 +535,15 @@ static int opt_sdp_file(void *optctx, const char *opt, 
const char *arg)
 #if CONFIG_VAAPI
 static int opt_vaapi_device(void *optctx, const char *opt, const char *arg)
 {
-HWDevice *dev;
 const char *prefix = "vaapi:";
 char *tmp;
 int err;
 tmp = av_asprintf("%s%s", prefix, arg);
 if (!tmp)
 return AVERROR(ENOMEM);
-err = hw_device_init_from_string(tmp, &dev);
+err = hw_device_init_from_string(tmp, NULL);
 av_free(tmp);
-if (err < 0)
-return err;
-hw_device_ctx = av_buffer_ref(dev->device_ref);
-if (!hw_device_ctx)
-return AVERROR(ENOMEM);
-return 0;
+return err;
 }
 #endif
 
diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c
index 9c4285b6c7..960c88b69d 100644
--- a/fftools/ffmpeg_qsv.c
+++ b/fftools/ffmpeg_qsv.c
@@ -28,6 +28,7 @@
 
 #include "ffmpeg.h"
 
+static AVBufferRef *hw_device_ctx;
 char *qsv_device = NULL;
 
 static int qsv_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)

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

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

[FFmpeg-cvslog] ffmpeg: Use hardware config metadata with encoders

2020-04-26 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Mon Apr 13 16:33:20 
2020 +0100| [8abd3b202821e9c491f44d097686402aafdda7c5] | committer: Mark 
Thompson

ffmpeg: Use hardware config metadata with encoders

This can support encoders which want frames and/or device contexts.  For
the device case, it currently picks the first initialised device of the
desired type to give to the encoder - a new option would be needed if it
were necessary to choose between multiple devices of the same type.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8abd3b202821e9c491f44d097686402aafdda7c5
---

 fftools/ffmpeg.c| 19 ++-
 fftools/ffmpeg_hw.c | 48 
 2 files changed, 46 insertions(+), 21 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d896b14a14..2287af59f0 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3476,21 +3476,14 @@ static int init_output_stream(OutputStream *ost, char 
*error, int error_len)
 !av_dict_get(ost->encoder_opts, "ab", NULL, 0))
 av_dict_set(&ost->encoder_opts, "b", "128000", 0);
 
-if (ost->filter && 
av_buffersink_get_hw_frames_ctx(ost->filter->filter) &&
-
((AVHWFramesContext*)av_buffersink_get_hw_frames_ctx(ost->filter->filter)->data)->format
 ==
-av_buffersink_get_format(ost->filter->filter)) {
-ost->enc_ctx->hw_frames_ctx = 
av_buffer_ref(av_buffersink_get_hw_frames_ctx(ost->filter->filter));
-if (!ost->enc_ctx->hw_frames_ctx)
-return AVERROR(ENOMEM);
-} else {
-ret = hw_device_setup_for_encode(ost);
-if (ret < 0) {
-snprintf(error, error_len, "Device setup failed for "
- "encoder on output stream #%d:%d : %s",
+ret = hw_device_setup_for_encode(ost);
+if (ret < 0) {
+snprintf(error, error_len, "Device setup failed for "
+ "encoder on output stream #%d:%d : %s",
  ost->file_index, ost->index, av_err2str(ret));
-return ret;
-}
+return ret;
 }
+
 if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && ost->enc->type 
== AVMEDIA_TYPE_SUBTITLE) {
 int input_props = 0, output_props = 0;
 AVCodecDescriptor const *input_descriptor =
diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c
index 40739fc320..c5c8aa97ef 100644
--- a/fftools/ffmpeg_hw.c
+++ b/fftools/ffmpeg_hw.c
@@ -19,6 +19,7 @@
 #include 
 
 #include "libavutil/avstring.h"
+#include "libavfilter/buffersink.h"
 
 #include "ffmpeg.h"
 
@@ -281,7 +282,10 @@ void hw_device_free_all(void)
 nb_hw_devices = 0;
 }
 
-static HWDevice *hw_device_match_by_codec(const AVCodec *codec)
+static HWDevice *hw_device_match_by_codec(const AVCodec *codec,
+  enum AVPixelFormat format,
+  int possible_methods,
+  int *matched_methods)
 {
 const AVCodecHWConfig *config;
 HWDevice *dev;
@@ -290,11 +294,18 @@ static HWDevice *hw_device_match_by_codec(const AVCodec 
*codec)
 config = avcodec_get_hw_config(codec, i);
 if (!config)
 return NULL;
-if (!(config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX))
+if (format != AV_PIX_FMT_NONE &&
+config->pix_fmt != AV_PIX_FMT_NONE &&
+config->pix_fmt != format)
+continue;
+if (!(config->methods & possible_methods))
 continue;
 dev = hw_device_get_by_type(config->device_type);
-if (dev)
+if (dev) {
+if (matched_methods)
+*matched_methods = config->methods & possible_methods;
 return dev;
+}
 }
 }
 
@@ -340,7 +351,9 @@ int hw_device_setup_for_decode(InputStream *ist)
 if (!dev)
 err = hw_device_init_from_type(type, NULL, &dev);
 } else {
-dev = hw_device_match_by_codec(ist->dec);
+dev = hw_device_match_by_codec(ist->dec, AV_PIX_FMT_NONE,
+   
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX,
+   NULL);
 if (!dev) {
 // No device for this codec, but not using generic hwaccel
 // and therefore may well not need one - ignore.
@@ -417,12 +430,31 @@ int hw_device_setup_for_decode(InputStream *ist)
 int hw_device_setup_for_encode(OutputStream *ost)
 {
 HWDevice *dev;
+AVBufferRef *frames_ref;
+int methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX;
+int matched_methods;
+
+if (ost->filter) {
+frames_ref = av_buffersink_get_hw_frames_ctx(ost->filter->filter);
+if (frames_ref &&
+((AVHWFramesContext*)frames_ref->data)->format ==
+ost->enc_ctx->pix_fmt)
+methods |= AV_CODEC_HW_C

[FFmpeg-cvslog] lavc: Rename hwaccel.h to hwconfig.h

2020-04-26 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Mon Apr 13 16:33:14 
2020 +0100| [2594f6a362c788a036dbf3e27d540d15fe7f72d0] | committer: Mark 
Thompson

lavc: Rename hwaccel.h to hwconfig.h

This already applied to decoders as well as hwaccels, and adding encoder
support was going to make the name even more inaccurate.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2594f6a362c788a036dbf3e27d540d15fe7f72d0
---

 libavcodec/cuviddec.c| 2 +-
 libavcodec/decode.c  | 2 +-
 libavcodec/h263dec.c | 2 +-
 libavcodec/h264dec.c | 2 +-
 libavcodec/hevcdec.c | 2 +-
 libavcodec/{hwaccel.h => hwconfig.h} | 6 +++---
 libavcodec/mediacodecdec.c   | 2 +-
 libavcodec/mjpegdec.c| 2 +-
 libavcodec/mmaldec.c | 2 +-
 libavcodec/mpeg12dec.c   | 2 +-
 libavcodec/mpeg4videodec.c   | 2 +-
 libavcodec/pthread_frame.c   | 2 +-
 libavcodec/qsvdec.h  | 2 +-
 libavcodec/rkmppdec.c| 2 +-
 libavcodec/utils.c   | 2 +-
 libavcodec/vaapi_h264.c  | 2 +-
 libavcodec/vaapi_hevc.c  | 2 +-
 libavcodec/vaapi_mjpeg.c | 2 +-
 libavcodec/vaapi_mpeg2.c | 2 +-
 libavcodec/vaapi_mpeg4.c | 2 +-
 libavcodec/vaapi_vc1.c   | 2 +-
 libavcodec/vaapi_vp8.c   | 2 +-
 libavcodec/vaapi_vp9.c   | 2 +-
 libavcodec/vc1dec.c  | 2 +-
 libavcodec/vdpau_h264.c  | 2 +-
 libavcodec/vdpau_hevc.c  | 2 +-
 libavcodec/vdpau_mpeg12.c| 2 +-
 libavcodec/vdpau_mpeg4.c | 2 +-
 libavcodec/vdpau_vc1.c   | 2 +-
 libavcodec/vdpau_vp9.c   | 2 +-
 libavcodec/vp8.c | 2 +-
 libavcodec/vp9.c | 2 +-
 32 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 50dc8956c3..9477b8fd3a 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -33,7 +33,7 @@
 
 #include "avcodec.h"
 #include "decode.h"
-#include "hwaccel.h"
+#include "hwconfig.h"
 #include "nvdec.h"
 #include "internal.h"
 
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index d4bdb9b1c0..2094095eca 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -41,7 +41,7 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "decode.h"
-#include "hwaccel.h"
+#include "hwconfig.h"
 #include "internal.h"
 #include "thread.h"
 
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 8ee844e298..31ac563f43 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -33,7 +33,7 @@
 #include "flv.h"
 #include "h263.h"
 #include "h263_parser.h"
-#include "hwaccel.h"
+#include "hwconfig.h"
 #include "internal.h"
 #include "mpeg_er.h"
 #include "mpeg4video.h"
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index e374f32e91..4c355feb18 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -46,7 +46,7 @@
 #include "h264_mvpred.h"
 #include "h264_ps.h"
 #include "golomb.h"
-#include "hwaccel.h"
+#include "hwconfig.h"
 #include "mathops.h"
 #include "me_cmp.h"
 #include "mpegutils.h"
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 36be83948e..78299f4b32 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -41,7 +41,7 @@
 #include "hevc_data.h"
 #include "hevc_parse.h"
 #include "hevcdec.h"
-#include "hwaccel.h"
+#include "hwconfig.h"
 #include "profiles.h"
 
 const uint8_t ff_hevc_pel_weight[65] = { [2] = 0, [4] = 1, [6] = 2, [8] = 3, 
[12] = 4, [16] = 5, [24] = 6, [32] = 7, [48] = 8, [64] = 9 };
diff --git a/libavcodec/hwaccel.h b/libavcodec/hwconfig.h
similarity index 97%
rename from libavcodec/hwaccel.h
rename to libavcodec/hwconfig.h
index 3aaa92571c..4199ffdd50 100644
--- a/libavcodec/hwaccel.h
+++ b/libavcodec/hwconfig.h
@@ -16,8 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_HWACCEL_H
-#define AVCODEC_HWACCEL_H
+#ifndef AVCODEC_HWCONFIG_H
+#define AVCODEC_HWCONFIG_H
 
 #include "avcodec.h"
 #include "hwaccels.h"
@@ -81,4 +81,4 @@ typedef struct AVCodecHWConfigInternal {
 #define HWACCEL_XVMC(codec) \
 HW_CONFIG_HWACCEL(0, 0, 1, XVMC, NONE, ff_ ## codec ## 
_xvmc_hwaccel)
 
-#endif /* AVCODEC_HWACCEL_H */
+#endif /* AVCODEC_HWCONFIG_H */
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index f5771bffb1..25410021e8 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -34,7 +34,7 @@
 #include "decode.h"
 #include "h264_parse.h"
 #include "hevc_parse.h"
-#include "hwaccel.h"
+#include "hwconfig.h"
 #include "internal.h"
 #include "mediacodec_wrapper.h"
 #include "mediacodecdec_common.h"
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index d5e7c21610..cb5e2a9b9b 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -36,7 +36,7 @@
 #incl

[FFmpeg-cvslog] lavc/vaapi_encode: Add hardware config metadata

2020-04-26 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Mon Apr 13 16:33:17 
2020 +0100| [344e6c3ff1b47279ffb360aba3f5e10183bc4eb4] | committer: Mark 
Thompson

lavc/vaapi_encode: Add hardware config metadata

These encoders all accept VAAPI surfaces in a hardware frames context.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=344e6c3ff1b47279ffb360aba3f5e10183bc4eb4
---

 libavcodec/vaapi_encode.c   | 5 +
 libavcodec/vaapi_encode.h   | 3 +++
 libavcodec/vaapi_encode_h264.c  | 1 +
 libavcodec/vaapi_encode_h265.c  | 1 +
 libavcodec/vaapi_encode_mjpeg.c | 1 +
 libavcodec/vaapi_encode_mpeg2.c | 1 +
 libavcodec/vaapi_encode_vp8.c   | 1 +
 libavcodec/vaapi_encode_vp9.c   | 1 +
 8 files changed, 14 insertions(+)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 8ff720e395..f551967ad6 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -27,6 +27,11 @@
 #include "vaapi_encode.h"
 #include "avcodec.h"
 
+const AVCodecHWConfigInternal *ff_vaapi_encode_hw_configs[] = {
+HW_CONFIG_ENCODER_FRAMES(VAAPI, VAAPI),
+NULL,
+};
+
 static const char * const picture_type_name[] = { "IDR", "I", "P", "B" };
 
 static int vaapi_encode_make_packed_header(AVCodecContext *avctx,
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index b9a3defd72..1329f6428f 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -31,6 +31,7 @@
 #include "libavutil/hwcontext_vaapi.h"
 
 #include "avcodec.h"
+#include "hwconfig.h"
 
 struct VAAPIEncodeType;
 struct VAAPIEncodePicture;
@@ -44,6 +45,8 @@ enum {
 MAX_PARAM_BUFFER_SIZE  = 1024,
 };
 
+extern const AVCodecHWConfigInternal *ff_vaapi_encode_hw_configs[];
+
 enum {
 PICTURE_TYPE_IDR = 0,
 PICTURE_TYPE_I   = 1,
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index f4965d8b09..67b1ecae1b 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -1361,5 +1361,6 @@ AVCodec ff_h264_vaapi_encoder = {
 AV_PIX_FMT_VAAPI,
 AV_PIX_FMT_NONE,
 },
+.hw_configs = ff_vaapi_encode_hw_configs,
 .wrapper_name   = "vaapi",
 };
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 97dc5a7e75..e20e8cbdd0 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -1297,5 +1297,6 @@ AVCodec ff_hevc_vaapi_encoder = {
 AV_PIX_FMT_VAAPI,
 AV_PIX_FMT_NONE,
 },
+.hw_configs = ff_vaapi_encode_hw_configs,
 .wrapper_name   = "vaapi",
 };
diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c
index bd029cc903..2b5d3bf4f9 100644
--- a/libavcodec/vaapi_encode_mjpeg.c
+++ b/libavcodec/vaapi_encode_mjpeg.c
@@ -570,5 +570,6 @@ AVCodec ff_mjpeg_vaapi_encoder = {
 AV_PIX_FMT_VAAPI,
 AV_PIX_FMT_NONE,
 },
+.hw_configs = ff_vaapi_encode_hw_configs,
 .wrapper_name   = "vaapi",
 };
diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c
index bac9ea1fa6..0398c4cd8c 100644
--- a/libavcodec/vaapi_encode_mpeg2.c
+++ b/libavcodec/vaapi_encode_mpeg2.c
@@ -707,5 +707,6 @@ AVCodec ff_mpeg2_vaapi_encoder = {
 AV_PIX_FMT_VAAPI,
 AV_PIX_FMT_NONE,
 },
+.hw_configs = ff_vaapi_encode_hw_configs,
 .wrapper_name   = "vaapi",
 };
diff --git a/libavcodec/vaapi_encode_vp8.c b/libavcodec/vaapi_encode_vp8.c
index 6e7bf9d106..16cbcbd81c 100644
--- a/libavcodec/vaapi_encode_vp8.c
+++ b/libavcodec/vaapi_encode_vp8.c
@@ -262,5 +262,6 @@ AVCodec ff_vp8_vaapi_encoder = {
 AV_PIX_FMT_VAAPI,
 AV_PIX_FMT_NONE,
 },
+.hw_configs = ff_vaapi_encode_hw_configs,
 .wrapper_name   = "vaapi",
 };
diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c
index d7f415d704..d05319ef39 100644
--- a/libavcodec/vaapi_encode_vp9.c
+++ b/libavcodec/vaapi_encode_vp9.c
@@ -296,5 +296,6 @@ AVCodec ff_vp9_vaapi_encoder = {
 AV_PIX_FMT_VAAPI,
 AV_PIX_FMT_NONE,
 },
+.hw_configs = ff_vaapi_encode_hw_configs,
 .wrapper_name   = "vaapi",
 };

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

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

[FFmpeg-cvslog] fate: hevc: Skip a few large testcases if large tests are disabled

2020-04-26 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Thu Apr 23 
10:15:03 2020 +0300| [499f43ae90c0b03264e874c199a5904280766782] | committer: 
Martin Storsjö

fate: hevc: Skip a few large testcases if large tests are disabled

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=499f43ae90c0b03264e874c199a5904280766782
---

 tests/fate/hevc.mak | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 35af3e43ac..65c5a262e9 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -160,6 +160,8 @@ HEVC_SAMPLES_422_10BIT =\
 
 HEVC_SAMPLES_422_10BIN =\
 Main_422_10_A_RExt_Sony_1   \
+
+HEVC_SAMPLES_422_10BIN_LARGE =  \
 Main_422_10_B_RExt_Sony_1   \
 
 HEVC_SAMPLES_444_8BIT = \
@@ -169,6 +171,8 @@ HEVC_SAMPLES_444_12BIT =\
 IPCM_B_RExt_NEC \
 PERSIST_RPARAM_A_RExt_Sony_1\
 PERSIST_RPARAM_A_RExt_Sony_3\
+
+HEVC_SAMPLES_444_12BIT_LARGE =  \
 SAO_A_RExt_MediaTek_1   \
 
 
@@ -206,6 +210,11 @@ FATE_HEVC += fate-hevc-conformance-$(1)
 fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bin -pix_fmt yuv422p10le
 endef
 
+define FATE_HEVC_TEST_422_10BIN_LARGE
+FATE_HEVC_LARGE += fate-hevc-conformance-$(1)
+fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bin -pix_fmt yuv422p10le
+endef
+
 define FATE_HEVC_TEST_444_8BIT
 FATE_HEVC += fate-hevc-conformance-$(1)
 fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv444p
@@ -216,15 +225,22 @@ FATE_HEVC += fate-hevc-conformance-$(1)
 fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv444p12le
 endef
 
+define FATE_HEVC_TEST_444_12BIT_LARGE
+FATE_HEVC_LARGE += fate-hevc-conformance-$(1)
+fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv444p12le
+endef
+
 $(foreach N,$(HEVC_SAMPLES),$(eval $(call FATE_HEVC_TEST,$(N
 $(foreach N,$(HEVC_SAMPLES_10BIT),$(eval $(call FATE_HEVC_TEST_10BIT,$(N
 $(foreach N,$(HEVC_SAMPLES_422_10BIT),$(eval $(call 
FATE_HEVC_TEST_422_10BIT,$(N
 $(foreach N,$(HEVC_SAMPLES_422_10BIN),$(eval $(call 
FATE_HEVC_TEST_422_10BIN,$(N
+$(foreach N,$(HEVC_SAMPLES_422_10BIN_LARGE),$(eval $(call 
FATE_HEVC_TEST_422_10BIN_LARGE,$(N
 $(foreach N,$(HEVC_SAMPLES_444_8BIT),$(eval $(call 
FATE_HEVC_TEST_444_8BIT,$(N
 $(foreach N,$(HEVC_SAMPLES_444_12BIT),$(eval $(call 
FATE_HEVC_TEST_444_12BIT,$(N
+$(foreach N,$(HEVC_SAMPLES_444_12BIT_LARGE),$(eval $(call 
FATE_HEVC_TEST_444_12BIT_LARGE,$(N
 
 fate-hevc-paramchange-yuv420p-yuv420p10: CMD = framecrc -vsync 0 -i 
$(TARGET_SAMPLES)/hevc/paramchange_yuv420p_yuv420p10.hevc -sws_flags 
area+accurate_rnd+bitexact
-FATE_HEVC += fate-hevc-paramchange-yuv420p-yuv420p10
+FATE_HEVC_LARGE += fate-hevc-paramchange-yuv420p-yuv420p10
 
 tests/data/hevc-mp4.mov: TAG = GEN
 tests/data/hevc-mp4.mov: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
@@ -241,6 +257,7 @@ fate-hevc-skiploopfilter: CMD = framemd5 -skip_loop_filter 
nokey -i $(TARGET_SAM
 FATE_HEVC += fate-hevc-skiploopfilter
 
 FATE_HEVC-$(call DEMDEC, HEVC, HEVC) += $(FATE_HEVC)
+FATE_HEVC-$(call ALLYES, HEVC_DEMUXER HEVC_DECODER LARGE_TESTS) += 
$(FATE_HEVC_LARGE)
 
 # this sample has two stsd entries and needs to reload extradata
 FATE_HEVC-$(call DEMDEC, MOV, HEVC) += fate-hevc-extradata-reload

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

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

[FFmpeg-cvslog] fate: Skip the dnxhd-uhd-hr-sq tests of large tests are disabled

2020-04-26 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Thu Apr 23 
10:13:06 2020 +0300| [02b74bd76a967741b0f4adf799d535350e13ce8b] | committer: 
Martin Storsjö

fate: Skip the dnxhd-uhd-hr-sq tests of large tests are disabled

These tests are also in the same size range as the previously
skipped 2k and 4k tests.

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=02b74bd76a967741b0f4adf799d535350e13ce8b
---

 tests/fate/vcodec.mak | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index fc27da5456..ec2a9c339d 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -29,13 +29,14 @@ FATE_VCODEC-$(call ENCDEC, DNXHD, DNXHD) += dnxhd-720p  
\
 dnxhd-720p-rd   \
 dnxhd-720p-10bit\
 dnxhd-720p-hr-lb\
-dnxhd-uhd-hr-sq \
 dnxhd-edge1-hr  \
 dnxhd-edge2-hr  \
 dnxhd-edge3-hr
 
 FATE_VCODEC-$(call ALLYES, DNXHD_ENCODER DNXHD_DECODER LARGE_TESTS) += 
dnxhd-4k-hr-lb \
-   
dnxhd-2k-hr-hq
+   
dnxhd-2k-hr-hq \
+   
dnxhd-uhd-hr-sq
+
 
 FATE_VCODEC-$(call ENCDEC, VC2 DIRAC, MOV) += vc2-420p vc2-420p10 vc2-420p12 \
   vc2-422p vc2-422p10 vc2-422p12 \

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

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

[FFmpeg-cvslog] avformat: only allow a single bitstream filter when muxing

2020-04-26 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Sat Apr 18 10:49:54 
2020 +0200| [1128aa875367f66ac11adc30364d5652919a2591] | committer: Marton 
Balint

avformat: only allow a single bitstream filter when muxing

Current muxers only use a single bitstream filter, so there is no need to
maintain code which operates on a list of bitstream filters. When multiple
bitstream filters are needed muxers can simply use a list bitstream filter.

If there is a use case in the future when different bitstream filters should be
added at subsequent packets then a new API possibly involving reconfiguring the
list bitstream filter can be added knowing the exact requirements.

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1128aa875367f66ac11adc30364d5652919a2591
---

 libavformat/dashenc.c  |  6 ++
 libavformat/internal.h |  5 ++---
 libavformat/mux.c  |  6 +++---
 libavformat/segment.c  |  6 ++
 libavformat/utils.c| 24 ++--
 5 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index b08253618d..9f83785792 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -2325,10 +2325,8 @@ static int dash_check_bitstream(struct AVFormatContext 
*s, const AVPacket *avpkt
 if (ret == 1) {
 AVStream *st = s->streams[avpkt->stream_index];
 AVStream *ost = oc->streams[0];
-st->internal->bsfcs = ost->internal->bsfcs;
-st->internal->nb_bsfcs = ost->internal->nb_bsfcs;
-ost->internal->bsfcs = NULL;
-ost->internal->nb_bsfcs = 0;
+st->internal->bsfc = ost->internal->bsfc;
+ost->internal->bsfc = NULL;
 }
 return ret;
 }
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 329b2e972d..6786b732ac 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -152,12 +152,11 @@ struct AVStreamInternal {
 int reorder;
 
 /**
- * bitstream filters to run on stream
+ * bitstream filter to run on stream
  * - encoding: Set by muxer using ff_stream_add_bitstream_filter
  * - decoding: unused
  */
-AVBSFContext **bsfcs;
-int nb_bsfcs;
+AVBSFContext *bsfc;
 
 /**
  * Whether or not check_bitstream should still be run on each packet
diff --git a/libavformat/mux.c b/libavformat/mux.c
index c348b8fdc8..3d1f71ab1a 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -811,7 +811,7 @@ static int prepare_input_packet(AVFormatContext *s, 
AVPacket *pkt)
 
 static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) {
 AVStream *st = s->streams[pkt->stream_index];
-int i, ret;
+int ret;
 
 if (!(s->flags & AVFMT_FLAG_AUTO_BSF))
 return 1;
@@ -825,8 +825,8 @@ static int do_packet_auto_bsf(AVFormatContext *s, AVPacket 
*pkt) {
 }
 }
 
-for (i = 0; i < st->internal->nb_bsfcs; i++) {
-AVBSFContext *ctx = st->internal->bsfcs[i];
+if (st->internal->bsfc) {
+AVBSFContext *ctx = st->internal->bsfc;
 // TODO: when any bitstream filter requires flushing at EOF, we'll 
need to
 // flush each stream's BSF chain on write_trailer.
 if ((ret = av_bsf_send_packet(ctx, pkt)) < 0) {
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 60b72b7d15..32c09827eb 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -1034,10 +1034,8 @@ static int seg_check_bitstream(struct AVFormatContext 
*s, const AVPacket *pkt)
 if (ret == 1) {
 AVStream *st = s->streams[pkt->stream_index];
 AVStream *ost = oc->streams[pkt->stream_index];
-st->internal->bsfcs = ost->internal->bsfcs;
-st->internal->nb_bsfcs = ost->internal->nb_bsfcs;
-ost->internal->bsfcs = NULL;
-ost->internal->nb_bsfcs = 0;
+st->internal->bsfc = ost->internal->bsfc;
+ost->internal->bsfc = NULL;
 }
 return ret;
 }
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a36d6738cd..3b53f97bee 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4408,10 +4408,7 @@ static void free_stream(AVStream **pst)
 
 if (st->internal) {
 avcodec_free_context(&st->internal->avctx);
-for (i = 0; i < st->internal->nb_bsfcs; i++) {
-av_bsf_free(&st->internal->bsfcs[i]);
-av_freep(&st->internal->bsfcs);
-}
+av_bsf_free(&st->internal->bsfc);
 av_freep(&st->internal->priv_pts);
 av_bsf_free(&st->internal->extract_extradata.bsf);
 av_packet_free(&st->internal->extract_extradata.pkt);
@@ -5572,7 +5569,8 @@ int ff_stream_add_bitstream_filter(AVStream *st, const 
char *name, const char *a
 int ret;
 const AVBitStreamFilter *bsf;
 AVBSFContext *bsfc;
-AVCodecParameters *in_par;
+
+av_assert0(!st->internal->bsfc);
 
 if (!(bsf = av_bsf_get_by_name(name))) {
 av_log