Re: [FFmpeg-devel] [PATCH] avdevice/decklink: adjust for timecode lag

2019-08-13 Thread Gyan



On 09-08-2019 04:59 PM, Ilinca Tudose wrote:

Hi Marton,

The issue with the out of sync TC was reproducible on all tapes and decks
that we tested. I don't have the exact number now, but a few dozens, less
than 100. They all had between 7 and 17 frames out of sync. We were not
able to obtain anything more in sync than 7 frames.

The TC sync was tested by setting up the deck to "burn" the TC with the
image while capturing the content with TC through ffmpeg. We then play the
file in a player that supports timecodes and compare the burned-in TC with
the one captured in the metadata.

We used Decklink quad 2 and several Sony decks: J30, J3, JH3. We tested on
multiple decks from each model and confirmed the issue was present + that
Gyan's patch seemed to fix it. We have used several types of Betacam tapes
and HDCAM tapes. I can not comment on whether this is the best solution,
but can confirm it works.

Let me know if you need more info.

Thanks,
ilinca


Ping.

Gyan




On Fri, Aug 9, 2019 at 1:08 PM Gyan  wrote:


On 28-07-2019 01:37 AM, Marton Balint wrote:


On Fri, 26 Jul 2019, Gyan wrote:


Patch supported by and tested at Google.

Seems like a huge hack for a decklink issue... ;)

I wonder if there are better approaches to work around this. Like
dropping all frames until we have a valid signal.

Let's say the scenario is like this,

Frame #TC Status
  1   no   dropped
  2   no   demuxed
  3   no   demuxed
  4   no   dropped
  5  04:11:21:04   dropped
  6  04:11:21:05   demuxed


We don't want to drop frames before 6; they still should be digitized
(sometimes the TC appears after ~15 frames). But the stored TC needs
to be 04:11:21:04 + (2 - 5) =  04:11:21:01


How is this repoducible? do you have an exact model / signal type /
TC source requirement?

(Anchor for reply)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

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

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


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

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

[FFmpeg-devel] [PATCH V3] avcodec/libvpxenc: add ROI-based encoding support for VP8/VP9 support

2019-08-13 Thread Guo, Yejun
example command line to verify it:
./ffmpeg -i input.stream -vf addroi=0:0:iw/3:ih/3:-0.8 -c:v libvpx -b:v 2M 
tmp.webm

Signed-off-by: Guo, Yejun 
---
 libavcodec/libvpxenc.c | 197 +
 1 file changed, 197 insertions(+)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 1a85bc6..04ef519 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -116,6 +116,9 @@ typedef struct VPxEncoderContext {
 int tune_content;
 int corpus_complexity;
 int tpl_model;
+// If the driver does not support ROI then warn the first time we
+// encounter a frame with ROI side data.
+int roi_warned;
 } VPxContext;
 
 /** String mappings for enum vp8e_enc_control_id */
@@ -1057,6 +1060,192 @@ static int queue_frames(AVCodecContext *avctx, AVPacket 
*pkt_out)
 return size;
 }
 
+static int set_roi_map(AVCodecContext *avctx, const AVFrameSideData *sd, int 
frame_width, int frame_height,
+   vpx_roi_map_t *roi_map, int block_size, int segment_cnt)
+{
+/* range of vpx_roi_map_t.delta_q[i] is [-63, 63] */
+#define MAX_DELTA_Q 63
+
+const AVRegionOfInterest *roi = NULL;
+int nb_rois;
+uint32_t self_size;
+int segment_id;
+
+/* record the mapping from delta_q to "segment id + 1" in 
segment_mapping[].
+ * the range of delta_q is [-MAX_DELTA_Q, MAX_DELTA_Q],
+ * and its corresponding array index is [0, 2 * MAX_DELTA_Q],
+ * and so the length of the mapping array is 2 * MAX_DELTA_Q + 1.
+ * "segment id + 1", so we can say there's no mapping if the value of 
array element is zero.
+ */
+int segment_mapping[2 * MAX_DELTA_Q + 1] = { 0 };
+
+memset(roi_map, 0, sizeof(*roi_map));
+
+/* segment id 0 in roi_map is reserved for the areas not covered by 
AVRegionOfInterest.
+ * segment id 0 in roi_map is also for the areas with 
AVRegionOfInterest.qoffset near 0.
+ * (delta_q of segment id 0 is 0).
+ */
+segment_mapping[MAX_DELTA_Q] = 1;
+/* roi_map has memset with zero, just explictly set it again for explict 
understanding. */
+roi_map->delta_q[0] = 0;
+segment_id = 1;
+
+roi = (const AVRegionOfInterest*)sd->data;
+self_size = roi->self_size;
+if (!self_size || sd->size % self_size != 0) {
+av_log(avctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n");
+return AVERROR(EINVAL);
+}
+nb_rois = sd->size / self_size;
+
+/* This list must be iterated from zero because regions are
+ * defined in order of decreasing importance. So discard less
+ * important areas if they exceed the segment count.
+ */
+for (int i = 0; i < nb_rois; i++) {
+int delta_q;
+int mapping_index;
+
+roi = (const AVRegionOfInterest*)(sd->data + self_size * i);
+if (roi->qoffset.den == 0) {
+av_log(avctx, AV_LOG_ERROR, "AVRegionOfInterest.qoffset.den must 
not be zero.\n");
+return AVERROR(EINVAL);
+}
+
+delta_q = (int)(roi->qoffset.num * 1.0f / roi->qoffset.den * 
MAX_DELTA_Q);
+delta_q = av_clip(delta_q, -MAX_DELTA_Q, MAX_DELTA_Q);
+
+mapping_index = delta_q + MAX_DELTA_Q;
+if (!segment_mapping[mapping_index]) {
+if (segment_id == segment_cnt) {
+av_log(avctx, AV_LOG_WARNING,
+   "ROI only supports %d segments (and segment 0 is 
reserved for non-ROIs), skipping the left ones.\n",
+   segment_cnt);
+break;
+}
+
+segment_mapping[mapping_index] = segment_id + 1;
+roi_map->delta_q[segment_id] = delta_q;
+segment_id++;
+}
+}
+
+
+roi_map->rows = (frame_height + block_size - 1) / block_size;
+roi_map->cols = (frame_width  + block_size - 1) / block_size;
+roi_map->roi_map = av_mallocz_array(roi_map->rows * roi_map->cols, 
sizeof(*roi_map->roi_map));
+if (!roi_map->roi_map) {
+av_log(avctx, AV_LOG_ERROR, "roi_map alloc failed.\n");
+return AVERROR(ENOMEM);
+}
+
+/* This list must be iterated in reverse, so for the case that
+ * two regions overlapping, the more important area takes effect.
+ */
+for (int i = nb_rois - 1; i >= 0; i--) {
+int delta_q;
+int mapping_value;
+int starty, endy, startx, endx;
+
+roi = (const AVRegionOfInterest*)(sd->data + self_size * i);
+
+starty = av_clip(roi->top / block_size, 0, roi_map->rows);
+endy   = av_clip((roi->bottom + block_size - 1) / block_size, 0, 
roi_map->rows);
+startx = av_clip(roi->left / block_size, 0, roi_map->cols);
+endx   = av_clip((roi->right + block_size - 1) / block_size, 0, 
roi_map->cols);
+
+delta_q = (int)(roi->qoffset.num * 1.0f / roi->qoffset.den * 
MAX_DELTA_Q);
+delta_q = av_clip(delta_q, -MAX_DELTA_Q, MAX_DELTA_Q);
+
+mapping_value = segment_mapping[delta_q + MAX_DELTA_Q];
+if 

Re: [FFmpeg-devel] [PATCH V2] avcodec/libvpxenc: add ROI-based encoding support for VP8/VP9 support

2019-08-13 Thread Guo, Yejun


> -Original Message-
> From: James Zern [mailto:jz...@google.com]
> Sent: Wednesday, August 14, 2019 7:32 AM
> To: FFmpeg development discussions and patches 
> Cc: Guo, Yejun 
> Subject: Re: [FFmpeg-devel] [PATCH V2] avcodec/libvpxenc: add ROI-based
> encoding support for VP8/VP9 support
> 
> Hi,
> 
> On Tue, Aug 13, 2019 at 1:18 AM Guo, Yejun  wrote:
> >
> > example command line to verify it:
> > ./ffmpeg -i input.stream -vf addroi=0:0:iw/3:ih/3:-0.8 -c:v libvpx -b:v 2M
> tmp.webm
> >
> > Signed-off-by: Guo, Yejun 
> > ---
> >  configure  |   7 ++
> >  libavcodec/libvpxenc.c | 197
> +
> >  2 files changed, 204 insertions(+)
> >
> > diff --git a/configure b/configure
> > index 3fb8f35..e549e26 100755
> > --- a/configure
> > +++ b/configure
> > @@ -6300,6 +6300,13 @@ enabled libvpx&& {
> >  check_pkg_config libvpx_vp9_encoder "vpx >= 1.4.0"
> "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
> >  check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h
> vpx/vp8cx.h" "vpx_codec_vp9_cx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx
> $libm_extralibs $pthreads_extralibs"
> >  }
> > +enabled libvpx_vp9_encoder && {
> > +test_cc < > +#include 
> > +void foo(void){ int i = VP9E_SET_ROI_MAP; }
> > +EOF
> > +}
> > +
> 
> This can be removed after addressing the comment below.
> 
> > [...].
> > +
> > +static int vp9_encode_set_roi(AVCodecContext *avctx, int frame_width, int
> frame_height, const AVFrameSideData *sd)
> > +{
> > +int roi_supported = 0;
> > +VPxContext *ctx = avctx->priv_data;
> > +
> > +#ifdef SUPPORT_LIBVPX_VP9_ROI
> 
> You can use VPX_CTRL_VP9E_SET_ROI_MAP to check availability. All
> controls have a corresponding VPX_CTRL_ define (see the
> bottom of vpx/vp8cx.h).

thanks, will use this one, and remove the change in configure.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] Change libaom default to crf=28.

2019-08-13 Thread elliottk
Current default is 256kbps, which produces inconsistent
results (too high for low-res, too low for hi-res).
Use CRF instead, which will adapt.
---
 libavcodec/libaomenc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 9b4fb3b4eb..a18d11c8aa 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -575,10 +575,10 @@ static av_cold int aom_init(AVCodecContext *avctx,
 if (enccfg.rc_end_usage == AOM_CQ) {
 enccfg.rc_target_bitrate = 100;
 } else {
-avctx->bit_rate = enccfg.rc_target_bitrate * 1000;
+enccfg.rc_end_usage = AOM_Q;
+ctx->crf = 28;
 av_log(avctx, AV_LOG_WARNING,
-   "Neither bitrate nor constrained quality specified, using 
default bitrate of %dkbit/sec\n",
-   enccfg.rc_target_bitrate);
+   "Neither bitrate nor constrained quality specified, using 
default CRF of 28\n");
 }
 }
 
@@ -1091,7 +1091,7 @@ static const AVOption options[] = {
 };
 
 static const AVCodecDefault defaults[] = {
-{ "b",  "256*1000" },
+{ "b", "0" },
 { "qmin", "-1" },
 { "qmax", "-1" },
 { "g","-1" },
-- 
2.23.0.rc1.153.gdeed80330f-goog

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

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

Re: [FFmpeg-devel] [PATCH] lavf/vf_deinterlace_vaapi: flush queued frame in field mode

2019-08-13 Thread Aman Gupta
On Tue, Aug 13, 2019 at 7:01 PM Fu, Linjie  wrote:

> > -Original Message-
> > From: Fu, Linjie
> > Sent: Friday, August 2, 2019 17:54
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Fu, Linjie 
> > Subject: [PATCH] lavf/vf_deinterlace_vaapi: flush queued frame in field
> > mode
> >
> > Add deint_vaapi_request_frame for deinterlace_vaapi, send NULL frame
> > to flush the queued frame.
> >
> > Fix the frame drop issue in field mode:
> >
> > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -c:v
> > h264 -i ./input.h264 -vf 'format=nv12|vaapi,hwupload,
> > deinterlace_vaapi=mode=bob:rate=field,hwdownload,format=nv12'
> > -pix_fmt yuv420p -f rawvideo -vsync passthrough -y dump.yuv
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavfilter/vf_deinterlace_vaapi.c | 46
> > --
> >  1 file changed, 39 insertions(+), 7 deletions(-)
> >
> > diff --git a/libavfilter/vf_deinterlace_vaapi.c
> > b/libavfilter/vf_deinterlace_vaapi.c
> > index 72d0349..c811327 100644
> > --- a/libavfilter/vf_deinterlace_vaapi.c
> > +++ b/libavfilter/vf_deinterlace_vaapi.c
> > @@ -48,6 +48,9 @@ typedef struct DeintVAAPIContext {
> >  intqueue_count;
> >  AVFrame   *frame_queue[MAX_REFERENCES];
> >  intextra_delay_for_timestamps;
> > +
> > +inteof;
> > +intprev_pts;
> >  } DeintVAAPIContext;
> >
> >  static const char *deint_vaapi_mode_name(int mode)
> > @@ -190,11 +193,16 @@ static int deint_vaapi_filter_frame(AVFilterLink
> > *inlink, AVFrame *input_frame)
> >  void *filter_params_addr = NULL;
> >  int err, i, field, current_frame_index;
> >
> > -av_log(avctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u
> (%"PRId64").\n",
> > -   av_get_pix_fmt_name(input_frame->format),
> > -   input_frame->width, input_frame->height, input_frame->pts);
> > +// NULL frame is used to flush the queue in field mode
> > +if (input_frame)
> > +av_log(avctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u
> > (%"PRId64").\n",
> > +av_get_pix_fmt_name(input_frame->format),
> > +input_frame->width, input_frame->height, input_frame->pts);
> > +else if (ctx->field_rate == 1) {
> > +return 0;
> > +}
> >
> > -if (ctx->queue_count < ctx->queue_depth) {
> > +if (input_frame && ctx->queue_count < ctx->queue_depth) {
> >  ctx->frame_queue[ctx->queue_count++] = input_frame;
> >  if (ctx->queue_count < ctx->queue_depth) {
> >  // Need more reference surfaces before we can continue.
> > @@ -291,6 +299,8 @@ static int deint_vaapi_filter_frame(AVFilterLink
> *inlink,
> > AVFrame *input_frame)
> >  if (ctx->field_rate == 2) {
> >  if (field == 0)
> >  output_frame->pts = 2 * input_frame->pts;
> > +else if (ctx->eof)
> > +output_frame->pts = 3 * input_frame->pts -
> ctx->prev_pts;
> >  else
> >  output_frame->pts = input_frame->pts +
> >  ctx->frame_queue[current_frame_index + 1]->pts;
> > @@ -306,6 +316,8 @@ static int deint_vaapi_filter_frame(AVFilterLink
> *inlink,
> > AVFrame *input_frame)
> >  break;
> >  }
> >
> > +ctx->prev_pts = input_frame->pts;
> > +
> >  return err;
> >
> >  fail:
> > @@ -315,6 +327,25 @@ fail:
> >  return err;
> >  }
> >
> > +static int deint_vaapi_request_frame(AVFilterLink *link)
> > +{
> > +AVFilterContext *avctx = link->src;
> > +DeintVAAPIContext *ctx   = avctx->priv;
> > +int ret;
> > +
> > +if (ctx->eof)
> > +return AVERROR_EOF;
> > +
> > +ret = ff_request_frame(link->src->inputs[0]);
> > +if (ret == AVERROR_EOF) {
> > +ctx->eof = 1;
> > +deint_vaapi_filter_frame(link->src->inputs[0], NULL);
> > +} else if (ret < 0)
> > +return ret;
> > +
> > +return 0;
> > +}
> > +
> >  static av_cold int deint_vaapi_init(AVFilterContext *avctx)
> >  {
> >  VAAPIVPPContext *vpp_ctx = avctx->priv;
> > @@ -376,9 +407,10 @@ static const AVFilterPad deint_vaapi_inputs[] = {
> >
> >  static const AVFilterPad deint_vaapi_outputs[] = {
> >  {
> > -.name = "default",
> > -.type = AVMEDIA_TYPE_VIDEO,
> > -.config_props = _vaapi_config_output,
> > +.name   = "default",
> > +.type   = AVMEDIA_TYPE_VIDEO,
> > +.request_frame  = _vaapi_request_frame,
> > +.config_props   = _vaapi_config_output,
> >  },
> >  { NULL }
> >  };
> > --
> > 2.7.4
> Ping.
>

LGTM


> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

Re: [FFmpeg-devel] [PATCH] lavf/vf_deinterlace_vaapi: flush queued frame in field mode

2019-08-13 Thread Fu, Linjie
> -Original Message-
> From: Fu, Linjie
> Sent: Friday, August 2, 2019 17:54
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [PATCH] lavf/vf_deinterlace_vaapi: flush queued frame in field
> mode
> 
> Add deint_vaapi_request_frame for deinterlace_vaapi, send NULL frame
> to flush the queued frame.
> 
> Fix the frame drop issue in field mode:
> 
> ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -c:v
> h264 -i ./input.h264 -vf 'format=nv12|vaapi,hwupload,
> deinterlace_vaapi=mode=bob:rate=field,hwdownload,format=nv12'
> -pix_fmt yuv420p -f rawvideo -vsync passthrough -y dump.yuv
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavfilter/vf_deinterlace_vaapi.c | 46
> --
>  1 file changed, 39 insertions(+), 7 deletions(-)
> 
> diff --git a/libavfilter/vf_deinterlace_vaapi.c
> b/libavfilter/vf_deinterlace_vaapi.c
> index 72d0349..c811327 100644
> --- a/libavfilter/vf_deinterlace_vaapi.c
> +++ b/libavfilter/vf_deinterlace_vaapi.c
> @@ -48,6 +48,9 @@ typedef struct DeintVAAPIContext {
>  intqueue_count;
>  AVFrame   *frame_queue[MAX_REFERENCES];
>  intextra_delay_for_timestamps;
> +
> +inteof;
> +intprev_pts;
>  } DeintVAAPIContext;
> 
>  static const char *deint_vaapi_mode_name(int mode)
> @@ -190,11 +193,16 @@ static int deint_vaapi_filter_frame(AVFilterLink
> *inlink, AVFrame *input_frame)
>  void *filter_params_addr = NULL;
>  int err, i, field, current_frame_index;
> 
> -av_log(avctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u (%"PRId64").\n",
> -   av_get_pix_fmt_name(input_frame->format),
> -   input_frame->width, input_frame->height, input_frame->pts);
> +// NULL frame is used to flush the queue in field mode
> +if (input_frame)
> +av_log(avctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u
> (%"PRId64").\n",
> +av_get_pix_fmt_name(input_frame->format),
> +input_frame->width, input_frame->height, input_frame->pts);
> +else if (ctx->field_rate == 1) {
> +return 0;
> +}
> 
> -if (ctx->queue_count < ctx->queue_depth) {
> +if (input_frame && ctx->queue_count < ctx->queue_depth) {
>  ctx->frame_queue[ctx->queue_count++] = input_frame;
>  if (ctx->queue_count < ctx->queue_depth) {
>  // Need more reference surfaces before we can continue.
> @@ -291,6 +299,8 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink,
> AVFrame *input_frame)
>  if (ctx->field_rate == 2) {
>  if (field == 0)
>  output_frame->pts = 2 * input_frame->pts;
> +else if (ctx->eof)
> +output_frame->pts = 3 * input_frame->pts - ctx->prev_pts;
>  else
>  output_frame->pts = input_frame->pts +
>  ctx->frame_queue[current_frame_index + 1]->pts;
> @@ -306,6 +316,8 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink,
> AVFrame *input_frame)
>  break;
>  }
> 
> +ctx->prev_pts = input_frame->pts;
> +
>  return err;
> 
>  fail:
> @@ -315,6 +327,25 @@ fail:
>  return err;
>  }
> 
> +static int deint_vaapi_request_frame(AVFilterLink *link)
> +{
> +AVFilterContext *avctx = link->src;
> +DeintVAAPIContext *ctx   = avctx->priv;
> +int ret;
> +
> +if (ctx->eof)
> +return AVERROR_EOF;
> +
> +ret = ff_request_frame(link->src->inputs[0]);
> +if (ret == AVERROR_EOF) {
> +ctx->eof = 1;
> +deint_vaapi_filter_frame(link->src->inputs[0], NULL);
> +} else if (ret < 0)
> +return ret;
> +
> +return 0;
> +}
> +
>  static av_cold int deint_vaapi_init(AVFilterContext *avctx)
>  {
>  VAAPIVPPContext *vpp_ctx = avctx->priv;
> @@ -376,9 +407,10 @@ static const AVFilterPad deint_vaapi_inputs[] = {
> 
>  static const AVFilterPad deint_vaapi_outputs[] = {
>  {
> -.name = "default",
> -.type = AVMEDIA_TYPE_VIDEO,
> -.config_props = _vaapi_config_output,
> +.name   = "default",
> +.type   = AVMEDIA_TYPE_VIDEO,
> +.request_frame  = _vaapi_request_frame,
> +.config_props   = _vaapi_config_output,
>  },
>  { NULL }
>  };
> --
> 2.7.4
Ping.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_vaapi: cope with race map for YUV420P

2019-08-13 Thread Fu, Linjie
> -Original Message-
> From: Fu, Linjie
> Sent: Thursday, August 1, 2019 12:45
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [PATCH] lavu/hwcontext_vaapi: cope with race map for YUV420P
> 
> There is a race condition for AV_PIX_FMT_YUV420P when mapping from
> pix_fmt
> to fourcc, both VA_FOURCC_I420 and VA_FOURCC_YV12 could be find by
> pix_fmt.
> 
> Currently, vaapi_get_image_format will go through the query results of
> pix_fmt and returned the first matched result according to the declared
> order in driver.This may leads to a wrong image_format.
> 
> Modify to find image_format via fourcc.
> 
> Fix vaapi CSC to I420:
> ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -f rawvideo
> -pix_fmt nv12 -s:v 1280x720 -i NV12.yuv -vf
> 'format=nv12,hwupload,scale_vaapi=format=yuv420p,hwdownload,format=
> yuv420p'
> -f rawvideo -vsync passthrough -vframes 10 -y aa.yuv
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavutil/hwcontext_vaapi.c | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index cf11764..64f14de 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -63,6 +63,7 @@ typedef struct VAAPIDevicePriv {
>  typedef struct VAAPISurfaceFormat {
>  enum AVPixelFormat pix_fmt;
>  VAImageFormat image_format;
> +unsigned int fourcc;
>  } VAAPISurfaceFormat;
> 
>  typedef struct VAAPIDeviceContext {
> @@ -171,15 +172,21 @@ static int
> vaapi_get_image_format(AVHWDeviceContext *hwdev,
>VAImageFormat **image_format)
>  {
>  VAAPIDeviceContext *ctx = hwdev->internal->priv;
> +VAAPIFormatDescriptor *desc;
>  int i;
> 
> +desc = vaapi_format_from_pix_fmt(pix_fmt);
> +if (!desc || !image_format)
> +goto fail;
> +
>  for (i = 0; i < ctx->nb_formats; i++) {
> -if (ctx->formats[i].pix_fmt == pix_fmt) {
> -if (image_format)
> -*image_format = >formats[i].image_format;
> +if (ctx->formats[i].fourcc == desc->fourcc) {
> +*image_format = >formats[i].image_format;
>  return 0;
>  }
>  }
> +
> +fail:
>  return AVERROR(EINVAL);
>  }
> 
> @@ -368,6 +375,7 @@ static int vaapi_device_init(AVHWDeviceContext
> *hwdev)
>  av_log(hwdev, AV_LOG_DEBUG, "Format %#x -> %s.\n",
> fourcc, av_get_pix_fmt_name(pix_fmt));
>  ctx->formats[ctx->nb_formats].pix_fmt  = pix_fmt;
> +ctx->formats[ctx->nb_formats].fourcc   = fourcc;
>  ctx->formats[ctx->nb_formats].image_format = image_list[i];
>  ++ctx->nb_formats;
>  }
> --
> 2.7.4
A gentle ping.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavformat/rtspdec: Don't send teardown if rtsp_hd_out is null

2019-08-13 Thread Ross Nicholson
Ping.

If I’m missing something I should have provided for this patch please let me 
know. It’s my first patch to FFmpeg.

> On 11 Aug 2019, at 10:39, Ross Nicholson  wrote:
> 
> 3rd time lucky, can anyone take a look at this? It’s a minor patch and is 
> required for kodi.
> 
> Thanks in advance 
> 
>> On 8 Aug 2019, at 11:46, Ross Nicholson  wrote:
>> 
>> Any feedback on this patch?
>> 
>>> On Mon, 5 Aug 2019 at 00:18, Ross Nicholson  wrote:
>>> Example stream that does not work: 
>>> rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov
>>> 
>>> Extending the condition allows the stream to be processed correctly. 
>>> 
 On Mon, 5 Aug 2019 at 08:17, Ross Nicholson  wrote:
 From: phunkyfish 
 
 ---
  libavformat/rtspdec.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
 index 32dff2319c..3a79d1b175 100644
 --- a/libavformat/rtspdec.c
 +++ b/libavformat/rtspdec.c
 @@ -57,7 +57,7 @@ static int rtsp_read_close(AVFormatContext *s)
  {
  RTSPState *rt = s->priv_data;
 
 -if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN))
 +if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN) && rt->rtsp_hd_out)
  ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL);
 
  ff_rtsp_close_streams(s);
 -- 
 2.20.1 (Apple Git-117)
 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v2 1/3] avfilter: add v360 filter

2019-08-13 Thread Eugene Lyapustin
Signed-off-by: Eugene Lyapustin 
---
 doc/filters.texi |  137 +++
 libavfilter/Makefile |1 +
 libavfilter/allfilters.c |1 +
 libavfilter/vf_v360.c| 1847 ++
 4 files changed, 1986 insertions(+)
 create mode 100644 libavfilter/vf_v360.c

diff --git a/doc/filters.texi b/doc/filters.texi
index e081cdc7bc..6168a3502a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17879,6 +17879,143 @@ Force a constant quantization parameter. If not set, 
the filter will use the QP
 from the video stream (if available).
 @end table
 
+@section v360
+
+Convert 360 videos between various formats.
+
+The filter accepts the following options:
+
+@table @option
+
+@item input
+@item output
+Set format of the input/output video.
+
+Available formats:
+
+@table @samp
+
+@item e
+Equirectangular projection.
+
+@item c3x2
+@item c6x1
+Cubemap with 3x2/6x1 layout.
+
+Format specific options:
+
+@table @option
+@item in_forder
+@item out_forder
+Set order of faces for the input/output cubemap. Choose one direction for each 
position.
+
+Designation of directions:
+@table @samp
+@item r
+right
+@item l
+left
+@item u
+up
+@item d
+down
+@item f
+forward
+@item b
+back
+@end table
+
+Default value is @b{@samp{rludfb}}.
+
+@item in_frot
+@item out_frot
+Set rotation of faces for the input/output cubemap. Choose one angle for each 
position.
+
+Designation of angles:
+@table @samp
+@item 0
+0 degrees clockwise
+@item 1
+90 degrees clockwise
+@item 2
+180 degrees clockwise
+@item 4
+270 degrees clockwise
+@end table
+
+Default value is @b{@samp{00}}.
+@end table
+
+@item eac
+Equi-Angular Cubemap.
+
+@item flat
+Regular video. @i{(output only)}
+
+Format specific options:
+@table @option
+@item h_fov
+@item v_fov
+Set horizontal/vertical field of view. Values in degrees.
+@end table
+@end table
+
+@item interp
+Set interpolation method.@*
+@i{Note: more complex interpolation methods require much more memory to run.}
+
+Available methods:
+
+@table @samp
+@item near
+@item nearest
+Nearest neighbour.
+@item line
+@item linear
+Bilinear interpolation.
+@item cube
+@item cubic
+Bicubic interpolation.
+@item lanc
+@item lanczos
+Lanczos interpolation.
+@end table
+
+Default value is @b{@samp{line}}.
+
+@item w
+@item h
+Set the output video resolution.
+
+Default resolution depends on formats.
+
+@item yaw
+@item pitch
+@item roll
+Set rotation for the output video. Values in degrees.
+
+@item hflip
+@item vflip
+@item dflip
+Flip the output video horizontally/vertically/in-depth. Boolean values.
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Convert equirectangular video to cubemap with 3x2 layout using bicubic 
interpolation:
+@example
+ffmpeg -i input.mkv -vf v360=e:c3x2:cubic output.mkv
+@end example
+@item
+Extract back view of Equi-Angular Cubemap:
+@example
+ffmpeg -i input.mkv -vf v360=eac:flat:yaw=180 output.mkv
+@end example
+@end itemize
+
 @section vaguedenoiser
 
 Apply a wavelet based denoiser.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index efc7bbb153..345f7c95cd 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -410,6 +410,7 @@ OBJS-$(CONFIG_UNSHARP_FILTER)+= vf_unsharp.o
 OBJS-$(CONFIG_UNSHARP_OPENCL_FILTER) += vf_unsharp_opencl.o opencl.o \
 opencl/unsharp.o
 OBJS-$(CONFIG_USPP_FILTER)   += vf_uspp.o
+OBJS-$(CONFIG_V360_FILTER)   += vf_v360.o
 OBJS-$(CONFIG_VAGUEDENOISER_FILTER)  += vf_vaguedenoiser.o
 OBJS-$(CONFIG_VECTORSCOPE_FILTER)+= vf_vectorscope.o
 OBJS-$(CONFIG_VFLIP_FILTER)  += vf_vflip.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index abd726d616..5799fb4b3c 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -390,6 +390,7 @@ extern AVFilter ff_vf_unpremultiply;
 extern AVFilter ff_vf_unsharp;
 extern AVFilter ff_vf_unsharp_opencl;
 extern AVFilter ff_vf_uspp;
+extern AVFilter ff_vf_v360;
 extern AVFilter ff_vf_vaguedenoiser;
 extern AVFilter ff_vf_vectorscope;
 extern AVFilter ff_vf_vflip;
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
new file mode 100644
index 00..5c377827b0
--- /dev/null
+++ b/libavfilter/vf_v360.c
@@ -0,0 +1,1847 @@
+/*
+ * Copyright (c) 2019 Eugene Lyapustin
+ *
+ * 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 

[FFmpeg-devel] [PATCH v2 3/3] avfilter/vf_v360: add dual fisheye format

2019-08-13 Thread Eugene Lyapustin
Signed-off-by: Eugene Lyapustin 
---
 doc/filters.texi  | 20 +++
 libavfilter/vf_v360.c | 60 +++
 2 files changed, 80 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6c70ffceb1..feb3a123b6 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17972,6 +17972,26 @@ Format specific options:
 @item v_fov
 Set horizontal/vertical field of view. Values in degrees.
 @end table
+
+@item dfisheye
+Dual fisheye. @i{(input only)}
+
+Format specific options:
+@table @option
+@item in_pad
+Set padding proprtion. Values in decimals.
+
+Example values:
+@table @samp
+@item 0
+No padding.
+@item 0.01
+1% padding.
+@end table
+
+Default value is @b{@samp{0}}.
+@end table
+
 @end table
 
 @item interp
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index 3c69f2cf3d..fb0b0e0b46 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -48,6 +48,7 @@ enum Projections {
 CUBEMAP_6_1,
 EQUIANGULAR,
 FLAT,
+DUAL_FISHEYE,
 NB_PROJECTIONS,
 };
 
@@ -136,6 +137,7 @@ static const AVOption v360_options[] = {
 {  "c3x2", "cubemap3x2", 0, 
AV_OPT_TYPE_CONST,  {.i64=CUBEMAP_3_2}, 0,   0, FLAGS, "in" 
},
 {  "c6x1", "cubemap6x1", 0, 
AV_OPT_TYPE_CONST,  {.i64=CUBEMAP_6_1}, 0,   0, FLAGS, "in" 
},
 {   "eac", "equi-angular",   0, 
AV_OPT_TYPE_CONST,  {.i64=EQUIANGULAR}, 0,   0, FLAGS, "in" 
},
+{  "dfisheye", "dual fisheye",   0, 
AV_OPT_TYPE_CONST,  {.i64=DUAL_FISHEYE},0,   0, FLAGS, "in" 
},
 {"output", "set output projection",OFFSET(out), 
AV_OPT_TYPE_INT,{.i64=CUBEMAP_3_2}, 0,NB_PROJECTIONS-1, FLAGS, 
"out" },
 { "e", "equirectangular",0, 
AV_OPT_TYPE_CONST,  {.i64=EQUIRECTANGULAR}, 0,   0, FLAGS, 
"out" },
 {  "c3x2", "cubemap3x2", 0, 
AV_OPT_TYPE_CONST,  {.i64=CUBEMAP_3_2}, 0,   0, FLAGS, 
"out" },
@@ -1593,6 +1595,58 @@ static void flat_to_xyz(const V360Context *s,
 vec[2] = l_z / norm;
 }
 
+/**
+ * Calculate frame position in dual fisheye format for corresponding 3D 
coordinates on sphere.
+ *
+ * @param s filter context
+ * @param vec coordinates on sphere
+ * @param width frame width
+ * @param height frame height
+ * @param us horizontal coordinates for interpolation window
+ * @param vs vertical coordinates for interpolation window
+ * @param du horizontal relative coordinate
+ * @param dv vertical relative coordinate
+ */
+static void xyz_to_dfisheye(const V360Context *s,
+const float *vec, int width, int height,
+uint16_t us[4][4], uint16_t vs[4][4], float *du, 
float *dv)
+{
+const float scale = 1.f - s->in_pad;
+
+const float ew = width / 2.f;
+const float eh = height;
+
+const float phi   = atan2f(-vec[1], -vec[0]);
+const float theta = acosf(fabsf(vec[2])) / M_PI;
+
+float uf = (theta * cosf(phi) * scale + 0.5f) * ew;
+float vf = (theta * sinf(phi) * scale + 0.5f) * eh;
+
+int ui, vi;
+int u_shift;
+int i, j;
+
+if (vec[2] >= 0) {
+u_shift = 0;
+} else {
+u_shift = ceilf(ew);
+uf = ew - uf;
+}
+
+ui = floorf(uf);
+vi = floorf(vf);
+
+*du = uf - ui;
+*dv = vf - vi;
+
+for (i = -1; i < 3; i++) {
+for (j = -1; j < 3; j++) {
+us[i + 1][j + 1] = av_clip(u_shift + ui + j, 0, width  - 1);
+vs[i + 1][j + 1] = av_clip(  vi + i, 0, height - 1);
+}
+}
+}
+
 /**
  * Calculate rotation matrix for yaw/pitch/roll angles.
  */
@@ -1730,6 +1784,12 @@ static int config_output(AVFilterLink *outlink)
 case FLAT:
 av_log(ctx, AV_LOG_ERROR, "Flat format is not accepted as input.\n");
 return AVERROR(EINVAL);
+case DUAL_FISHEYE:
+in_transform = xyz_to_dfisheye;
+err = 0;
+wf = inlink->w;
+hf = inlink->h;
+break;
 }
 
 if (err != 0) {
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_v360: add padding option for cubemap

2019-08-13 Thread Eugene Lyapustin
Signed-off-by: Eugene Lyapustin 
---
 doc/filters.texi  |  18 +++-
 libavfilter/vf_v360.c | 100 --
 2 files changed, 93 insertions(+), 25 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6168a3502a..6c70ffceb1 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17905,6 +17905,20 @@ Cubemap with 3x2/6x1 layout.
 Format specific options:
 
 @table @option
+@item in_pad
+@item out_pad
+Set padding proprtion for the input/output cubemap. Values in decimals.
+
+Example values:
+@table @samp
+@item 0
+No padding.
+@item 0.01
+1% of face is padding. For example, with 1920x1280 resolution face size would 
be 640x640 and padding would be 3 pixels from each side. (640 * 0.01 = 6 pixels)
+@end table
+
+Default value is @b{@samp{0}}.
+
 @item in_forder
 @item out_forder
 Set order of faces for the input/output cubemap. Choose one direction for each 
position.
@@ -18005,9 +18019,9 @@ Flip the output video horizontally/vertically/in-depth. 
Boolean values.
 
 @itemize
 @item
-Convert equirectangular video to cubemap with 3x2 layout using bicubic 
interpolation:
+Convert equirectangular video to cubemap with 3x2 layout and 1% padding using 
bicubic interpolation:
 @example
-ffmpeg -i input.mkv -vf v360=e:c3x2:cubic output.mkv
+ffmpeg -i input.mkv -vf v360=e:c3x2:cubic:out_pad=0.01 output.mkv
 @end example
 @item
 Extract back view of Equi-Angular Cubemap:
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index 5c377827b0..3c69f2cf3d 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -102,6 +102,8 @@ typedef struct V360Context {
 int in_cubemap_face_rotation[6];
 int out_cubemap_face_rotation[6];
 
+float in_pad, out_pad;
+
 float yaw, pitch, roll;
 
 int h_flip, v_flip, d_flip;
@@ -155,6 +157,8 @@ static const AVOption v360_options[] = {
 {"out_forder", "output cubemap face order", OFFSET(out_forder), 
AV_OPT_TYPE_STRING, {.str="rludfb"},0, NB_DIRECTIONS-1, FLAGS, 
"out_forder"},
 {   "in_frot", "input cubemap face rotation",  OFFSET(in_frot), 
AV_OPT_TYPE_STRING, {.str="00"},0, NB_DIRECTIONS-1, FLAGS, 
"in_frot"},
 {  "out_frot", "output cubemap face rotation",OFFSET(out_frot), 
AV_OPT_TYPE_STRING, {.str="00"},0, NB_DIRECTIONS-1, FLAGS, 
"out_frot"},
+{"in_pad", "input cubemap pads",OFFSET(in_pad), 
AV_OPT_TYPE_FLOAT,  {.dbl=0.f},   0.f, 1.f, FLAGS, 
"in_pad"},
+{   "out_pad", "output cubemap pads",  OFFSET(out_pad), 
AV_OPT_TYPE_FLOAT,  {.dbl=0.f},   0.f, 1.f, FLAGS, 
"out_pad"},
 {   "yaw", "yaw rotation", OFFSET(yaw), 
AV_OPT_TYPE_FLOAT,  {.dbl=0.f},-180.f,   180.f, FLAGS, 
"yaw"},
 { "pitch", "pitch rotation", OFFSET(pitch), 
AV_OPT_TYPE_FLOAT,  {.dbl=0.f},-180.f,   180.f, FLAGS, 
"pitch"},
 {  "roll", "roll rotation",   OFFSET(roll), 
AV_OPT_TYPE_FLOAT,  {.dbl=0.f},-180.f,   180.f, FLAGS, 
"roll"},
@@ -734,6 +738,9 @@ static void cube_to_xyz(const V360Context *s,
 float norm;
 float l_x, l_y, l_z;
 
+uf /= (1.f - s->out_pad);
+vf /= (1.f - s->out_pad);
+
 rotate_cube_face_inverse(, , s->out_cubemap_face_rotation[face]);
 
 switch (direction) {
@@ -1091,6 +1098,9 @@ static void xyz_to_cube3x2(const V360Context *s,
 
 xyz_to_cube(s, vec, , , );
 
+uf *= (1.f - s->in_pad);
+vf *= (1.f - s->in_pad);
+
 face = s->in_cubemap_face_order[direction];
 u_face = face % 3;
 v_face = face / 3;
@@ -1108,22 +1118,44 @@ static void xyz_to_cube3x2(const V360Context *s,
 
 for (i = -1; i < 3; i++) {
 for (j = -1; j < 3; j++) {
-float u, v;
+int new_ui = ui + j;
+int new_vi = vi + i;
 int u_shift, v_shift;
 int new_ewi, new_ehi;
 
-process_cube_coordinates(s, 2.f * (ui + j) / ewi - 1.f,
-2.f * (vi + i) / ehi - 1.f,
-direction, , , );
-u_face = face % 3;
-v_face = face / 3;
-u_shift = ceilf(ew * u_face);
-v_shift = ceilf(eh * v_face);
-new_ewi = ceilf(ew * (u_face + 1)) - u_shift;
-new_ehi = ceilf(eh * (v_face + 1)) - v_shift;
-
-us[i + 1][j + 1] = u_shift + av_clip(roundf(0.5f * new_ewi * (u + 
1.f)), 0, new_ewi - 1);
-vs[i + 1][j + 1] = v_shift + av_clip(roundf(0.5f * new_ehi * (v + 
1.f)), 0, new_ehi - 1);
+if (new_ui >= 0 && new_ui < ewi && new_vi >= 0 && new_vi < ehi) {
+face = s->in_cubemap_face_order[direction];
+
+u_face = face % 3;
+v_face = face / 3;
+u_shift = ceilf(ew * u_face);
+v_shift = ceilf(eh * v_face);
+} else {
+

Re: [FFmpeg-devel] [PATCH, RFC, v2 3/3] lavc/libvpxenc: add dynamic resolution encode support for libvpx

2019-08-13 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of James Zern
> Sent: Wednesday, August 14, 2019 07:37
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH, RFC, v2 3/3] lavc/libvpxenc: add
> dynamic resolution encode support for libvpx
> 
> Hi,
> 
> On Tue, Aug 13, 2019 at 2:30 AM Linjie Fu  wrote:
> >
> > According to spec, libvpx should support dynamic resolution changes.
> >
> > Add dynamic resolution encoding support in libvpx.
> >
> > Only single pass mode with no look ahead is supported for variable
> > resolution encoding without initialization.
> >
> 
> Do you mean /reinitialization/?

Yes, should be reinitialization exactly.

> 
> > cmdline:
> > ffmpeg -noautoscale -y -i ./reinit-large_420_8-to-small_420_8.h264
> >  -pix_fmt yuv420p -c:v libvpx-vp9 lena.ivf
> >
> 
> Do you have a reference command line for creating the source content?

This clips is accessible at
http://fate-suite.ffmpeg.org/h264/reinit-large_420_8-to-small_420_8.h264

However, mentioned issue could not be reproduced with above clips actually.

> 
> > Filed an issue in
> https://bugs.chromium.org/p/webm/issues/detail?id=1642
> > to fix some memory problem.
> >
> 
> It may be worth getting that bug resolved before landing this change
> if existing library versions are buggy.

Sure, this patch should be hold until bug is fixed in libvpx. 

> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/libvpxenc.c | 24 
> >  1 file changed, 24 insertions(+)
> >
> > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> > index feb52ea..3d2295d 100644
> > --- a/libavcodec/libvpxenc.c
> > +++ b/libavcodec/libvpxenc.c
> > @@ -1067,6 +1067,28 @@ static int vpx_encode(AVCodecContext *avctx,
> AVPacket *pkt,
> >  int res, coded_size;
> >  vpx_enc_frame_flags_t flags = 0;
> >
> > +if (frame && (avctx->width != frame->width ||
> > +  avctx->height != frame->height)) {
> > +avctx->width  = frame->width;
> > +avctx->height = frame->height;
> > +
> > +struct vpx_codec_enc_cfg new_cfg = { 0 };
> > +memcpy(_cfg, ctx->encoder.config.enc,
> > +sizeof(struct vpx_codec_enc_cfg));
> > +
> > +new_cfg.g_w = frame->width;
> > +new_cfg.g_h = frame->height;
> > +if (new_cfg.g_lag_in_frames > 1 ||
> > +new_cfg.g_pass != VPX_RC_ONE_PASS) {
> > +av_log(avctx, AV_LOG_WARNING, "Only single pass mode "
> > +   "with no look ahead is supported for variable "
> > +   "resolution encoding without initialization.\n");
> 
> Would it be better to warn and reinitialize as in your earlier patch
> rather than changing the settings from the user?

Warn and reinitialize seems better for me.

Will resend after all concerns are addressed.
Thanks.

- linjie


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

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

Re: [FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures

2019-08-13 Thread Juan De León
On Tue, Aug 13, 2019 at 4:49 PM James Almer  wrote:

> I'm fairly sure this was discussed before, but invalid arguments
> shouldn't crash an user's application. They even have their own
> standardized errno value for this purpose.
> asserts() are to catch bugs in our code, not in theirs. Returning a NULL
> pointer is the preferred behavior.
>

Thank you for the feedback, I will update the patch accordingly.
Also I noticed I was using FFMIN instead of FFMAX here:
size_t size = sizeof(AVEncodeInfoFrame) +
sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks
- 1, 0);

If anyone has any more feedback or wants to discuss the patch I'll also be
available in the IRC channel.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures

2019-08-13 Thread James Almer
On 8/13/2019 7:29 PM, Nicolas George wrote:
> Juan De León (12019-08-13):
>> The array is there so that the structure isn't opaque, it should be
>> accessed with the function.
> 
> I realize you need it, but not for the reason you say. It is needed for
> alignment: if blocks needs more alignment than info, info+sizeof(info)
> is not a valid pointer for blocks.
> 
 +if (!info || idx >= info->nb_blocks || idx < 0)
 +return NULL;
>>> How valid is it for applications to call with idx outside the range?
>> They shouldn't but I figure it's better to return NULL than to get
>> undefined behaviour.
> 
> In that case, I think is is better practice to document:
> 
>   Index must be between 0 and nb_blocks
> 
> and check with an assert, forcing the application programmer fix their
> code immediately.
> 
> Most code will likely use idx from a loop counter, where it cannot be
> outside the range, and for the few other cases, the caller can do the
> check if necessary.
> 
> Also, make the fields that cannot be negative unsigned, and you can drop
> the <0 test.
> 
> Regards,

I'm fairly sure this was discussed before, but invalid arguments
shouldn't crash an user's application. They even have their own
standardized errno value for this purpose.
asserts() are to catch bugs in our code, not in theirs. Returning a NULL
pointer is the preferred behavior.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, RFC, v2 3/3] lavc/libvpxenc: add dynamic resolution encode support for libvpx

2019-08-13 Thread James Zern
Hi,

On Tue, Aug 13, 2019 at 2:30 AM Linjie Fu  wrote:
>
> According to spec, libvpx should support dynamic resolution changes.
>
> Add dynamic resolution encoding support in libvpx.
>
> Only single pass mode with no look ahead is supported for variable
> resolution encoding without initialization.
>

Do you mean /reinitialization/?

> cmdline:
> ffmpeg -noautoscale -y -i ./reinit-large_420_8-to-small_420_8.h264
>  -pix_fmt yuv420p -c:v libvpx-vp9 lena.ivf
>

Do you have a reference command line for creating the source content?

> Filed an issue in https://bugs.chromium.org/p/webm/issues/detail?id=1642
> to fix some memory problem.
>

It may be worth getting that bug resolved before landing this change
if existing library versions are buggy.

> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/libvpxenc.c | 24 
>  1 file changed, 24 insertions(+)
>
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index feb52ea..3d2295d 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -1067,6 +1067,28 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
> *pkt,
>  int res, coded_size;
>  vpx_enc_frame_flags_t flags = 0;
>
> +if (frame && (avctx->width != frame->width ||
> +  avctx->height != frame->height)) {
> +avctx->width  = frame->width;
> +avctx->height = frame->height;
> +
> +struct vpx_codec_enc_cfg new_cfg = { 0 };
> +memcpy(_cfg, ctx->encoder.config.enc,
> +sizeof(struct vpx_codec_enc_cfg));
> +
> +new_cfg.g_w = frame->width;
> +new_cfg.g_h = frame->height;
> +if (new_cfg.g_lag_in_frames > 1 ||
> +new_cfg.g_pass != VPX_RC_ONE_PASS) {
> +av_log(avctx, AV_LOG_WARNING, "Only single pass mode "
> +   "with no look ahead is supported for variable "
> +   "resolution encoding without initialization.\n");

Would it be better to warn and reinitialize as in your earlier patch
rather than changing the settings from the user?

> +new_cfg.g_pass  = VPX_RC_ONE_PASS;
> +new_cfg.g_lag_in_frames = 0;
> +}
> +vpx_codec_enc_config_set(>encoder, _cfg);
> +}
> +
>  if (frame) {
>  rawimg  = >rawimg;
>  rawimg->planes[VPX_PLANE_Y] = frame->data[0];
> @@ -1075,6 +1097,8 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
> *pkt,
>  rawimg->stride[VPX_PLANE_Y] = frame->linesize[0];
>  rawimg->stride[VPX_PLANE_U] = frame->linesize[1];
>  rawimg->stride[VPX_PLANE_V] = frame->linesize[2];
> +rawimg->d_w = frame->width;
> +rawimg->d_h = frame->height;
>  if (ctx->is_alpha) {
>  uint8_t *u_plane, *v_plane;
>  rawimg_alpha = >rawimg_alpha;
> --
> 2.7.4
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH V2] avcodec/libvpxenc: add ROI-based encoding support for VP8/VP9 support

2019-08-13 Thread James Zern
Hi,

On Tue, Aug 13, 2019 at 1:18 AM Guo, Yejun  wrote:
>
> example command line to verify it:
> ./ffmpeg -i input.stream -vf addroi=0:0:iw/3:ih/3:-0.8 -c:v libvpx -b:v 2M 
> tmp.webm
>
> Signed-off-by: Guo, Yejun 
> ---
>  configure  |   7 ++
>  libavcodec/libvpxenc.c | 197 
> +
>  2 files changed, 204 insertions(+)
>
> diff --git a/configure b/configure
> index 3fb8f35..e549e26 100755
> --- a/configure
> +++ b/configure
> @@ -6300,6 +6300,13 @@ enabled libvpx&& {
>  check_pkg_config libvpx_vp9_encoder "vpx >= 1.4.0" 
> "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
>  check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" 
> "vpx_codec_vp9_cx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs 
> $pthreads_extralibs"
>  }
> +enabled libvpx_vp9_encoder && {
> +test_cc < +#include 
> +void foo(void){ int i = VP9E_SET_ROI_MAP; }
> +EOF
> +}
> +

This can be removed after addressing the comment below.

> [...].
> +
> +static int vp9_encode_set_roi(AVCodecContext *avctx, int frame_width, int 
> frame_height, const AVFrameSideData *sd)
> +{
> +int roi_supported = 0;
> +VPxContext *ctx = avctx->priv_data;
> +
> +#ifdef SUPPORT_LIBVPX_VP9_ROI

You can use VPX_CTRL_VP9E_SET_ROI_MAP to check availability. All
controls have a corresponding VPX_CTRL_ define (see the
bottom of vpx/vp8cx.h).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures

2019-08-13 Thread Juan De León
AVEncodeInfoFrame data structure to store as AVFrameSideData of type
AV_FRAME_DATA_ENCODE_INFO.
The structure stores quantization index for each plane, DC/AC deltas
for luma and chroma planes, and an array of AVEncodeInfoBlock type
denoting position, size, and delta quantizer for each block in the
frame.
Can be extended to support extraction of other block information.

Signed-off-by: Juan De León 
---
 libavutil/Makefile  |   2 +
 libavutil/encode_info.c |  68 +
 libavutil/encode_info.h | 110 
 libavutil/frame.c   |   1 +
 libavutil/frame.h   |   7 +++
 5 files changed, 188 insertions(+)
 create mode 100644 libavutil/encode_info.c
 create mode 100644 libavutil/encode_info.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 57e6e3d7e8..37cfb099e9 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -24,6 +24,7 @@ HEADERS = adler32.h   
  \
   dict.h\
   display.h \
   downmix_info.h\
+  encode_info.h \
   encryption_info.h \
   error.h   \
   eval.h\
@@ -111,6 +112,7 @@ OBJS = adler32.o
\
dict.o   \
display.o\
downmix_info.o   \
+   encode_info.o\
encryption_info.o\
error.o  \
eval.o   \
diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
new file mode 100644
index 00..631934efc2
--- /dev/null
+++ b/libavutil/encode_info.c
@@ -0,0 +1,68 @@
+/*
+ * 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/encode_info.h"
+#include "libavutil/mem.h"
+
+static int init_encode_info_data(AVEncodeInfoFrame *info, int nb_blocks) {
+info->nb_blocks = nb_blocks;
+info->block_size = sizeof(AVEncodeInfoBlock);
+info->blocks_offset = offsetof(AVEncodeInfoFrame, blocks);
+
+for(int i = 0; i < AV_NUM_DATA_POINTERS; i++)
+info->plane_q[i] = -1;
+
+return 0;
+}
+
+AVEncodeInfoFrame *av_encode_info_alloc(unsigned nb_blocks)
+{
+AVEncodeInfoFrame *ptr;
+//AVEncodeInfoFrame already allocates size for one element of 
AVEncodeInfoBlock
+size_t size = sizeof(AVEncodeInfoFrame) + 
sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks - 1, 0);
+
+if (size >= INT_MAX)
+return NULL;
+
+ptr = av_mallocz(size);
+if (!ptr)
+return NULL;
+
+init_encode_info_data(ptr, nb_blocks);
+
+return ptr;
+}
+
+AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, unsigned 
nb_blocks)
+{
+size_t size = sizeof(AVEncodeInfoFrame) + 
sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks - 1, 0);
+
+if (size >= INT_MAX)
+return NULL;
+
+AVFrameSideData *sd = av_frame_new_side_data(frame,
+ AV_FRAME_DATA_ENCODE_INFO,
+ size);
+if (!sd)
+return NULL;
+
+memset(sd->data, 0, size);
+init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks);
+
+return (AVEncodeInfoFrame*)sd->data;
+}
diff --git a/libavutil/encode_info.h b/libavutil/encode_info.h
new file mode 100644
index 00..8408deb382
--- /dev/null
+++ b/libavutil/encode_info.h
@@ -0,0 +1,110 @@
+/*
+ * 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 

Re: [FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures

2019-08-13 Thread Nicolas George
Juan De León (12019-08-13):
> The array is there so that the structure isn't opaque, it should be
> accessed with the function.

I realize you need it, but not for the reason you say. It is needed for
alignment: if blocks needs more alignment than info, info+sizeof(info)
is not a valid pointer for blocks.

> > > +if (!info || idx >= info->nb_blocks || idx < 0)
> > > +return NULL;
> > How valid is it for applications to call with idx outside the range?
> They shouldn't but I figure it's better to return NULL than to get
> undefined behaviour.

In that case, I think is is better practice to document:

Index must be between 0 and nb_blocks

and check with an assert, forcing the application programmer fix their
code immediately.

Most code will likely use idx from a loop counter, where it cannot be
outside the range, and for the few other cases, the caller can do the
check if necessary.

Also, make the fields that cannot be negative unsigned, and you can drop
the <0 test.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures

2019-08-13 Thread Juan De León
On Tue, Aug 13, 2019 at 2:49 PM Nicolas George  wrote:

> > +info->blocks_offset = offsetof(AVEncodeInfoFrame, blocks);
>
> You can use sizeof(AVEncodeInfoFrame) and dispense with the blocks final
> array entirely.
>
The array is there so that the structure isn't opaque, it should be
accessed with the function.


> > +if (!info || idx >= info->nb_blocks || idx < 0)
> > +return NULL;
>
> How valid is it for applications to call with idx outside the range?

They shouldn't but I figure it's better to return NULL than to get
undefined behaviour.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures

2019-08-13 Thread Nicolas George
Juan De León (12019-08-13):
> AVEncodeInfoFrame data structure to store as AVFrameSideData of type
> AV_FRAME_DATA_ENCODE_INFO.
> The structure stores quantization index for each plane, DC/AC deltas
> for luma and chroma planes, and an array of AVEncodeInfoBlock type
> denoting position, size, and delta quantizer for each block in the
> frame.
> Can be extended to support extraction of other block information.
> 
> Signed-off-by: Juan De León 
> ---
>  libavutil/Makefile  |   2 +
>  libavutil/encode_info.c |  68 +
>  libavutil/encode_info.h | 110 
>  libavutil/frame.c   |   1 +
>  libavutil/frame.h   |   7 +++
>  5 files changed, 188 insertions(+)
>  create mode 100644 libavutil/encode_info.c
>  create mode 100644 libavutil/encode_info.h
> 
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index 57e6e3d7e8..37cfb099e9 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -24,6 +24,7 @@ HEADERS = adler32.h 
> \
>dict.h\
>display.h \
>downmix_info.h\
> +  encode_info.h \
>encryption_info.h \
>error.h   \
>eval.h\
> @@ -111,6 +112,7 @@ OBJS = adler32.o  
>   \
> dict.o   \
> display.o\
> downmix_info.o   \
> +   encode_info.o\
> encryption_info.o\
> error.o  \
> eval.o   \
> diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
> new file mode 100644
> index 00..ffc43f2c19
> --- /dev/null
> +++ b/libavutil/encode_info.c
> @@ -0,0 +1,68 @@
> +/*
> + * 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/encode_info.h"
> +#include "libavutil/mem.h"
> +
> +static int init_encode_info_data(AVEncodeInfoFrame *info, int nb_blocks) {
> +info->nb_blocks = nb_blocks;
> +info->block_size = sizeof(AVEncodeInfoBlock);

> +info->blocks_offset = offsetof(AVEncodeInfoFrame, blocks);

You can use sizeof(AVEncodeInfoFrame) and dispense with the blocks final
array entirely.

> +
> +for(int i = 0; i < AV_NUM_DATA_POINTERS; i++)
> +info->plane_q[i] = -1;
> +
> +return 0;
> +}
> +
> +AVEncodeInfoFrame *av_encode_info_alloc(int nb_blocks)
> +{
> +AVEncodeInfoFrame *ptr;
> +//AVEncodeInfoFrame already allocates size for one element of 
> AVEncodeInfoBlock
> +size_t size = sizeof(AVEncodeInfoFrame) + 
> sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks - 1, 0);
> +
> +if (nb_blocks < 0 || size >= INT_MAX)
> +return NULL;
> +
> +ptr = av_mallocz(size);
> +if (!ptr)
> +return NULL;
> +
> +init_encode_info_data(ptr, nb_blocks);
> +
> +return ptr;
> +}
> +
> +AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, int 
> nb_blocks)
> +{
> +size_t size = sizeof(AVEncodeInfoFrame) + 
> sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks - 1, 0);
> +
> +if (nb_blocks < 0 || size >= INT_MAX)
> +return NULL;
> +
> +AVFrameSideData *sd = av_frame_new_side_data(frame,
> + AV_FRAME_DATA_ENCODE_INFO,
> + size);
> +if (!sd)
> +return NULL;
> +
> +memset(sd->data, 0, size);
> +init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks);
> +
> +return (AVEncodeInfoFrame*)sd->data;
> +}
> diff --git 

[FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures

2019-08-13 Thread Juan De León
AVEncodeInfoFrame data structure to store as AVFrameSideData of type
AV_FRAME_DATA_ENCODE_INFO.
The structure stores quantization index for each plane, DC/AC deltas
for luma and chroma planes, and an array of AVEncodeInfoBlock type
denoting position, size, and delta quantizer for each block in the
frame.
Can be extended to support extraction of other block information.

Signed-off-by: Juan De León 
---
 libavutil/Makefile  |   2 +
 libavutil/encode_info.c |  68 +
 libavutil/encode_info.h | 110 
 libavutil/frame.c   |   1 +
 libavutil/frame.h   |   7 +++
 5 files changed, 188 insertions(+)
 create mode 100644 libavutil/encode_info.c
 create mode 100644 libavutil/encode_info.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 57e6e3d7e8..37cfb099e9 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -24,6 +24,7 @@ HEADERS = adler32.h   
  \
   dict.h\
   display.h \
   downmix_info.h\
+  encode_info.h \
   encryption_info.h \
   error.h   \
   eval.h\
@@ -111,6 +112,7 @@ OBJS = adler32.o
\
dict.o   \
display.o\
downmix_info.o   \
+   encode_info.o\
encryption_info.o\
error.o  \
eval.o   \
diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
new file mode 100644
index 00..ffc43f2c19
--- /dev/null
+++ b/libavutil/encode_info.c
@@ -0,0 +1,68 @@
+/*
+ * 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/encode_info.h"
+#include "libavutil/mem.h"
+
+static int init_encode_info_data(AVEncodeInfoFrame *info, int nb_blocks) {
+info->nb_blocks = nb_blocks;
+info->block_size = sizeof(AVEncodeInfoBlock);
+info->blocks_offset = offsetof(AVEncodeInfoFrame, blocks);
+
+for(int i = 0; i < AV_NUM_DATA_POINTERS; i++)
+info->plane_q[i] = -1;
+
+return 0;
+}
+
+AVEncodeInfoFrame *av_encode_info_alloc(int nb_blocks)
+{
+AVEncodeInfoFrame *ptr;
+//AVEncodeInfoFrame already allocates size for one element of 
AVEncodeInfoBlock
+size_t size = sizeof(AVEncodeInfoFrame) + 
sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks - 1, 0);
+
+if (nb_blocks < 0 || size >= INT_MAX)
+return NULL;
+
+ptr = av_mallocz(size);
+if (!ptr)
+return NULL;
+
+init_encode_info_data(ptr, nb_blocks);
+
+return ptr;
+}
+
+AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, int 
nb_blocks)
+{
+size_t size = sizeof(AVEncodeInfoFrame) + 
sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks - 1, 0);
+
+if (nb_blocks < 0 || size >= INT_MAX)
+return NULL;
+
+AVFrameSideData *sd = av_frame_new_side_data(frame,
+ AV_FRAME_DATA_ENCODE_INFO,
+ size);
+if (!sd)
+return NULL;
+
+memset(sd->data, 0, size);
+init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks);
+
+return (AVEncodeInfoFrame*)sd->data;
+}
diff --git a/libavutil/encode_info.h b/libavutil/encode_info.h
new file mode 100644
index 00..864e42bdcf
--- /dev/null
+++ b/libavutil/encode_info.h
@@ -0,0 +1,110 @@
+/*
+ * 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; 

[FFmpeg-devel] [PATCH] ffplay: properly detect all window size changes

2019-08-13 Thread Marton Balint
SDL_WINDOWEVENT_SIZE_CHANGED should be used instead of SDL_WINDOWEVENT_RESIZED
because SDL_WINDOWEVENT_RESIZED is only emitted if the resize happened due to
an external event.

Fixes ticket #8072.

Additional references:
https://bugzilla.libsdl.org/show_bug.cgi?id=4760
https://wiki.libsdl.org/SDL_WindowEventID

Signed-off-by: Marton Balint 
---
 fftools/ffplay.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 8fb8faeb06..fee0619f7c 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3436,7 +3436,7 @@ static void event_loop(VideoState *cur_stream)
 break;
 case SDL_WINDOWEVENT:
 switch (event.window.event) {
-case SDL_WINDOWEVENT_RESIZED:
+case SDL_WINDOWEVENT_SIZE_CHANGED:
 screen_width  = cur_stream->width  = event.window.data1;
 screen_height = cur_stream->height = event.window.data2;
 if (cur_stream->vis_texture) {
-- 
2.16.4

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

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

Re: [FFmpeg-devel] [PATCH 0/1] Parsing quicktime tracks in matroska containers

2019-08-13 Thread Carl Eugen Hoyos


> Am 13.08.2019 um 21:16 schrieb Stanislav Ionascu 
> :
> 
> Hi All,
> 
> when remuxing some of the mp4 files into the mkv container, not all
> video codecs can be properly represented. As such, to make the codec
> configuration complete, mkvtoolnix muxes in the full stsd box.
> 
> I also switched "detecting" DVH1 in a v_quicktime track in an mkv file, as a 
> HEVC
> codec, as I did not find a better way (yet) to check if hvcC box exists in
> stsd.
> 
> The easiest way to verify the patch. Is to take a dolby vision profile 5
> mp4, and mux it with mkv-toolnix into an mkv. Without this patch, the
> file is unplayable.

Please provide such a short sample.

Which other files is your patch supposed to fix?

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

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

Re: [FFmpeg-devel] [PATCH 1/1] avformat/matroska: fully parse stsd atom in v_quicktime tracks

2019-08-13 Thread Andreas Rheinhardt
Stanislav Ionascu:
> Per matroska spec, v_quicktime contains the complete stsd atom, after
> the mandatory size + fourcc. By properly parsing the hvcc sub-atoms of
> the track, it becomes possible to demux/decode mp4/mov tracks stored as is
> in matroska containers.
> 
> Also dvh1 in stsd in matroska is more likely hevc codec than dv.
> 
> Signed-off-by: Stanislav Ionascu 
> ---
>  libavformat/matroskadec.c | 51 +++
>  1 file changed, 36 insertions(+), 15 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 4e20f15792..88bc89c545 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -2473,25 +2473,46 @@ static int matroska_parse_tracks(AVFormatContext *s)
>  } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
> (track->codec_priv.size >= 21)  &&
> (track->codec_priv.data)) {
> +MOVStreamContext *msc;
> +MOVContext *mc = NULL;
> +AVIOContext *stsd_ctx = NULL;
> +void *priv_data;
> +int nb_streams;
>  int ret = get_qt_codec(track, , _id);
>  if (ret < 0)
>  return ret;
> -if (codec_id == AV_CODEC_ID_NONE && 
> AV_RL32(track->codec_priv.data+4) == AV_RL32("SMI ")) {
> -fourcc = MKTAG('S','V','Q','3');
> -codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
> +av_log(matroska->ctx, AV_LOG_TRACE,
> +   "FourCC found %s.\n", av_fourcc2str(fourcc));
> +priv_data = st->priv_data;
> +nb_streams = s->nb_streams;
> +mc = av_mallocz(sizeof(*mc));
> +if (!mc)
> +return AVERROR(ENOMEM);
> +stsd_ctx = avio_alloc_context(track->codec_priv.data,
> +track->codec_priv.size,
> +0, NULL, NULL, NULL, NULL);
> +if (!stsd_ctx)
> +return AVERROR(ENOMEM);
I haven't looked at this patch deeply yet, but it seems to me that you
should rather use ffio_init_context like it is done in the code that
you intend to delete. That saves allocating and freeing stsd_ctx. You
can even reuse the AVIOContext b that already exists on the stack.
> +mc->fc = s;
> +st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext));
> +if (!msc) {
> +av_free(mc);
> +st->priv_data = priv_data;
> +return AVERROR(ENOMEM);
>  }
> -if (codec_id == AV_CODEC_ID_NONE)
> -av_log(matroska->ctx, AV_LOG_ERROR,
> -   "mov FourCC not found %s.\n", av_fourcc2str(fourcc));
> -if (track->codec_priv.size >= 86) {
> -bit_depth = AV_RB16(track->codec_priv.data + 82);
> -ffio_init_context(, track->codec_priv.data,
> -  track->codec_priv.size,
> -  0, NULL, NULL, NULL, NULL);
> -if (ff_get_qtpalette(codec_id, , track->palette)) {
> -bit_depth &= 0x1F;
> -track->has_palette = 1;
Why are you removing this code? What about tracks that ought to have a
palette?
> -}
> +/* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
> + * so set it temporarily to indicate which stream to update. */
> +s->nb_streams = st->index + 1;
> +ff_mov_read_stsd_entries(mc, stsd_ctx, 1);
> +av_free(msc);
> +av_free(mc);
> +avio_context_free(_ctx);
> +st->priv_data = priv_data;
> +s->nb_streams = nb_streams;
> +
> +// dvh1 in mkv is likely HEVC
> +if (st->codecpar->codec_tag == MKTAG('d','v','h','1')) {
> +codec_id = AV_CODEC_ID_HEVC;
>  }
>  } else if (codec_id == AV_CODEC_ID_PCM_S16BE) {
>  switch (track->audio.bitdepth) {
> 

Also, your patch should refer to the exact component that is about to
be changed: avformat/matroskadec.

- Andreas

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/indeo2: Check remaining input more often

2019-08-13 Thread Michael Niedermayer
On Thu, Aug 01, 2019 at 02:26:22AM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (95sec -> 30ms)
> Fixes: 
> 14765/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INDEO2_fuzzer-5692455527120896
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpe
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/indeo2.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)

will apply patchset

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

Never trust a computer, one day, it may think you are the virus. -- Compn


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

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

[FFmpeg-devel] [PATCH] libavformat/mxfenc: Allow more bitrates for NTSC IMX50

2019-08-13 Thread Thomas Mundt
Hi,

attached patch fixes ticket #8077.
Please comment.

Regards,
Thomas


0001-libavformat-mxfenc-Allow-more-bitrates-for-NTSC-IMX5.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 0/1] Parsing quicktime tracks in matroska containers

2019-08-13 Thread Kieran O Leary
On Tue, 13 Aug 2019, 20:25 Stanislav Ionascu, 
wrote:

> Hi All,
>
> when remuxing some of the mp4 files into the mkv container, not all
> video codecs can be properly represented.


Purely out of curiosity, what other codes does this affect?

Best,

Kieran O'Leary
Irish Film Institute
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 1/1] avformat/matroska: fully parse stsd atom in v_quicktime tracks

2019-08-13 Thread Stanislav Ionascu
Per matroska spec, v_quicktime contains the complete stsd atom, after
the mandatory size + fourcc. By properly parsing the hvcc sub-atoms of
the track, it becomes possible to demux/decode mp4/mov tracks stored as is
in matroska containers.

Also dvh1 in stsd in matroska is more likely hevc codec than dv.

Signed-off-by: Stanislav Ionascu 
---
 libavformat/matroskadec.c | 51 +++
 1 file changed, 36 insertions(+), 15 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 4e20f15792..88bc89c545 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2473,25 +2473,46 @@ static int matroska_parse_tracks(AVFormatContext *s)
 } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
(track->codec_priv.size >= 21)  &&
(track->codec_priv.data)) {
+MOVStreamContext *msc;
+MOVContext *mc = NULL;
+AVIOContext *stsd_ctx = NULL;
+void *priv_data;
+int nb_streams;
 int ret = get_qt_codec(track, , _id);
 if (ret < 0)
 return ret;
-if (codec_id == AV_CODEC_ID_NONE && 
AV_RL32(track->codec_priv.data+4) == AV_RL32("SMI ")) {
-fourcc = MKTAG('S','V','Q','3');
-codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
+av_log(matroska->ctx, AV_LOG_TRACE,
+   "FourCC found %s.\n", av_fourcc2str(fourcc));
+priv_data = st->priv_data;
+nb_streams = s->nb_streams;
+mc = av_mallocz(sizeof(*mc));
+if (!mc)
+return AVERROR(ENOMEM);
+stsd_ctx = avio_alloc_context(track->codec_priv.data,
+track->codec_priv.size,
+0, NULL, NULL, NULL, NULL);
+if (!stsd_ctx)
+return AVERROR(ENOMEM);
+mc->fc = s;
+st->priv_data = msc = av_mallocz(sizeof(MOVStreamContext));
+if (!msc) {
+av_free(mc);
+st->priv_data = priv_data;
+return AVERROR(ENOMEM);
 }
-if (codec_id == AV_CODEC_ID_NONE)
-av_log(matroska->ctx, AV_LOG_ERROR,
-   "mov FourCC not found %s.\n", av_fourcc2str(fourcc));
-if (track->codec_priv.size >= 86) {
-bit_depth = AV_RB16(track->codec_priv.data + 82);
-ffio_init_context(, track->codec_priv.data,
-  track->codec_priv.size,
-  0, NULL, NULL, NULL, NULL);
-if (ff_get_qtpalette(codec_id, , track->palette)) {
-bit_depth &= 0x1F;
-track->has_palette = 1;
-}
+/* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
+ * so set it temporarily to indicate which stream to update. */
+s->nb_streams = st->index + 1;
+ff_mov_read_stsd_entries(mc, stsd_ctx, 1);
+av_free(msc);
+av_free(mc);
+avio_context_free(_ctx);
+st->priv_data = priv_data;
+s->nb_streams = nb_streams;
+
+// dvh1 in mkv is likely HEVC
+if (st->codecpar->codec_tag == MKTAG('d','v','h','1')) {
+codec_id = AV_CODEC_ID_HEVC;
 }
 } else if (codec_id == AV_CODEC_ID_PCM_S16BE) {
 switch (track->audio.bitdepth) {
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 0/1] Parsing quicktime tracks in matroska containers

2019-08-13 Thread Stanislav Ionascu
Hi All,

when remuxing some of the mp4 files into the mkv container, not all
video codecs can be properly represented. As such, to make the codec
configuration complete, mkvtoolnix muxes in the full stsd box.

I also switched "detecting" DVH1 in a v_quicktime track in an mkv file, as a 
HEVC
codec, as I did not find a better way (yet) to check if hvcC box exists in
stsd.

The easiest way to verify the patch. Is to take a dolby vision profile 5
mp4, and mux it with mkv-toolnix into an mkv. Without this patch, the
file is unplayable.

I'm open to any other approaches for solving the issue.

Thanks!
Stan.

Stanislav Ionascu (1):
  avformat/matroska: fully parse stsd atom in v_quicktime tracks

 libavformat/matroskadec.c | 51 +++
 1 file changed, 36 insertions(+), 15 deletions(-)

-- 
2.20.1

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

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

Re: [FFmpeg-devel] [PATCH 2/2] convert_from_tensorflow.py: support conv2d with dilation

2019-08-13 Thread Pedro Arthur
LGTM.
Should push soon.

BTW I just noticed that the tensorflow backend is failling to load SR
filter models.

$ python tools/python/convert.py sr_models/srcnn.pb
$ ./ffmpeg -i input.jpg -vf
sr=model=srcnn.model:dnn_backend=tensorflow out_srcnn_tf.png

The above command fails.
It seems commit ccbab41039af424237eaac5c302c293ab97540f8 is the
problem. I thought I had tested it but clearly I made a mistake
somewhere in the process.
I suppose you have the .pb files to test it, but let me know if you need them.

Em sex, 9 de ago de 2019 às 12:25, Guo, Yejun  escreveu:
>
>
>
> > -Original Message-
> > From: Guo, Yejun
> > Sent: Tuesday, July 30, 2019 9:26 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Guo, Yejun 
> > Subject: [PATCH 2/2] convert_from_tensorflow.py: support conv2d with 
> > dilation
> >
> > conv2d with dilation > 1 generates tens of nodes in graph, it is not
> > easy to parse each node one by one, so we do special tricks to parse
> > the conv2d layer.
> >
> > Signed-off-by: Guo, Yejun 
> > ---
> >  tools/python/convert_from_tensorflow.py | 80
> > -
> >  1 file changed, 59 insertions(+), 21 deletions(-)
>
> this patch set asks for review, thanks.
>
> I've locally finished more patches to improve dnn module, plan to send more 
> them set by set, since the patches have dependency.
>
> Just in case you are interested in these new patches, I've uploaded to 
> https://github.com/guoyejun/ffmpeg/tree/dnn0809.
> for your convenient, I also copy the oneline log here for each patch (from 
> newer to older) with 4 patch sets.
>
> 7eced90 libavfilter/dnn: support multiple outputs for native mode
> 28a7054 libavfilter/dnn/dnn_backend_native: find the input operand according 
> to input name
>
> 256e657 FATE/dnn: add unit test for layer maximum
> 8c616a0 libavfilter/dnn: add layer maximum for native mode.
>
> 8ec6c0c FATE/dnn: add unit test for dnn depth_to_space layer
> 09ef108 libavfilter/dnn: separate depth_to_space layer from 
> dnn_backend_native.c to a new file
> c65b59d FATE/dnn: add unit test for dnn conv2d layer
> a5d69a7 libavfilter/dnn: separate conv2d layer from dnn_backend_native.c to a 
> new file
>
> 202d323 dnn: export operand info in python script and load in c code
> 3c706a0 dnn: change .model file format to put layer number at the end of file
> 0256731 dnn: introduce dnn operand (in c code) to hold operand infos within 
> network
>
>
> Besides continuous dnn improvement, I also plan to add two generic video 
> filters for dnn.
> - a generic filter to process the content of AVFrame with different dnn 
> networks.
> and so the current specific filters such as vf_sr (some changes needed) and 
> vf_derain are no longer needed, since they can be
> included in this specific filter. And of course, in practice I'll not remove 
> them.
>
> - a generic filter to analyze the content of AVFrame to generate some side 
> data with different dnn networks. The content of AVFrame does not change.
> The application, which invokes the filter with a given dnn network, has the 
> responsibility/knowledge to parse the side data (analyze result).
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v6] avfilter/avf_aphasemeter: Add out-of-phase and mono detection

2019-08-13 Thread Romane Lafon
This patch extends aphasemeter to detect out of phase or mono sequences in
stereo streams, with its associated documentation.
From f7f627e48282c4aefa5229925454f97747822deb Mon Sep 17 00:00:00 2001
From: Romane Lafon 
Date: Tue, 13 Aug 2019 17:39:36 +0200
Subject: [PATCH] avfilter/avf_aphasemeter: Add out of phase and mono detection

Signed-off-by: Romane Lafon 
---
 doc/filters.texi  |  33 +++
 libavfilter/avf_aphasemeter.c | 124 --
 2 files changed, 153 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index e081cdc7bc..d1f272c091 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20810,6 +20810,39 @@ Set color which will be used for drawing median phase. If color is
 Enable video output. Default is enabled.
 @end table
 
+@subsection phasing detection
+
+The filter also detects out of phase and mono sequences in stereo streams.
+It logs the sequence start, end and duration when it lasts longer or as long as the minimum set.
+
+The filter accepts the following options for this detection:
+
+@table @option
+@item phasing
+Enable mono and out of phase detection. Default is disabled.
+
+@item tolerance
+Set phase tolerance for mono detection, in amplitude ratio. Default is @code{0}.
+Allowed range is @code{[0, 1]}.
+
+@item angle
+Set angle threshold for out of phase detection, in degree. Default is @code{170}.
+Allowed range is @code{[0, 180]}.
+
+@item duration
+Set mono or out of phase duration until notification, expressed in seconds. Default is @code{2}.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Complete example with @command{ffmpeg} to detect 1 second of mono with 0.001 phase tolerance:
+@example
+ffmpeg -i stereo.wav -af aphasemeter=video=0:phasing=1:duration=1:tolerance=0.001 -f null -
+@end example
+@end itemize
+
 @section avectorscope
 
 Convert input audio to a video output, representing the audio vector
diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c
index f497bc9969..60cc153e61 100644
--- a/libavfilter/avf_aphasemeter.c
+++ b/libavfilter/avf_aphasemeter.c
@@ -28,26 +28,40 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
 #include "libavutil/parseutils.h"
+#include "libavutil/timestamp.h"
 #include "avfilter.h"
 #include "formats.h"
 #include "audio.h"
 #include "video.h"
 #include "internal.h"
+#include "float.h"
 
 typedef struct AudioPhaseMeterContext {
 const AVClass *class;
 AVFrame *out;
 int do_video;
+int do_phasing_detection;
 int w, h;
 AVRational frame_rate;
 int contrast[4];
 uint8_t *mpc_str;
 uint8_t mpc[4];
 int draw_median_phase;
+int is_mono;
+int is_out_phase;
+int start_mono_presence;
+int start_out_phase_presence;
+float tolerance;
+float angle;
+float phase;
+float mono_idx[2];
+float out_phase_idx[2];
+double duration;
 } AudioPhaseMeterContext;
 
 #define OFFSET(x) offsetof(AudioPhaseMeterContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+#define get_duration(index) (index[1] - index[0])
 
 static const AVOption aphasemeter_options[] = {
 { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
@@ -59,6 +73,10 @@ static const AVOption aphasemeter_options[] = {
 { "bc", "set blue contrast",  OFFSET(contrast[2]), AV_OPT_TYPE_INT, {.i64=1}, 0, 255, FLAGS },
 { "mpc", "set median phase color", OFFSET(mpc_str), AV_OPT_TYPE_STRING, {.str = "none"}, 0, 0, FLAGS },
 { "video", "set video output", OFFSET(do_video), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
+{ "phasing", "set mono and out-of-phase detection output", OFFSET(do_phasing_detection), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
+{ "tolerance", "set phase tolerance for mono detection", OFFSET(tolerance), AV_OPT_TYPE_FLOAT, {.dbl = 0.}, 0, 1, FLAGS },
+{ "angle", "set angle threshold for out-of-phase detection", OFFSET(angle), AV_OPT_TYPE_FLOAT, {.dbl = 170.}, 90, 180, FLAGS },
+{ "duration", "set minimum mono or out-of-phase duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl=2.}, 0, 24*60*60, FLAGS },
 { NULL }
 };
 
@@ -140,6 +158,22 @@ static inline int get_x(float phase, int w)
   return (phase + 1.) / 2. * (w - 1);
 }
 
+static inline float get_index(AVFilterLink *inlink, AVFrame *in)
+{
+char *index_str = av_ts2timestr(in->pts, >time_base);
+return atof(index_str);
+}
+
+static inline void add_metadata(AVFrame *insamples, const char *key, float value)
+{
+char buf[128];
+char str[128];
+
+snprintf(str, sizeof(str), "%f", value);
+snprintf(buf, sizeof(buf), "lavfi.aphasemeter.%s", key);
+av_dict_set(>metadata, buf, str, 0);
+}
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx = inlink->dst;
@@ -154,6 +188,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 AVFrame *out;
 

Re: [FFmpeg-devel] [PATCH v5] avfilter/avf_aphasemeter: Add out-of-phase and mono detection

2019-08-13 Thread Romane Lafon
Ok, did it in v6. I also removed unused variables in uninit function :

+float tolerance = 1.0f - s->tolerance;

+float angle = cosf(s->angle/180.0f*M_PI);


Le lun. 5 août 2019 à 17:18, Paul B Mahol  a écrit :

> This should be applied with sdtbool.h  include removed.
>
> On Mon, Jul 8, 2019 at 2:01 PM Romane Lafon  wrote:
>
> > This patch extends aphasemeter to detect out of phase or mono sequences
> in
> > stereo streams, with its associated documentation.
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavformat/subfile: Fix SEEK_CUR and SEEK_END seeking

2019-08-13 Thread Nicolas George
Andreas Rheinhardt (12019-08-08):
> Ping.

I just pushed your patch and mine.

Regards,

-- 
  Nicolas George


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

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

[FFmpeg-devel] [PATCH v1] fftoos/ffmpeg_opt: avoid to display the hwaccels name twice

2019-08-13 Thread lance . lmwang
From: Limin Wang 

videotoolbox and qsv have been defined by hw_type_names[] in hwcontext.c

Signed-off-by: Limin Wang 
---
 fftools/ffmpeg_opt.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index f5ca18a..8baa898 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -66,12 +66,6 @@
 }
 
 const HWAccel hwaccels[] = {
-#if CONFIG_VIDEOTOOLBOX
-{ "videotoolbox", videotoolbox_init, HWACCEL_VIDEOTOOLBOX, 
AV_PIX_FMT_VIDEOTOOLBOX },
-#endif
-#if CONFIG_LIBMFX
-{ "qsv",   qsv_init,   HWACCEL_QSV,   AV_PIX_FMT_QSV },
-#endif
 #if CONFIG_CUVID
 { "cuvid", cuvid_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA },
 #endif
-- 
2.6.4

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

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

Re: [FFmpeg-devel] [PATCH V1] lavf/mov: fix fMP4 tfdt box lead to dts reset issue

2019-08-13 Thread myp...@gmail.com
On Tue, Aug 13, 2019 at 7:08 PM Carl Eugen Hoyos  wrote:
>
> Am Di., 13. Aug. 2019 um 12:36 Uhr schrieb Jun Zhao :
> >
> > From: Jun Zhao 
> >
> > In fMP4 format, traf maybe have zero or more trun box, in this case,
> > we just used tfdt as dts once. The sample layout like this:
> >
> > [moof] size=8+1392
> >   [mfhd] size=12+4
> > sequence number = 29
> >   [traf] size=8+1368
> > [tfhd] size=12+16, flags=20038
> >   track ID = 1
> >   default sample duration = 512
> >   default sample size = 40720
> >   default sample flags = 0
> > [tfdt] size=12+8, version=1
> >   base media decode time = 1873920
> > [trun] size=12+452, version=1, flags=e01
> >   sample count = 37
> >   data offset = 1408
> > [trun] size=12+452, version=1, flags=e01
> >   sample count = 37
> >   data offset = 292973
> > [trun] size=12+380, version=1, flags=e01
> >   sample count = 31
> >   data offset = 586457
>
> If this is meant to fix ticket #8070, please mention it in the commit message.
>
> But more important: How did you test this patch / what does this patch
> change with the sample from ticket #8070?
>
I got a copyrighted sample for this issue, maybe I need to add FATE
test case with no copyright sample for this issue, I think. After I
submitted the patch, I found #8070 in trac, by the way, I think this
patch didn't fix #8070 after verified the #8070 test sample vd.mp4. I
will try to fix #8070. Thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] avutil/mips: remove redundant code in TRANSPOSE16x8_UB_UB.

2019-08-13 Thread Shiyou Yin
---
 libavutil/mips/generic_macros_msa.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavutil/mips/generic_macros_msa.h 
b/libavutil/mips/generic_macros_msa.h
index 9ac0583..219ff07 100644
--- a/libavutil/mips/generic_macros_msa.h
+++ b/libavutil/mips/generic_macros_msa.h
@@ -2523,8 +2523,6 @@
 out5 = (v16u8) __msa_ilvod_w((v4i32) tmp3_m, (v4i32) tmp2_m);\
  \
 tmp2_m = (v16u8) __msa_ilvod_h((v8i16) tmp5_m, (v8i16) tmp4_m);  \
-tmp2_m = (v16u8) __msa_ilvod_h((v8i16) tmp5_m, (v8i16) tmp4_m);  \
-tmp3_m = (v16u8) __msa_ilvod_h((v8i16) tmp7_m, (v8i16) tmp6_m);  \
 tmp3_m = (v16u8) __msa_ilvod_h((v8i16) tmp7_m, (v8i16) tmp6_m);  \
 out3 = (v16u8) __msa_ilvev_w((v4i32) tmp3_m, (v4i32) tmp2_m);\
 out7 = (v16u8) __msa_ilvod_w((v4i32) tmp3_m, (v4i32) tmp2_m);\
-- 
2.1.0


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

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

Re: [FFmpeg-devel] [PATCH V1] lavf/mov: fix fMP4 tfdt box lead to dts reset issue

2019-08-13 Thread Carl Eugen Hoyos
Am Di., 13. Aug. 2019 um 12:36 Uhr schrieb Jun Zhao :
>
> From: Jun Zhao 
>
> In fMP4 format, traf maybe have zero or more trun box, in this case,
> we just used tfdt as dts once. The sample layout like this:
>
> [moof] size=8+1392
>   [mfhd] size=12+4
> sequence number = 29
>   [traf] size=8+1368
> [tfhd] size=12+16, flags=20038
>   track ID = 1
>   default sample duration = 512
>   default sample size = 40720
>   default sample flags = 0
> [tfdt] size=12+8, version=1
>   base media decode time = 1873920
> [trun] size=12+452, version=1, flags=e01
>   sample count = 37
>   data offset = 1408
> [trun] size=12+452, version=1, flags=e01
>   sample count = 37
>   data offset = 292973
> [trun] size=12+380, version=1, flags=e01
>   sample count = 31
>   data offset = 586457

If this is meant to fix ticket #8070, please mention it in the commit message.

But more important: How did you test this patch / what does this patch
change with the sample from ticket #8070?

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

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

Re: [FFmpeg-devel] avformat/flvdec: delete unused code

2019-08-13 Thread Tao Zhang
Carl Eugen Hoyos  于2019年8月13日周二 下午5:37写道:
>
> Am Di., 13. Aug. 2019 um 09:06 Uhr schrieb leozhang :
> >
> > Signed-off-by: leozhang 
> > ---
> >  libavformat/flvdec.c | 16 
> >  1 file changed, 16 deletions(-)
> >
> > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> > index b531a39..4e8faed 100644
> > --- a/libavformat/flvdec.c
> > +++ b/libavformat/flvdec.c
> > @@ -1265,22 +1265,6 @@ retry_duration:
> >  if (st->codecpar->codec_id == AV_CODEC_ID_AAC && t && 
> > !strcmp(t->value, "Omnia A/XE"))
> >  st->codecpar->extradata_size = 2;
> >
> > -if (st->codecpar->codec_id == AV_CODEC_ID_AAC && 0) {
> > -MPEG4AudioConfig cfg;
> > -
> > -if (avpriv_mpeg4audio_get_config(, 
> > st->codecpar->extradata,
> > - 
> > st->codecpar->extradata_size * 8, 1) >= 0) {
> > -st->codecpar->channels   = cfg.channels;
> > -st->codecpar->channel_layout = 0;
> > -if (cfg.ext_sample_rate)
> > -st->codecpar->sample_rate = cfg.ext_sample_rate;
> > -else
> > -st->codecpar->sample_rate = cfg.sample_rate;
> > -av_log(s, AV_LOG_TRACE, "mp4a config channels %d sample 
> > rate %d\n",
> > -st->codecpar->channels, st->codecpar->sample_rate);
> > -}
> > -}
> > -
> >  ret = FFERROR_REDO;
> >  goto leave;
> >  }
>
> You forgot to remove '#include "libavcodec/mpeg4audio.h"'.
Thanks. Will send a new patch which removes this header.
>
> In case anybody is interested, here is the original thread:
> https://ffmpeg.org/pipermail/ffmpeg-devel/2009-February/065799.html
>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH V1] libavdevice: Update the class name as uniform style

2019-08-13 Thread Jun Zhao
From: Jun Zhao 

Update the class name to uniform indev/outdev style.

Signed-off-by: Jun Zhao 
---
 libavdevice/alsa_dec.c|2 +-
 libavdevice/alsa_enc.c|2 +-
 libavdevice/avfoundation.m|2 +-
 libavdevice/bktr.c|2 +-
 libavdevice/caca.c|2 +-
 libavdevice/decklink_dec_c.c  |2 +-
 libavdevice/decklink_enc_c.c  |2 +-
 libavdevice/openal-dec.c  |2 +-
 libavdevice/oss_dec.c |2 +-
 libavdevice/oss_enc.c |2 +-
 libavdevice/pulse_audio_dec.c |2 +-
 libavdevice/pulse_audio_enc.c |2 +-
 12 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavdevice/alsa_dec.c b/libavdevice/alsa_dec.c
index c50ce71..36494e9 100644
--- a/libavdevice/alsa_dec.c
+++ b/libavdevice/alsa_dec.c
@@ -148,7 +148,7 @@ static const AVOption options[] = {
 };
 
 static const AVClass alsa_demuxer_class = {
-.class_name = "ALSA demuxer",
+.class_name = "ALSA indev",
 .item_name  = av_default_item_name,
 .option = options,
 .version= LIBAVUTIL_VERSION_INT,
diff --git a/libavdevice/alsa_enc.c b/libavdevice/alsa_enc.c
index 0bef625..1a6d01e 100644
--- a/libavdevice/alsa_enc.c
+++ b/libavdevice/alsa_enc.c
@@ -151,7 +151,7 @@ static int audio_get_device_list(AVFormatContext *h, 
AVDeviceInfoList *device_li
 }
 
 static const AVClass alsa_muxer_class = {
-.class_name = "ALSA muxer",
+.class_name = "ALSA outdev",
 .item_name  = av_default_item_name,
 .version= LIBAVUTIL_VERSION_INT,
 .category   = AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT,
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 08deecf..af8fe31 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -1140,7 +1140,7 @@ static const AVOption options[] = {
 };
 
 static const AVClass avf_class = {
-.class_name = "AVFoundation input device",
+.class_name = "AVFoundation indev",
 .item_name  = av_default_item_name,
 .option = options,
 .version= LIBAVUTIL_VERSION_INT,
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index 993cc19..2601adb 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -341,7 +341,7 @@ static const AVOption options[] = {
 };
 
 static const AVClass bktr_class = {
-.class_name = "BKTR grab interface",
+.class_name = "BKTR grab indev",
 .item_name  = av_default_item_name,
 .option = options,
 .version= LIBAVUTIL_VERSION_INT,
diff --git a/libavdevice/caca.c b/libavdevice/caca.c
index 47de824..be3ff79 100644
--- a/libavdevice/caca.c
+++ b/libavdevice/caca.c
@@ -220,7 +220,7 @@ static const AVOption options[] = {
 };
 
 static const AVClass caca_class = {
-.class_name = "caca_outdev",
+.class_name = "caca outdev",
 .item_name  = av_default_item_name,
 .option = options,
 .version= LIBAVUTIL_VERSION_INT,
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 91d2839..7aceaf9 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -89,7 +89,7 @@ static const AVOption options[] = {
 };
 
 static const AVClass decklink_demuxer_class = {
-.class_name = "Blackmagic DeckLink demuxer",
+.class_name = "Blackmagic DeckLink indev",
 .item_name  = av_default_item_name,
 .option = options,
 .version= LIBAVUTIL_VERSION_INT,
diff --git a/libavdevice/decklink_enc_c.c b/libavdevice/decklink_enc_c.c
index 63cbd39..682c714 100644
--- a/libavdevice/decklink_enc_c.c
+++ b/libavdevice/decklink_enc_c.c
@@ -41,7 +41,7 @@ static const AVOption options[] = {
 };
 
 static const AVClass decklink_muxer_class = {
-.class_name = "Blackmagic DeckLink muxer",
+.class_name = "Blackmagic DeckLink outdev",
 .item_name  = av_default_item_name,
 .option = options,
 .version= LIBAVUTIL_VERSION_INT,
diff --git a/libavdevice/openal-dec.c b/libavdevice/openal-dec.c
index c19048e..57de665 100644
--- a/libavdevice/openal-dec.c
+++ b/libavdevice/openal-dec.c
@@ -241,7 +241,7 @@ static const AVOption options[] = {
 };
 
 static const AVClass class = {
-.class_name = "openal",
+.class_name = "openal indev",
 .item_name = av_default_item_name,
 .option = options,
 .version = LIBAVUTIL_VERSION_INT,
diff --git a/libavdevice/oss_dec.c b/libavdevice/oss_dec.c
index d0dc327..13ace70 100644
--- a/libavdevice/oss_dec.c
+++ b/libavdevice/oss_dec.c
@@ -125,7 +125,7 @@ static const AVOption options[] = {
 };
 
 static const AVClass oss_demuxer_class = {
-.class_name = "OSS demuxer",
+.class_name = "OSS indev",
 .item_name  = av_default_item_name,
 .option = options,
 .version= LIBAVUTIL_VERSION_INT,
diff --git a/libavdevice/oss_enc.c b/libavdevice/oss_enc.c
index e3172af..274c760 100644
--- a/libavdevice/oss_enc.c
+++ b/libavdevice/oss_enc.c
@@ -90,7 +90,7 @@ static int audio_write_trailer(AVFormatContext *s1)
 }
 
 

[FFmpeg-devel] [PATCH]lavf/chromaprint: Silence compilation warnings

2019-08-13 Thread Carl Eugen Hoyos
Hi!

Attached patch fixes several compilation warnings when building with
chromapring.

Please comment, Carl Eugen
From 96eb4a33e8b256ee3ae75f3600ba26e6cd9b3bf2 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Tue, 13 Aug 2019 12:42:27 +0200
Subject: [PATCH] lavf/chromaprint: Silence compilation warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes the following warnings:
libavformat/chromaprint.c:117:42: warning: passing argument 2 of ‘chromaprint_feed’ from incompatible pointer type
libavformat/chromaprint.c:132:52: warning: passing argument 2 of ‘chromaprint_get_raw_fingerprint’ from incompatible pointer type
libavformat/chromaprint.c:143:71: warning: passing argument 4 of ‘chromaprint_encode_fingerprint’ from incompatible pointer type
---
 libavformat/chromaprint.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c
index f39c09ddb9..77015d9c10 100644
--- a/libavformat/chromaprint.c
+++ b/libavformat/chromaprint.c
@@ -114,14 +114,15 @@ fail:
 static int write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 ChromaprintMuxContext *cpr = s->priv_data;
-return chromaprint_feed(cpr->ctx, pkt->data, pkt->size / 2) ? 0 : AVERROR(EINVAL);
+return chromaprint_feed(cpr->ctx, (const uint16_t *)pkt->data, pkt->size / 2) ? 0 : AVERROR(EINVAL);
 }
 
 static int write_trailer(AVFormatContext *s)
 {
 ChromaprintMuxContext *cpr = s->priv_data;
 AVIOContext *pb = s->pb;
-void *fp = NULL, *enc_fp = NULL;
+void *fp = NULL;
+char *enc_fp = NULL;
 int size, enc_size, ret = AVERROR(EINVAL);
 
 if (!chromaprint_finish(cpr->ctx)) {
@@ -129,7 +130,7 @@ static int write_trailer(AVFormatContext *s)
 goto fail;
 }
 
-if (!chromaprint_get_raw_fingerprint(cpr->ctx, , )) {
+if (!chromaprint_get_raw_fingerprint(cpr->ctx, (uint32_t **), )) {
 av_log(s, AV_LOG_ERROR, "Failed to retrieve fingerprint\n");
 goto fail;
 }
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH V1] lavf/mov: fix fMP4 tfdt box lead to dts reset issue

2019-08-13 Thread Jun Zhao
From: Jun Zhao 

In fMP4 format, traf maybe have zero or more trun box, in this case,
we just used tfdt as dts once. The sample layout like this:

[moof] size=8+1392
  [mfhd] size=12+4
sequence number = 29
  [traf] size=8+1368
[tfhd] size=12+16, flags=20038
  track ID = 1
  default sample duration = 512
  default sample size = 40720
  default sample flags = 0
[tfdt] size=12+8, version=1
  base media decode time = 1873920
[trun] size=12+452, version=1, flags=e01
  sample count = 37
  data offset = 1408
[trun] size=12+452, version=1, flags=e01
  sample count = 37
  data offset = 292973
[trun] size=12+380, version=1, flags=e01
  sample count = 31
  data offset = 586457

Signed-off-by: Jun Zhao 
---
 libavformat/mov.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 24de542..d47d491 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4762,6 +4762,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 dts = frag_stream_info->tfdt_dts - sc->time_offset;
 av_log(c->fc, AV_LOG_DEBUG, "found tfdt time %"PRId64
 ", using it for dts\n", dts);
+frag_stream_info->tfdt_dts = AV_NOPTS_VALUE;
 } else {
 dts = sc->track_end - sc->time_offset;
 av_log(c->fc, AV_LOG_DEBUG, "found track end time %"PRId64
-- 
1.7.1

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avutil: Add Simple loop detector

2019-08-13 Thread Lynne
Aug 12, 2019, 20:53 by mich...@niedermayer.cc:

> On Sun, Aug 11, 2019 at 08:30:51PM +0200, Reimar Döffinger wrote:
>
>> On 08.08.2019, at 10:36, Michael Niedermayer  wrote:
>>
>> > This provides an alternative to retry counters.
>> > Useful if there is no reasonable maximum number of iterations and
>> > no ordering that naturally avoids loops.
>>
>> Going by the old principle of "an API is not tested until it has at least 3 
>> users"
>> might it make sense to delay this until we've found and tested it in a few 
>> use-cases?
>> Depending on how much hurry there is to get the bug-fix in.
>>
>> I assume there is also an actual bug-fix patch somewhere, maybe we should 
>> have that
>> in the same patch series to make it easier to review the actual usage?
>>
>
> sure will repost this eventually with 3+ bugfixes.
> But wont search for such bugs ATM as ive too many other things to do
> so it might take a bit of time before i do
>
>
>>
>> > diff --git a/doc/APIchanges b/doc/APIchanges
>> > index 6603a8229e..eee4c30ec5 100644
>> > --- a/doc/APIchanges
>> > +++ b/doc/APIchanges
>> > @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>> > 
>> > API changes, most recent first:
>> > 
>> > +2019-XX-XX - XX - lavu 56.XX.XXX - loop_detector.h
>> > +  Add loop_detector.h, av_is_loop(), AVSimpleLoopDetector
>>
>> Does is mean it is a public/installed header?
>>
>
> that was intended, but it can of course be trivially be kept local if people
> prefer when i repost with 3+ dependant fixes 
>

You are ignoring 2 developers, and this isn't the first time you're doing this, 
nor even the second.
I still do no think even with 3 bugfixes this deserves to be in lavu but rather 
in every library as a non-installed header, at the very most. I still prefer 
for code to be duplicated for such a small amount of fixes.
Iit could encourage other developers to put this in their code when it isn't 
needed when a properly written loop would never go infinite.
And, regardless where this code goes, its still as its been pointed out, a hack.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 08/13] avformat/avformat.h: Correct some comments

2019-08-13 Thread Carl Eugen Hoyos
Am Di., 13. Aug. 2019 um 04:49 Uhr schrieb Andreas Rheinhardt
:
>
> 1. When set_parameters was removed from AVOutputFormat in 2fb75019, it
> was forgotten to remove the comment pertaining to it. Said comment now
> appeared to apply to interleave_packet; it is of course nonsense and has
> been replaced by an accurate description.
> 2. The description of av_write_uncoded_frame suggested
> av_interleaved_write_frame as a replacement if the input is not
> already correctly interleaved; it also referred to said function for
> details. Given that said function can't write AVFrames and that the
> stuff specific to writing uncoded frames is explained in the description
> of av_interleaved_write_uncoded_frame, both references have been fixed.
> 3. Removed an outdated comment about avformat_seek_file.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/avformat.h | 9 -
>  libavformat/version.h  | 2 +-
>  2 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 6eb329f13f..92c3a89f4b 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -556,7 +556,8 @@ typedef struct AVOutputFormat {
>  int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
>  int (*write_trailer)(struct AVFormatContext *);
>  /**
> - * Currently only used to set pixel format if not YUV420P.
> + * A format-specific function for interleavement.
> + * If unset, packets will be interleaved by dts.
>   */
>  int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
>   AVPacket *in, int flush);
> @@ -2449,8 +2450,6 @@ int av_seek_frame(AVFormatContext *s, int stream_index, 
> int64_t timestamp,
>   * @return >=0 on success, error code otherwise
>   *
>   * @note This is part of the new seek API which is still under construction.
> - *   Thus do not use this yet. It may change at any time, do not expect
> - *   ABI compatibility yet!
>   */
>  int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, 
> int64_t ts, int64_t max_ts, int flags);
>
> @@ -2637,9 +2636,9 @@ int av_interleaved_write_frame(AVFormatContext *s, 
> AVPacket *pkt);
>   * Write an uncoded frame to an output media file.
>   *
>   * The frame must be correctly interleaved according to the container
> - * specification; if not, then av_interleaved_write_frame() must be used.
> + * specification; if not, av_interleaved_write_uncoded_frame() must be used.
>   *
> - * See av_interleaved_write_frame() for details.
> + * See av_interleaved_write_uncoded_frame() for details.
>   */
>  int av_write_uncoded_frame(AVFormatContext *s, int stream_index,
> AVFrame *frame);
> diff --git a/libavformat/version.h b/libavformat/version.h
> index 45efaff9b9..feceaedc08 100644
> --- a/libavformat/version.h
> +++ b/libavformat/version.h
> @@ -32,7 +32,7 @@
>  // Major bumping may affect Ticket5467, 5421, 5451(compatibility with 
> Chromium)
>  // Also please add any ticket numbers that you believe might be affected here
>  #define LIBAVFORMAT_VERSION_MAJOR  58

> -#define LIBAVFORMAT_VERSION_MINOR  30
> +#define LIBAVFORMAT_VERSION_MINOR  31

Seems unneeded to me.

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

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

Re: [FFmpeg-devel] [PATCH] libavfilter/vf_scale: Ensure scaled video is divisible by n

2019-08-13 Thread Michael Niedermayer
On Mon, Aug 12, 2019 at 03:58:14PM +0200, Lars Kiesow wrote:
> This patch adds a new option to the scale filter which ensures that the
> output resolution is divisible by the given integer when used together
> with `force_original_aspect_ratio`. This works similar to using `-n` in
> the `w` and `h` options.
> 
> This option respects the value set for `force_original_aspect_ratio`,
> increasing or decreasing the resolution accordingly.
> 
> The use case for this is to set a fixed target resolution using `w` and
> `h`, to use the `force_original_aspect_ratio` option to make sure that
> the video always fits in the defined bounding box regardless of aspect
> ratio, but to also make sure that the calculated output resolution is
> divisible by n so in can be encoded with certain encoders/options if
> that is required.
> 
> Signed-off-by: Lars Kiesow 
> ---
>  doc/filters.texi   | 12 
>  libavfilter/vf_scale.c | 15 ++-
>  2 files changed, 26 insertions(+), 1 deletion(-)

will apply

thx

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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

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

Re: [FFmpeg-devel] avformat/flvdec: delete unused code

2019-08-13 Thread Carl Eugen Hoyos
Am Di., 13. Aug. 2019 um 09:06 Uhr schrieb leozhang :
>
> Signed-off-by: leozhang 
> ---
>  libavformat/flvdec.c | 16 
>  1 file changed, 16 deletions(-)
>
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index b531a39..4e8faed 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -1265,22 +1265,6 @@ retry_duration:
>  if (st->codecpar->codec_id == AV_CODEC_ID_AAC && t && 
> !strcmp(t->value, "Omnia A/XE"))
>  st->codecpar->extradata_size = 2;
>
> -if (st->codecpar->codec_id == AV_CODEC_ID_AAC && 0) {
> -MPEG4AudioConfig cfg;
> -
> -if (avpriv_mpeg4audio_get_config(, 
> st->codecpar->extradata,
> - 
> st->codecpar->extradata_size * 8, 1) >= 0) {
> -st->codecpar->channels   = cfg.channels;
> -st->codecpar->channel_layout = 0;
> -if (cfg.ext_sample_rate)
> -st->codecpar->sample_rate = cfg.ext_sample_rate;
> -else
> -st->codecpar->sample_rate = cfg.sample_rate;
> -av_log(s, AV_LOG_TRACE, "mp4a config channels %d sample rate 
> %d\n",
> -st->codecpar->channels, st->codecpar->sample_rate);
> -}
> -}
> -
>  ret = FFERROR_REDO;
>  goto leave;
>  }

You forgot to remove '#include "libavcodec/mpeg4audio.h"'.

In case anybody is interested, here is the original thread:
https://ffmpeg.org/pipermail/ffmpeg-devel/2009-February/065799.html

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

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

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/vp56: Consider the alpha start as end of the prior header

2019-08-13 Thread Michael Niedermayer
On Mon, Aug 12, 2019 at 09:03:41PM +1000, Peter Ross wrote:
> On Sun, Aug 11, 2019 at 05:02:47PM +0200, Michael Niedermayer wrote:
> > On Sun, Aug 11, 2019 at 09:29:14AM +1000, Peter Ross wrote:
> > > On Tue, Aug 06, 2019 at 11:30:02PM +0200, Michael Niedermayer wrote:
> > > > Fixes: Timeout (23sec -> 71ms)
> > > > Fixes: 
> > > > 15661/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP6A_fuzzer-6257865947348992
> > > > 
> > > > Found-by: continuous fuzzing process 
> > > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > > Signed-off-by: Michael Niedermayer 
> > > > ---
> > > >  libavcodec/vp56.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c
> > > > index 72fea3780e..695f37e972 100644
> > > > --- a/libavcodec/vp56.c
> > > > +++ b/libavcodec/vp56.c
> > > > @@ -572,7 +572,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, 
> > > > void *data, int *got_frame,
> > > >  VP56Context *s = avctx->priv_data;
> > > >  AVFrame *const p = s->frames[VP56_FRAME_CURRENT];
> > > >  int remaining_buf_size = avpkt->size;
> > > > -int av_uninit(alpha_offset);
> > > > +int alpha_offset = remaining_buf_size;
> > > >  int i, res;
> > > >  int ret;
> > > >  
> > > > @@ -585,7 +585,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, 
> > > > void *data, int *got_frame,
> > > >  return AVERROR_INVALIDDATA;
> > > >  }
> > > >  
> > > > -res = s->parse_header(s, buf, remaining_buf_size);
> > > > +res = s->parse_header(s, buf, alpha_offset);
> > > >  if (res < 0)
> > > >  return res;
> > > >  
> > > 
> > > hi michael, i am strugling to see a problem with the existing logic.
> > > 
> > > if (s->has_alpha) {
> > > if (remaining_buf_size < 3)
> > > return AVERROR_INVALIDDATA;
> > > alpha_offset = bytestream_get_be24();
> > > remaining_buf_size -= 3;
> > > if (remaining_buf_size < alpha_offset)
> > > return AVERROR_INVALIDDATA;
> > > }
> > > 
> > > res = s->parse_header(s, buf, remaining_buf_size);
> > > if (res < 0)
> > > return res;
> > > 
> > > 
> > > if the sample has alpha, remaining_buf_size is reduced in size.
> > 
> > > can you post the sanple that takes 23s to decode?
> > 
> > ill send the sample to you privatly
> 
> thanks, was able to reproduce. disregard my comment above regarding 
> remaining_buf_size.
> 
> approve.

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.


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

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

Re: [FFmpeg-devel] [PATCH v4] avutil/mips: refine msa macros CLIP_*.

2019-08-13 Thread Michael Niedermayer
On Mon, Aug 12, 2019 at 01:23:09PM +0800, Shiyou Yin wrote:
> >-Original Message-
> >From: ffmpeg-devel-boun...@ffmpeg.org 
> >[mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> >Michael Niedermayer
> >Sent: Friday, August 9, 2019 12:07 AM
> >To: FFmpeg development discussions and patches
> >Subject: Re: [FFmpeg-devel] [PATCH v4] avutil/mips: refine msa macros CLIP_*.
> >
> >On Thu, Aug 08, 2019 at 09:49:35AM +0800, 顾希伟 wrote:
> >> > 发件人: "Michael Niedermayer" 
> >> > 发送时间: 2019-08-08 07:05:13 (星期四)
> >> > 收件人: "FFmpeg development discussions and patches"
> >> > 
> >> > 抄送:
> >> > 主题: Re: [FFmpeg-devel] [PATCH v4] avutil/mips: refine msa macros CLIP_*.
> >> >
> >> > On Wed, Aug 07, 2019 at 05:52:00PM +0800, gxw wrote:
> >> > > Changing details as following:
> >> > > 1. Remove the local variable 'out_m' in 'CLIP_SH' and store the result 
> >> > > in
> >> > >source vector.
> >> > > 2. Refine the implementation of macro 'CLIP_SH_0_255' and 
> >> > > 'CLIP_SW_0_255'.
> >> > >Performance of VP8 decoding has speed up about 1.1%(from 7.03x to 
> >> > > 7.11x).
> >> > >Performance of H264 decoding has speed up about 0.5%(from 4.35x to 
> >> > > 4.37x).
> >> > >Performance of Theora decoding has speed up about 0.7%(from 5.79x 
> >> > > to 5.83x).
> >> > > 3. Remove redundant macro 'CLIP_SH/Wn_0_255_MAX_SATU' and use 
> >> > > 'CLIP_SH/Wn_0_255'
> >> > >instead, because there are no difference in the effect of this two 
> >> > > macros.
> >> >
> >> > can these 3 things be split into 3 patches ?
> >> > It would be clearer if each change would be in its own patch
> >> >
> >> > thanks
> >> >
> >> > [...]
> >>
> >> It can be split into 3 patches. But there some benefits as 1 patch, these 
> >> macros belong to the same
> >>class and are highly relevant. It is more intuitive to put them in a patch.
> >
> >hmm
> >does anyone else has any oppinion about this ?
> >
> >if not ill apply it
> >
> 
> In fact, change 2 and 3 is related closely. it's using a new macro to replace 
> 'CLIP_SH/Wn_0_255' and
>  'CLIP_SH/Wn_0_255_MAX_SATU'. So, It's better to put 2&3 in one patch. 
> Change 1 belongs to the same macro type of change 2&3. Putting it together is 
> mainly because of there are
> too many macros are pending refactor, It's a balance between patch complexity 
> and patch number.
> So it's acceptable to me. 

ok, will apply

thx

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

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



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

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

Re: [FFmpeg-devel] [PATCH 5/6] avcodec/4xm: Check for end of input in decode_p_block()

2019-08-13 Thread Michael Niedermayer
On Mon, Aug 12, 2019 at 11:53:20AM +0200, Paul B Mahol wrote:
> LGTM

will apply

thanks

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

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


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

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

[FFmpeg-devel] [PATCH, RFC, v2 3/3] lavc/libvpxenc: add dynamic resolution encode support for libvpx

2019-08-13 Thread Linjie Fu
According to spec, libvpx should support dynamic resolution changes.

Add dynamic resolution encoding support in libvpx.

Only single pass mode with no look ahead is supported for variable
resolution encoding without initialization.

cmdline:
ffmpeg -noautoscale -y -i ./reinit-large_420_8-to-small_420_8.h264
 -pix_fmt yuv420p -c:v libvpx-vp9 lena.ivf

Filed an issue in https://bugs.chromium.org/p/webm/issues/detail?id=1642
to fix some memory problem.

Signed-off-by: Linjie Fu 
---
 libavcodec/libvpxenc.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index feb52ea..3d2295d 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1067,6 +1067,28 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 int res, coded_size;
 vpx_enc_frame_flags_t flags = 0;
 
+if (frame && (avctx->width != frame->width ||
+  avctx->height != frame->height)) {
+avctx->width  = frame->width;
+avctx->height = frame->height;
+
+struct vpx_codec_enc_cfg new_cfg = { 0 };
+memcpy(_cfg, ctx->encoder.config.enc,
+sizeof(struct vpx_codec_enc_cfg));
+
+new_cfg.g_w = frame->width;
+new_cfg.g_h = frame->height;
+if (new_cfg.g_lag_in_frames > 1 ||
+new_cfg.g_pass != VPX_RC_ONE_PASS) {
+av_log(avctx, AV_LOG_WARNING, "Only single pass mode "
+   "with no look ahead is supported for variable "
+   "resolution encoding without initialization.\n");
+new_cfg.g_pass  = VPX_RC_ONE_PASS;
+new_cfg.g_lag_in_frames = 0;
+}
+vpx_codec_enc_config_set(>encoder, _cfg);
+}
+
 if (frame) {
 rawimg  = >rawimg;
 rawimg->planes[VPX_PLANE_Y] = frame->data[0];
@@ -1075,6 +1097,8 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 rawimg->stride[VPX_PLANE_Y] = frame->linesize[0];
 rawimg->stride[VPX_PLANE_U] = frame->linesize[1];
 rawimg->stride[VPX_PLANE_V] = frame->linesize[2];
+rawimg->d_w = frame->width;
+rawimg->d_h = frame->height;
 if (ctx->is_alpha) {
 uint8_t *u_plane, *v_plane;
 rawimg_alpha = >rawimg_alpha;
-- 
2.7.4

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

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

Re: [FFmpeg-devel] [PATCH 2/6] avcodec/hevcdec: Check delta_luma_weight_l0/1

2019-08-13 Thread Michael Niedermayer
On Sun, Aug 11, 2019 at 11:07:24PM -0300, James Almer wrote:
> On 8/11/2019 9:17 PM, Michael Niedermayer wrote:
> > Fixes: signed integer overflow: 1 + 2147483647 cannot be represented in 
> > type 'int'
> > Fixes: 
> > 16041/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5685680656613376
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/hevcdec.c | 4 
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> > index f1934975d5..eed031913a 100644
> > --- a/libavcodec/hevcdec.c
> > +++ b/libavcodec/hevcdec.c
> > @@ -182,6 +182,8 @@ static int pred_weight_table(HEVCContext *s, 
> > GetBitContext *gb)
> >  for (i = 0; i < s->sh.nb_refs[L0]; i++) {
> >  if (luma_weight_l0_flag[i]) {
> >  int delta_luma_weight_l0 = get_se_golomb(gb);
> > +if ((int8_t)delta_luma_weight_l0 != delta_luma_weight_l0)
> > +return AVERROR_INVALIDDATA;
> >  s->sh.luma_weight_l0[i] = (1 << s->sh.luma_log2_weight_denom) 
> > + delta_luma_weight_l0;
> >  s->sh.luma_offset_l0[i] = get_se_golomb(gb);
> >  }
> > @@ -224,6 +226,8 @@ static int pred_weight_table(HEVCContext *s, 
> > GetBitContext *gb)
> >  for (i = 0; i < s->sh.nb_refs[L1]; i++) {
> >  if (luma_weight_l1_flag[i]) {
> >  int delta_luma_weight_l1 = get_se_golomb(gb);
> > +if ((int8_t)delta_luma_weight_l1 != delta_luma_weight_l1)
> > +return AVERROR_INVALIDDATA;
> >  s->sh.luma_weight_l1[i] = (1 << 
> > s->sh.luma_log2_weight_denom) + delta_luma_weight_l1;
> >  s->sh.luma_offset_l1[i] = get_se_golomb(gb);
> >  }
> > 
> 
> LGTM.

will apply

thx

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

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.


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

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

Re: [FFmpeg-devel] [PATCH 2/5] avcodec/vc1: Fix overflow in aspect ratio calculation

2019-08-13 Thread Jean-Baptiste Kempf
Are those values even acceptable according to spec?
Shouldn't 16k*16K be the maximum allowed?

On Fri, Aug 9, 2019, at 01:26, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 393215 * 14594 cannot be represented in 
> type 'int'
> Fixes: 
> 15728/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5661588893204480
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vc1.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
> index e102b931d8..0790eb160e 100644
> --- a/libavcodec/vc1.c
> +++ b/libavcodec/vc1.c
> @@ -453,8 +453,8 @@ static int decode_sequence_header_adv(VC1Context 
> *v, GetBitContext *gb)
>  } else {
>  av_reduce(>s.avctx->sample_aspect_ratio.num,
>>s.avctx->sample_aspect_ratio.den,
> -  v->s.avctx->height * w,
> -  v->s.avctx->width * h,
> +  v->s.avctx->height * (int64_t)w,
> +  v->s.avctx->width * (int64_t)h,
>1 << 30);
>  }
>  ff_set_sar(v->s.avctx, v->s.avctx->sample_aspect_ratio);
> -- 
> 2.22.0
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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

[FFmpeg-devel] [PATCH V2] avcodec/libvpxenc: add ROI-based encoding support for VP8/VP9 support

2019-08-13 Thread Guo, Yejun
example command line to verify it:
./ffmpeg -i input.stream -vf addroi=0:0:iw/3:ih/3:-0.8 -c:v libvpx -b:v 2M 
tmp.webm

Signed-off-by: Guo, Yejun 
---
 configure  |   7 ++
 libavcodec/libvpxenc.c | 197 +
 2 files changed, 204 insertions(+)

diff --git a/configure b/configure
index 3fb8f35..e549e26 100755
--- a/configure
+++ b/configure
@@ -6300,6 +6300,13 @@ enabled libvpx&& {
 check_pkg_config libvpx_vp9_encoder "vpx >= 1.4.0" "vpx/vpx_encoder.h 
vpx/vp8cx.h" vpx_codec_vp9_cx ||
 check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" 
"vpx_codec_vp9_cx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs 
$pthreads_extralibs"
 }
+enabled libvpx_vp9_encoder && {
+test_cc <
+void foo(void){ int i = VP9E_SET_ROI_MAP; }
+EOF
+}
+
 if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder 
libvpx_vp9_encoder; then
 die "libvpx enabled but no supported decoders found"
 fi
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 1a85bc6..475c139 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -116,6 +116,9 @@ typedef struct VPxEncoderContext {
 int tune_content;
 int corpus_complexity;
 int tpl_model;
+// If the driver does not support ROI then warn the first time we
+// encounter a frame with ROI side data.
+int roi_warned;
 } VPxContext;
 
 /** String mappings for enum vp8e_enc_control_id */
@@ -1057,6 +1060,192 @@ static int queue_frames(AVCodecContext *avctx, AVPacket 
*pkt_out)
 return size;
 }
 
+static int set_roi_map(AVCodecContext *avctx, const AVFrameSideData *sd, int 
frame_width, int frame_height,
+   vpx_roi_map_t *roi_map, int block_size, int segment_cnt)
+{
+/* range of vpx_roi_map_t.delta_q[i] is [-63, 63] */
+#define MAX_DELTA_Q 63
+
+const AVRegionOfInterest *roi = NULL;
+int nb_rois;
+uint32_t self_size;
+int segment_id;
+
+/* record the mapping from delta_q to "segment id + 1" in 
segment_mapping[].
+ * the range of delta_q is [-MAX_DELTA_Q, MAX_DELTA_Q],
+ * and its corresponding array index is [0, 2 * MAX_DELTA_Q],
+ * and so the length of the mapping array is 2 * MAX_DELTA_Q + 1.
+ * "segment id + 1", so we can say there's no mapping if the value of 
array element is zero.
+ */
+int segment_mapping[2 * MAX_DELTA_Q + 1] = { 0 };
+
+memset(roi_map, 0, sizeof(*roi_map));
+
+/* segment id 0 in roi_map is reserved for the areas not covered by 
AVRegionOfInterest.
+ * segment id 0 in roi_map is also for the areas with 
AVRegionOfInterest.qoffset near 0.
+ * (delta_q of segment id 0 is 0).
+ */
+segment_mapping[MAX_DELTA_Q] = 1;
+/* roi_map has memset with zero, just explictly set it again for explict 
understanding. */
+roi_map->delta_q[0] = 0;
+segment_id = 1;
+
+roi = (const AVRegionOfInterest*)sd->data;
+self_size = roi->self_size;
+if (!self_size || sd->size % self_size != 0) {
+av_log(avctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n");
+return AVERROR(EINVAL);
+}
+nb_rois = sd->size / self_size;
+
+/* This list must be iterated from zero because regions are
+ * defined in order of decreasing importance. So discard less
+ * important areas if they exceed the segment count.
+ */
+for (int i = 0; i < nb_rois; i++) {
+int delta_q;
+int mapping_index;
+
+roi = (const AVRegionOfInterest*)(sd->data + self_size * i);
+if (roi->qoffset.den == 0) {
+av_log(avctx, AV_LOG_ERROR, "AVRegionOfInterest.qoffset.den must 
not be zero.\n");
+return AVERROR(EINVAL);
+}
+
+delta_q = (int)(roi->qoffset.num * 1.0f / roi->qoffset.den * 
MAX_DELTA_Q);
+delta_q = av_clip(delta_q, -MAX_DELTA_Q, MAX_DELTA_Q);
+
+mapping_index = delta_q + MAX_DELTA_Q;
+if (!segment_mapping[mapping_index]) {
+if (segment_id == segment_cnt) {
+av_log(avctx, AV_LOG_WARNING,
+   "ROI only supports %d segments (and segment 0 is 
reserved for non-ROIs), skipping the left ones.\n",
+   segment_cnt);
+break;
+}
+
+segment_mapping[mapping_index] = segment_id + 1;
+roi_map->delta_q[segment_id] = delta_q;
+segment_id++;
+}
+}
+
+
+roi_map->rows = (frame_height + block_size - 1) / block_size;
+roi_map->cols = (frame_width  + block_size - 1) / block_size;
+roi_map->roi_map = av_mallocz_array(roi_map->rows * roi_map->cols, 
sizeof(*roi_map->roi_map));
+if (!roi_map->roi_map) {
+av_log(avctx, AV_LOG_ERROR, "roi_map alloc failed.\n");
+return AVERROR(ENOMEM);
+}
+
+/* This list must be iterated in reverse, so for the case that
+ * two regions overlapping, the more important area takes effect.
+ */

Re: [FFmpeg-devel] [REQUEST] ffmpeg-security subscription

2019-08-13 Thread Paul B Mahol
On Mon, Aug 12, 2019 at 6:15 PM Michael Niedermayer 
wrote:

> Hi Paul
>
> On Mon, Aug 05, 2019 at 11:50:04AM +0200, Paul B Mahol wrote:
> > Hi,
> >
> > I here hereby request from lead FFmpeg entity to give me subscription to
> > ffmpeg-security mailing list.
>
> I am not sure who or what a "lead FFmpeg entity" is, But as iam being
> highlighted
> on IRC by you in relation to this, and as iam the most active developer on
> security issues in ffmpeg it would be inpolite from me if i didnt say
> something.
>

You are the only one working on this.


>
> About ffmpeg-security,
> Theres currently no need for more manpower to handle security issues. We
> have
> a backlog of a few days of fuzzing issues only which is shrinking. And no
> other
> issues besides fuzzing issues. (part of the backlog probably was the
> result
> of distractions and some longer review cycles on some patches recently)
> Also all patches are being posted in public so no access is needed for
> reviews.
>

I strongly disagree. And I haven't asked if you need help.


>
> I think many of the complaints from people about some of the patches
> should be
> resolved by the recent addition of thresholds on all pixels decoded. That
> way
> slow video decoders can have their timeout thresholds effectively tuned and
> would no longer require ugly changes which several people did not like.
> That wont eliminate all uglyness but it should reduce it.
>
> PS: also keep in mind that we recently increased coverage of the fuzzers
> this created a spike of new issues, so besides more such spikes from more
> coverage increases the amount of new issues is expected to decrease over
> time
>
> Thanks
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] avcodec/videotoolboxenc: fix encoding frame crash on iOS 11

2019-08-13 Thread sharpbai
On iOS 11, encoding a frame may return error with log
"Error encoding frame 0", which means vtenc_output_callback
is called with status=0 and sample_buffer=NULL. Then the
encoding session will be crashed on next callback wether or not
closing the codec context.

Let us look through the link below introducing VTCompressionOutputCallback,

https://developer.apple.com/documentation/videotoolbox/vtcompressionoutputcallback?language=objc

"status=0" (noErr) means compression was successful.
"sampleBuffer=NULL" means the frame was dropped when compression
was successful (status=0) or compression was not successful (status!=0).

So we should not set AVERROR_EXTERNAL on "status=0" and "sample_buffer=NULL"
as it is not a error.

The fix is that we only set AVERROR_EXTERNAL with status value non zero.
When sample_buffer is NULL and status value is zero, we simply return
with no other operation.

This crash often occurs on iOS 11 for example encoding 720p@25fps.

Signed-off-by: sharpbai 
---
 libavcodec/videotoolboxenc.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index d76bb7f646..8afdd125d2 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -569,12 +569,16 @@ static void vtenc_output_callback(
 return;
 }
 
-if (status || !sample_buffer) {
+if (status) {
 av_log(avctx, AV_LOG_ERROR, "Error encoding frame: %d\n", (int)status);
 set_async_error(vtctx, AVERROR_EXTERNAL);
 return;
 }
 
+if (!sample_buffer) {
+return;
+}
+
 if (!avctx->extradata && (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {
 int set_status = set_extradata(avctx, sample_buffer);
 if (set_status) {
-- 
2.21.0

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

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

[FFmpeg-devel] avcodec/videotoolboxenc: fix encoding frame crash on iOS 11

2019-08-13 Thread sharpbai
On iOS 11, encoding a frame may return error with log
"Error encoding frame 0", which means vtenc_output_callback
is called with status=0 and sample_buffer=NULL. Then the
encoding session will be crashed on next callback wether or not
closing the codec context.

Let us look through the link below introducing VTCompressionOutputCallback,

https://developer.apple.com/documentation/videotoolbox/vtcompressionoutputcallback?language=objc

"status=0" (noErr) means compression was successful.
"sampleBuffer=NULL" means the frame was dropped when compression
was successful (status=0) or compression was not successful (status!=0).

So we should not set AVERROR_EXTERNAL on "status=0" and "sample_buffer=NULL"
as it is not a error.

The fix is that we only set AVERROR_EXTERNAL with status value non zero.
When sample_buffer is NULL and status value is zero, we simply return
with no other operation.

This crash often occurs on iOS 11 for example encoding 720p@25fps.

Signed-off-by: sharpbai 
---
 libavcodec/videotoolboxenc.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index d76bb7f646..8afdd125d2 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -569,12 +569,16 @@ static void vtenc_output_callback(
 return;
 }
 
-if (status || !sample_buffer) {
+if (status) {
 av_log(avctx, AV_LOG_ERROR, "Error encoding frame: %d\n", (int)status);
 set_async_error(vtctx, AVERROR_EXTERNAL);
 return;
 }
 
+if (!sample_buffer) {
+return;
+}
+
 if (!avctx->extradata && (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {
 int set_status = set_extradata(avctx, sample_buffer);
 if (set_status) {
-- 
2.21.0

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

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

Re: [FFmpeg-devel] [PATCH] hevc_mp4toannexb: Do not duplicate parameter sets

2019-08-13 Thread Andreas Rheinhardt
Andriy Gelman:
> Andreas,
> 
> On Sun, 21. Jul 10:47, Andreas Rheinhardt wrote:
>> Andriy Gelman:
>>> From: Andriy Gelman 
>>>
>>> Fixes #7799
>>>
>>> Currently, the mp4toannexb filter always inserts extradata at the start
>>> of each IRAP unit. This can lead to duplication of parameter sets if the
>>> demuxed packet from mdat atom already contains a version of the
>>> parameters.
>>>
>>> As in ticket #7799 this can also lead to decoding errors when the
>>> parameter sets of the IRAP frames are different from the ones stored in
>>> extradata.
>>>
>>> This commit avoids duplicating the parameter sets if they are already
>>> present in the demuxed packet.
>>>
>>> This commit also makes an update to the hevc-bsf-mp4toannexb fate
>>> test since the result before this patch contained duplicate vps/sps/pps
>>> nal units.
>>> ---
>>>  libavcodec/hevc_mp4toannexb_bsf.c | 9 -
>>>  tests/fate/hevc.mak   | 2 +-
>>>  2 files changed, 9 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavcodec/hevc_mp4toannexb_bsf.c 
>>> b/libavcodec/hevc_mp4toannexb_bsf.c
>>> index 09bce5b34c..5c27306b09 100644
>>> --- a/libavcodec/hevc_mp4toannexb_bsf.c
>>> +++ b/libavcodec/hevc_mp4toannexb_bsf.c
>>> @@ -123,6 +123,7 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, 
>>> AVPacket *out)
>>>  
>>>  int got_irap = 0;
>>>  int i, ret = 0;
>>> +int vps_detected, sps_detected, pps_detected = 0;
>>>  
>> You are only initiallizing pps_detected.
>>
>>>  ret = ff_bsf_get_packet(ctx, );
>>>  if (ret < 0)
>>> @@ -146,9 +147,15 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, 
>>> AVPacket *out)
>>>  
>>>  nalu_type = (bytestream2_peek_byte() >> 1) & 0x3f;
>>>  
>>> +switch (nalu_type) {
>>> +  case HEVC_NAL_VPS: vps_detected = 1; break;
>>> +  case HEVC_NAL_SPS: sps_detected = 1; break;
>>> +  case HEVC_NAL_PPS: pps_detected = 1; break;
>>> +}
>>> +
>>>  /* prepend extradata to IRAP frames */
>>>  is_irap   = nalu_type >= 16 && nalu_type <= 23;
>>> -add_extradata = is_irap && !got_irap;
>>> +add_extradata = is_irap && !got_irap && !(vps_detected && 
>>> sps_detected && pps_detected);
>>>  extra_size= add_extradata * ctx->par_out->extradata_size;
>>>  got_irap |= is_irap;
>>>  
>> There are two things that I don't like about this approach:
>> 1. Image an input file like this: VPS, SPS and PPS in extradata and
>> then after a few GOPs there is an inband PPS as part of a VPS, SPS and
>> PPS combination where the PPS differs from the PPS in the extradata.
>> After this change in parameter sets there are no further inband
>> parameter sets. With your proposal, the extradata would again be
>> inserted into access units with IRAP frames after the change in
>> extradata and it would be the old, outdated extradata, thereby
>> breaking decoding (the original mp4 file would probably not be able
>> fully seekable in this case, but that would be another story).
>> 2. If the sample in #7799 contained only the parameter set that
>> actually changed inband, your proposal would still add a whole
>> VPS+SPS+PPS combination and therefore still make the sample unplayable.
>>
> 
> Thanks for your feedback. 
> I believe I'm quite close to finishing the new patch. 
> 
> The general workflow in the updated mp4toannexb_filter function is: 
>   1. Convert input avcc packet to annexb.
>   2. Split the annexb bytestream into NAL units using ff_h2645_packet_splits 
> function
This function is quite slow (it checks the whole NAL unit for 0x03
escapes and if it finds any, it unescapes the whole NAL unit, i.e. it
copies the NAL unit with the 0x03 escapes removed). Do you limit
unescaping to the relevant NAL units only?
>   3. If VPS/SPS/PPS nal units are present, parse them to get their id and 
> reference to higher level parameter set.
>   4. New VPS/SPS/PPS parameter sets are compared their 'cached version'. The 
> cached versions are stored in a struct similar to HEVCParamSets. If the new 
> parameter set is
>   different, then update the cached version.
>   5. Update extradata if any of the cached parameter sets have changed.
If I am not mistaken, then you are not allowed to modify the extradata
after init. All you could do is send side data of
AV_PKT_DATA_NEW_EXTRADATA type. But it is probably enough to simply
add the new extradata in-band.

>   6. Insert new extradata at the first IRAP nal unit (i.e.
>   same as original code).
> 
> The only part that still remains to be done is dealing with SEI nals. What 
> I'm unsure about is whether SEIs from past extradata should be inserted at 
> the start of future IRAP frames. The current code seems to do this. 
> I think the consistent approach is to add SEI prefix/suffix into extradata. 
> But, also update SEI if new version are encountered in the bytestream.
New version means same payload type, but different payload? That's at
least the only generic way of 

[FFmpeg-devel] [PATCH 4/6] lavc/qsvdec: remove orignal parser code since not needed now

2019-08-13 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 configure   | 10 +-
 libavcodec/qsvdec.c | 28 +---
 libavcodec/qsvdec.h |  3 ---
 3 files changed, 6 insertions(+), 35 deletions(-)

diff --git a/configure b/configure
index 3fb8f35..ddaaf80 100755
--- a/configure
+++ b/configure
@@ -3018,7 +3018,7 @@ h264_mediacodec_decoder_select="h264_mp4toannexb_bsf 
h264_parser"
 h264_mmal_decoder_deps="mmal"
 h264_nvenc_encoder_deps="nvenc"
 h264_omx_encoder_deps="omx"
-h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec"
+h264_qsv_decoder_select="h264_mp4toannexb_bsf qsvdec"
 h264_qsv_encoder_select="qsvenc"
 h264_rkmpp_decoder_deps="rkmpp"
 h264_rkmpp_decoder_select="h264_mp4toannexb_bsf"
@@ -3032,7 +3032,7 @@ hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf"
 hevc_mediacodec_decoder_deps="mediacodec"
 hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser"
 hevc_nvenc_encoder_deps="nvenc"
-hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec"
+hevc_qsv_decoder_select="hevc_mp4toannexb_bsf qsvdec"
 hevc_qsv_encoder_select="hevcparse qsvenc"
 hevc_rkmpp_decoder_deps="rkmpp"
 hevc_rkmpp_decoder_select="hevc_mp4toannexb_bsf"
@@ -3052,7 +3052,7 @@ mpeg2_crystalhd_decoder_select="crystalhd"
 mpeg2_cuvid_decoder_deps="cuvid"
 mpeg2_mmal_decoder_deps="mmal"
 mpeg2_mediacodec_decoder_deps="mediacodec"
-mpeg2_qsv_decoder_select="qsvdec mpegvideo_parser"
+mpeg2_qsv_decoder_select="qsvdec"
 mpeg2_qsv_encoder_select="qsvenc"
 mpeg2_vaapi_encoder_select="cbs_mpeg2 vaapi_encode"
 mpeg2_v4l2m2m_decoder_deps="v4l2_m2m mpeg2_v4l2_m2m"
@@ -3069,11 +3069,11 @@ nvenc_hevc_encoder_select="hevc_nvenc_encoder"
 vc1_crystalhd_decoder_select="crystalhd"
 vc1_cuvid_decoder_deps="cuvid"
 vc1_mmal_decoder_deps="mmal"
-vc1_qsv_decoder_select="qsvdec vc1_parser"
+vc1_qsv_decoder_select="qsvdec"
 vc1_v4l2m2m_decoder_deps="v4l2_m2m vc1_v4l2_m2m"
 vp8_cuvid_decoder_deps="cuvid"
 vp8_mediacodec_decoder_deps="mediacodec"
-vp8_qsv_decoder_select="qsvdec vp8_parser"
+vp8_qsv_decoder_select="qsvdec"
 vp8_rkmpp_decoder_deps="rkmpp"
 vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8"
 vp8_vaapi_encoder_select="vaapi_encode"
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 7e48c83..eef4fe7 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -529,9 +529,6 @@ int ff_qsv_decode_close(QSVContext *q)
 av_fifo_free(q->async_fifo);
 q->async_fifo = NULL;
 
-av_parser_close(q->parser);
-avcodec_free_context(>avctx_internal);
-
 if (q->internal_session)
 MFXClose(q->internal_session);
 
@@ -544,36 +541,13 @@ int ff_qsv_decode_close(QSVContext *q)
 int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
 AVFrame *frame, int *got_frame, AVPacket *pkt)
 {
-uint8_t *dummy_data;
-int dummy_size;
 int ret;
 mfxVideoParam param = { 0 };
 enum AVPixelFormat pix_fmt = AV_PIX_FMT_NV12;
 
-if (!q->avctx_internal) {
-q->avctx_internal = avcodec_alloc_context3(NULL);
-if (!q->avctx_internal)
-return AVERROR(ENOMEM);
-
-q->avctx_internal->codec_id = avctx->codec_id;
-
-q->parser = av_parser_init(avctx->codec_id);
-if (!q->parser)
-return AVERROR(ENOMEM);
-
-q->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
-}
-
 if (!pkt->size)
 return qsv_decode(avctx, q, frame, got_frame, pkt);
 
-/* we assume the packets are already split properly and want
- * just the codec parameters here */
-av_parser_parse2(q->parser, q->avctx_internal,
- _data, _size,
- pkt->data, pkt->size, pkt->pts, pkt->dts,
- pkt->pos);
-
 /* TODO: flush delayed frames on reinit */
 
 // sw_pix_fmt, coded_width/height should be set for ff_get_format(),
@@ -622,7 +596,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext 
*q,
 return qsv_decode(avctx, q, frame, got_frame, pkt);
 
 reinit_fail:
-q->orig_pix_fmt = q->parser->format = avctx->pix_fmt = AV_PIX_FMT_NONE;
+q->orig_pix_fmt = avctx->pix_fmt = AV_PIX_FMT_NONE;
 return ret;
 }
 
diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
index 4812fb2..c057bc6 100644
--- a/libavcodec/qsvdec.h
+++ b/libavcodec/qsvdec.h
@@ -56,9 +56,6 @@ typedef struct QSVContext {
 int buffered_count;
 int reinit_flag;
 
-// the internal parser and codec context for parsing the data
-AVCodecParserContext *parser;
-AVCodecContext *avctx_internal;
 enum AVPixelFormat orig_pix_fmt;
 uint32_t fourcc;
 mfxFrameInfo frame_info;
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 5/6] lavc/qsvdec: Add mjpeg decoder support

2019-08-13 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 Changelog |  3 +++
 configure |  1 +
 libavcodec/Makefile   |  1 +
 libavcodec/allcodecs.c|  1 +
 libavcodec/qsvdec_other.c | 28 +++-
 5 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 389ca6c..e9a15d8 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,9 @@
 Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
+version :
+- Intel QSV-accelerated MJPEG decoding
+
 version 4.2:
 - tpad filter
 - AV1 decoding support through libdav1d
diff --git a/configure b/configure
index ddaaf80..cdc7cd5 100755
--- a/configure
+++ b/configure
@@ -3042,6 +3042,7 @@ hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
 hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"
 hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
 mjpeg_cuvid_decoder_deps="cuvid"
+mjpeg_qsv_decoder_select="qsvdec"
 mjpeg_qsv_encoder_deps="libmfx"
 mjpeg_qsv_encoder_select="qsvenc"
 mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fb..e491883 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -425,6 +425,7 @@ OBJS-$(CONFIG_METASOUND_DECODER)   += metasound.o 
metasound_data.o \
 OBJS-$(CONFIG_MICRODVD_DECODER)+= microdvddec.o ass.o
 OBJS-$(CONFIG_MIMIC_DECODER)   += mimic.o
 OBJS-$(CONFIG_MJPEG_DECODER)   += mjpegdec.o
+OBJS-$(CONFIG_MJPEG_QSV_DECODER)   += qsvdec_other.o
 OBJS-$(CONFIG_MJPEG_ENCODER)   += mjpegenc.o mjpegenc_common.o \
   mjpegenc_huffman.o
 OBJS-$(CONFIG_MJPEGB_DECODER)  += mjpegbdec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d2f9a39..cfc1d47 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -763,6 +763,7 @@ extern AVCodec ff_hevc_videotoolbox_encoder;
 extern AVCodec ff_libkvazaar_encoder;
 extern AVCodec ff_mjpeg_cuvid_decoder;
 extern AVCodec ff_mjpeg_qsv_encoder;
+extern AVCodec ff_mjpeg_qsv_decoder;
 extern AVCodec ff_mjpeg_vaapi_encoder;
 extern AVCodec ff_mpeg1_cuvid_decoder;
 extern AVCodec ff_mpeg2_cuvid_decoder;
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index a6f1b88..ca5b285 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -1,5 +1,5 @@
 /*
- * Intel MediaSDK QSV based MPEG-2, VC-1 and VP8 decoders
+ * Intel MediaSDK QSV based MPEG-2, VC-1, VP8 and MJPEG decoders
  *
  * copyright (c) 2015 Anton Khirnov
  *
@@ -256,3 +256,29 @@ AVCodec ff_vp8_qsv_decoder = {
 .wrapper_name   = "qsv",
 };
 #endif
+
+#if CONFIG_MJPEG_QSV_DECODER
+static const AVClass mjpeg_qsv_class = {
+.class_name = "mjpeg_qsv",
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_mjpeg_qsv_decoder = {
+.name   = "mjpeg_qsv",
+.long_name  = NULL_IF_CONFIG_SMALL("MJPEG video (Intel Quick Sync 
Video acceleration)"),
+.priv_data_size = sizeof(QSVOtherContext),
+.type   = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_MJPEG,
+.init   = qsv_decode_init,
+.decode = qsv_decode_frame,
+.flush  = qsv_decode_flush,
+.close  = qsv_decode_close,
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+.priv_class = _qsv_class,
+.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+AV_PIX_FMT_QSV,
+AV_PIX_FMT_NONE },
+};
+#endif
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 6/6] lavc/qsvdec: Add VP9 decoder support

2019-08-13 Thread Zhong Li
VP9 decoder is support on Intel kabyLake+ platforms with MSDK Version 1.19+

Signed-off-by: Zhong Li 
---
 Changelog |  1 +
 configure |  1 +
 libavcodec/allcodecs.c|  1 +
 libavcodec/qsv.c  |  5 +
 libavcodec/qsvdec_other.c | 46 +++---
 5 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index e9a15d8..c1f1237 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
 
 version :
 - Intel QSV-accelerated MJPEG decoding
+- Intel QSV-accelerated VP9 decoding
 
 version 4.2:
 - tpad filter
diff --git a/configure b/configure
index cdc7cd5..56f94ac 100755
--- a/configure
+++ b/configure
@@ -3082,6 +3082,7 @@ vp8_v4l2m2m_decoder_deps="v4l2_m2m vp8_v4l2_m2m"
 vp8_v4l2m2m_encoder_deps="v4l2_m2m vp8_v4l2_m2m"
 vp9_cuvid_decoder_deps="cuvid"
 vp9_mediacodec_decoder_deps="mediacodec"
+vp9_qsv_decoder_select="qsvdec"
 vp9_rkmpp_decoder_deps="rkmpp"
 vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9"
 vp9_vaapi_encoder_select="vaapi_encode"
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index cfc1d47..2298532 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -780,6 +780,7 @@ extern AVCodec ff_vp8_v4l2m2m_encoder;
 extern AVCodec ff_vp8_vaapi_encoder;
 extern AVCodec ff_vp9_cuvid_decoder;
 extern AVCodec ff_vp9_mediacodec_decoder;
+extern AVCodec ff_vp9_qsv_decoder;
 extern AVCodec ff_vp9_vaapi_encoder;
 
 // The iterate API is not usable with ossfuzz due to the excessive size of 
binaries created
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 533804a..65ad070 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -60,6 +60,11 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
 #endif
 case AV_CODEC_ID_MJPEG:
 return MFX_CODEC_JPEG;
+#if QSV_VERSION_ATLEAST(1, 19)
+case AV_CODEC_ID_VP9:
+return MFX_CODEC_VP9;
+#endif
+
 default:
 break;
 }
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index ca5b285..b044c11 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -1,5 +1,5 @@
 /*
- * Intel MediaSDK QSV based MPEG-2, VC-1, VP8 and MJPEG decoders
+ * Intel MediaSDK QSV based MPEG-2, VC-1, VP8, MJPEG and VP9 decoders
  *
  * copyright (c) 2015 Anton Khirnov
  *
@@ -60,8 +60,8 @@ static av_cold int qsv_decode_close(AVCodecContext *avctx)
 {
 QSVOtherContext *s = avctx->priv_data;
 
-#if CONFIG_VP8_QSV_DECODER
-if (avctx->codec_id == AV_CODEC_ID_VP8)
+#if CONFIG_VP8_QSV_DECODER || CONFIG_VP9_QSV_DECODER
+if (avctx->codec_id == AV_CODEC_ID_VP8 || avctx->codec_id == 
AV_CODEC_ID_VP9)
 av_freep(>qsv.load_plugins);
 #endif
 
@@ -90,6 +90,17 @@ static av_cold int qsv_decode_init(AVCodecContext *avctx)
 }
 #endif
 
+#if CONFIG_VP9_QSV_DECODER
+if (avctx->codec_id == AV_CODEC_ID_VP9) {
+static const char *uid_vp9dec_hw = "a922394d8d87452f878c51f2fc9b4131";
+
+av_freep(>qsv.load_plugins);
+s->qsv.load_plugins = av_strdup(uid_vp9dec_hw);
+if (!s->qsv.load_plugins)
+return AVERROR(ENOMEM);
+}
+#endif
+
 s->qsv.orig_pix_fmt = AV_PIX_FMT_NV12;
 s->packet_fifo = av_fifo_alloc(sizeof(AVPacket));
 if (!s->packet_fifo) {
@@ -282,3 +293,32 @@ AVCodec ff_mjpeg_qsv_decoder = {
 AV_PIX_FMT_NONE },
 };
 #endif
+
+#if CONFIG_VP9_QSV_DECODER
+static const AVClass vp9_qsv_class = {
+.class_name = "vp9_qsv",
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_vp9_qsv_decoder = {
+.name   = "vp9_qsv",
+.long_name  = NULL_IF_CONFIG_SMALL("VP9 video (Intel Quick Sync Video 
acceleration)"),
+.priv_data_size = sizeof(QSVOtherContext),
+.type   = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_VP9,
+.init   = qsv_decode_init,
+.decode = qsv_decode_frame,
+.flush  = qsv_decode_flush,
+.close  = qsv_decode_close,
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+.priv_class = _qsv_class,
+.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+AV_PIX_FMT_P010,
+AV_PIX_FMT_QSV,
+AV_PIX_FMT_NONE },
+.hw_configs = ff_qsv_hw_configs,
+.wrapper_name   = "qsv",
+};
+#endif
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 3/6] lavc/qsvdec: Replace current parser with MFXVideoDECODE_DecodeHeader()

2019-08-13 Thread Zhong Li
Using MSDK parser can improve qsv decoder pass rate in some cases (E.g:
sps declares a wrong level_idc, smaller than it should be).
And it is necessary for adding new qsv decoders such as MJPEG and VP9
since current parser can't provide enough information.
Actually using MFXVideoDECODE_DecodeHeader() was disscussed at
https://ffmpeg.org/pipermail/ffmpeg-devel/2015-July/175734.html and merged as 
commit 1acb19d,
but was overwritten when merged libav patches (commit: 1f26a23) without any 
explain.

Split decode header from decode_init, and call it for everyframe to
detect format/resoultion change. It can fix some regression issues such
as hevc 10bits decoding.

Signed-off-by: Zhong Li 
Signed-off-by: Dmitry Rogozhkin 
---
 libavcodec/qsvdec.c   | 184 --
 libavcodec/qsvdec.h   |   2 +
 libavcodec/qsvdec_h2645.c |   1 +
 libavcodec/qsvdec_other.c |   1 +
 4 files changed, 100 insertions(+), 88 deletions(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 46aa2d6..7e48c83 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -147,19 +147,21 @@ static int check_dec_param(AVCodecContext *avctx, 
QSVContext *q, mfxVideoParam *
 return 1;
 }
 
-static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
+static int qsv_decode_preinit(AVCodecContext *avctx, QSVContext *q, enum 
AVPixelFormat pix_fmt, mfxVideoParam *param)
 {
-const AVPixFmtDescriptor *desc;
 mfxSession session = NULL;
 int iopattern = 0;
-mfxVideoParam param = { 0 };
-int frame_width  = avctx->coded_width;
-int frame_height = avctx->coded_height;
 int ret;
+enum AVPixelFormat pix_fmts[3] = {
+AV_PIX_FMT_QSV, /* opaque format in case of video memory output */
+pix_fmt,/* system memory format obtained from bitstream parser 
*/
+AV_PIX_FMT_NONE };
 
-desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
-if (!desc)
-return AVERROR_BUG;
+ret = ff_get_format(avctx, pix_fmts);
+if (ret < 0) {
+q->orig_pix_fmt = avctx->pix_fmt = AV_PIX_FMT_NONE;
+return ret;
+}
 
 if (!q->async_fifo) {
 q->async_fifo = av_fifo_alloc(q->async_depth * qsv_fifo_item_size());
@@ -197,54 +199,72 @@ static int qsv_decode_init(AVCodecContext *avctx, 
QSVContext *q)
 return ret;
 }
 
-ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
-if (ret < 0)
-return ret;
+param->IOPattern   = q->iopattern;
+param->AsyncDepth  = q->async_depth;
+param->ExtParam= q->ext_buffers;
+param->NumExtParam = q->nb_ext_buffers;
 
-param.mfx.CodecId  = ret;
-param.mfx.CodecProfile = ff_qsv_profile_to_mfx(avctx->codec_id, 
avctx->profile);
-param.mfx.CodecLevel   = ff_qsv_level_to_mfx(avctx->codec_id, 
avctx->level);
-
-param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
-param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
-param.mfx.FrameInfo.Shift  = desc->comp[0].depth > 8;
-param.mfx.FrameInfo.FourCC = q->fourcc;
-param.mfx.FrameInfo.Width  = frame_width;
-param.mfx.FrameInfo.Height = frame_height;
-param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
-
-switch (avctx->field_order) {
-case AV_FIELD_PROGRESSIVE:
-param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
-break;
-case AV_FIELD_TT:
-param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
-break;
-case AV_FIELD_BB:
-param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_BFF;
-break;
-default:
-param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_UNKNOWN;
-break;
-}
+return 0;
+ }
 
-param.IOPattern   = q->iopattern;
-param.AsyncDepth  = q->async_depth;
-param.ExtParam= q->ext_buffers;
-param.NumExtParam = q->nb_ext_buffers;
+static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, mfxVideoParam 
*param)
+{
+int ret;
 
-if (!check_dec_param(avctx, q, )) {
-//Just give a warning instead of an error since it is still decodable 
possibly.
-av_log(avctx, AV_LOG_WARNING,
-   "Current input bitstream is not supported by QSV decoder.\n");
-}
+avctx->width= param->mfx.FrameInfo.CropW;
+avctx->height   = param->mfx.FrameInfo.CropH;
+avctx->coded_width  = param->mfx.FrameInfo.Width;
+avctx->coded_height = param->mfx.FrameInfo.Height;
+avctx->level= param->mfx.CodecLevel;
+avctx->profile  = param->mfx.CodecProfile;
+avctx->field_order  = ff_qsv_map_picstruct(param->mfx.FrameInfo.PicStruct);
+avctx->pix_fmt  = ff_qsv_map_fourcc(param->mfx.FrameInfo.FourCC);
 
-ret = MFXVideoDECODE_Init(q->session, );
+ret = MFXVideoDECODE_Init(q->session, param);
 if (ret < 0)
 return ff_qsv_print_error(avctx, ret,
   "Error initializing the MFX video decoder");
 
-

[FFmpeg-devel] [PATCH 2/6] lavc/qsv: make function qsv_map_fourcc() can be called externally

2019-08-13 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 libavcodec/qsv.c  | 4 ++--
 libavcodec/qsv_internal.h | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 437ef7c..533804a 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -207,7 +207,7 @@ int ff_qsv_print_warning(void *log_ctx, mfxStatus err,
 return ret;
 }
 
-static enum AVPixelFormat qsv_map_fourcc(uint32_t fourcc)
+enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
 {
 switch (fourcc) {
 case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
@@ -518,7 +518,7 @@ static mfxStatus qsv_frame_alloc(mfxHDL pthis, 
mfxFrameAllocRequest *req,
 frames_hwctx = frames_ctx->hwctx;
 
 frames_ctx->format= AV_PIX_FMT_QSV;
-frames_ctx->sw_format = qsv_map_fourcc(i->FourCC);
+frames_ctx->sw_format = ff_qsv_map_fourcc(i->FourCC);
 frames_ctx->width = i->Width;
 frames_ctx->height= i->Height;
 frames_ctx->initial_pool_size = req->NumFrameSuggested;
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index f701cee..c50e9c7 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -92,6 +92,8 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id);
 int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile);
 int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level);
 
+enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc);
+
 int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc);
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
 
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 1/6] lavc/qsvdec: add function ff_qsv_map_picstruct()

2019-08-13 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 libavcodec/qsv.c  | 18 ++
 libavcodec/qsv_internal.h |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 986d4f6..437ef7c 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -245,6 +245,24 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, 
QSVFrame *frame)
 return AVERROR_BUG;
 }
 
+enum AVFieldOrder ff_qsv_map_picstruct(int mfx_pic_struct)
+{
+enum AVFieldOrder field = AV_FIELD_UNKNOWN;
+switch (mfx_pic_struct & 0xF) {
+case MFX_PICSTRUCT_PROGRESSIVE:
+field = AV_FIELD_PROGRESSIVE;
+break;
+case MFX_PICSTRUCT_FIELD_TFF:
+field = AV_FIELD_TT;
+break;
+case MFX_PICSTRUCT_FIELD_BFF:
+field = AV_FIELD_BB;
+break;
+}
+
+return field;
+}
+
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
 {
 enum AVPictureType type;
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index b63a7d6..f701cee 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -95,6 +95,8 @@ int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level);
 int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc);
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
 
+enum AVFieldOrder ff_qsv_map_picstruct(int mfx_pic_struct);
+
 int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
  const char *load_plugins);
 
-- 
2.7.4

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

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