[FFmpeg-devel] [PATCH V1 2/2] lavfi/hqdn3d: add slice thread optionmation

2019-10-02 Thread Jun Zhao
From: Jun Zhao 

Enabled one thread per planar, used the test command for 1080P video
(YUV420P format) as follow:

ffmpeg -i 1080p.mp4 -an -vf hqdn3d -f null /dev/nul

This optimization improved the performance about 30% in 1080P YUV420P
case (from 110fps to 143fps), also pass the framemd5 check and FATE.

Signed-off-by: Jun Zhao 
---
 libavfilter/vf_hqdn3d.c |   55 +-
 libavfilter/vf_hqdn3d.h |2 +-
 2 files changed, 40 insertions(+), 17 deletions(-)

diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c
index d6c14bb..1530c40 100644
--- a/libavfilter/vf_hqdn3d.c
+++ b/libavfilter/vf_hqdn3d.c
@@ -223,7 +223,9 @@ static av_cold void uninit(AVFilterContext *ctx)
 av_freep(>coefs[1]);
 av_freep(>coefs[2]);
 av_freep(>coefs[3]);
-av_freep(>line);
+av_freep(>line[0]);
+av_freep(>line[1]);
+av_freep(>line[2]);
 av_freep(>frame_prev[0]);
 av_freep(>frame_prev[1]);
 av_freep(>frame_prev[2]);
@@ -271,9 +273,11 @@ static int config_input(AVFilterLink *inlink)
 s->vsub  = desc->log2_chroma_h;
 s->depth = desc->comp[0].depth;
 
-s->line = av_malloc_array(inlink->w, sizeof(*s->line));
-if (!s->line)
-return AVERROR(ENOMEM);
+for (i = 0; i < 3; i++) {
+s->line[i] = av_malloc_array(inlink->w, sizeof(*s->line[i]));
+if (!s->line[i])
+return AVERROR(ENOMEM);
+}
 
 for (i = 0; i < 4; i++) {
 s->coefs[i] = precalc_coefs(s->strength[i], s->depth);
@@ -287,14 +291,38 @@ static int config_input(AVFilterLink *inlink)
 return 0;
 }
 
+struct ThreadData {
+AVFrame *in, *out;
+int direct;
+};
+
+static int do_denoise(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
+{
+struct ThreadData *td = data;
+HQDN3DContext *s = ctx->priv;
+AVFrame *out = td->out;
+AVFrame *in = td->in;
+int direct = td->direct;
+
+denoise(s, in->data[job_nr], out->data[job_nr],
+s->line[job_nr], >frame_prev[job_nr],
+AV_CEIL_RSHIFT(in->width,  (!!job_nr * s->hsub)),
+AV_CEIL_RSHIFT(in->height, (!!job_nr * s->vsub)),
+in->linesize[job_nr], out->linesize[job_nr],
+s->coefs[job_nr ? CHROMA_SPATIAL : LUMA_SPATIAL],
+s->coefs[job_nr ? CHROMA_TMP : LUMA_TMP]);
+
+return 0;
+}
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx  = inlink->dst;
-HQDN3DContext *s = ctx->priv;
 AVFilterLink *outlink = ctx->outputs[0];
 
 AVFrame *out;
-int c, direct = av_frame_is_writable(in) && !ctx->is_disabled;
+int direct = av_frame_is_writable(in) && !ctx->is_disabled;
+struct ThreadData td;
 
 if (direct) {
 out = in;
@@ -308,15 +336,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 av_frame_copy_props(out, in);
 }
 
-for (c = 0; c < 3; c++) {
-denoise(s, in->data[c], out->data[c],
-s->line, >frame_prev[c],
-AV_CEIL_RSHIFT(in->width,  (!!c * s->hsub)),
-AV_CEIL_RSHIFT(in->height, (!!c * s->vsub)),
-in->linesize[c], out->linesize[c],
-s->coefs[c ? CHROMA_SPATIAL : LUMA_SPATIAL],
-s->coefs[c ? CHROMA_TMP : LUMA_TMP]);
-}
+td.in = in;
+td.out = out;
+td.direct = direct;
+ctx->internal->execute(ctx, do_denoise, , NULL, 3);
 
 if (ctx->is_disabled) {
 av_frame_free();
@@ -370,5 +393,5 @@ AVFilter ff_vf_hqdn3d = {
 .query_formats = query_formats,
 .inputs= avfilter_vf_hqdn3d_inputs,
 .outputs   = avfilter_vf_hqdn3d_outputs,
-.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
+.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | 
AVFILTER_FLAG_SLICE_THREADS,
 };
diff --git a/libavfilter/vf_hqdn3d.h b/libavfilter/vf_hqdn3d.h
index 03a79a1..3279bbc 100644
--- a/libavfilter/vf_hqdn3d.h
+++ b/libavfilter/vf_hqdn3d.h
@@ -31,7 +31,7 @@
 typedef struct HQDN3DContext {
 const AVClass *class;
 int16_t *coefs[4];
-uint16_t *line;
+uint16_t *line[3];
 uint16_t *frame_prev[3];
 double strength[4];
 int hsub, vsub;
-- 
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".

[FFmpeg-devel] [PATCH V1 1/2] avutil/common: Fix underflow for ROUNDED_DIV with unsigned integer

2019-10-02 Thread Jun Zhao
From: Mengye Lv 

When used ROUNDED_DIV(a,b), if a is unsigned integer zero, it's
will lead to an underflow issue(it called unsigned integer
wrapping).

Fixes #8062

Signed-off-by: Mengye Lv 
Signed-off-by: Jun Zhao 
---
 libavutil/common.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavutil/common.h b/libavutil/common.h
index af35397..f09f0b4 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -53,7 +53,7 @@
 //rounded division & shift
 #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + 
((1<<(b))>>1)-1)>>(b))
 /* assume b>0 */
-#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
+#define ROUNDED_DIV(a,b) (((a)>=0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
 /* Fast a/(1<=0 and b>=0 */
 #define AV_CEIL_RSHIFT(a,b) (!av_builtin_constant_p(b) ? -((-(a)) >> (b)) \
: ((a) + (1<<(b)) - 1) 
>> (b))
-- 
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".

[FFmpeg-devel] avcodec_send_packet: send 0 size packet to libopus for loss concealment

2019-10-02 Thread Anthony Alba
Hi devs,

I am converting a PCAP RTP file using the libopus decoder and there
may be missing packets. This is not a real-time application. I am
implementing my own reordering/missing packet buffer so if the buffer
declares a packet "lost" I want to inform the libopus.

Two questions:

1. What is the correct pattern to avcodec_send_packet() to signal lost
packet to a generic decoder?

2. libopus accepts NULL data and 0 size for loss concealment, but this
is a flush packet in libavcodec semantics, so how do you pass-through
this information? I accept that this is a leaky implementation detail
of the decoder so probably not the "correct" way to use libavcodec.

Thank you.

Anthony
___
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 17/18] cbs_h265: Add functions to turn HDR metadata into SEI

2019-10-02 Thread Mark Thompson
On 03/10/2019 00:04, Mark Thompson wrote:
> ---
> With intent to add some sort of support for this in H.265 metadata, though 
> it's not in this set.
> 
> Is there any thought on what a human-usable text serialisation of 
> AVMasteringDisplayMetadata should look like?  Ideally it wants to be 
> something which would require no escaping when using it on the command-line.  
> (This is relevant to video filters as well.)
> 
> 
>  libavcodec/Makefile   |  2 +-
>  libavcodec/cbs_h265.c | 94 +++
>  libavcodec/cbs_h265.h | 18 +
>  3 files changed, 113 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/cbs_h265.c
> 
> ...
> +cll->max_content_light_level = av_clip_uintp2(clm->MaxCLL, 16);
> +cll->max_pic_average_light_level = av_clip_uintp2(clm->MaxCLL, 16);

Stupid error is stupid :(

Fixed locally.

- Mark
___
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 09/18] cbs_h265: Use table-based alloc/free

2019-10-02 Thread Mark Thompson
---
 libavcodec/cbs_h2645.c | 198 +++--
 1 file changed, 94 insertions(+), 104 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 4aba615bef..9f7d910711 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -443,71 +443,6 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
*gbc)
 #undef allocate
 
 
-static void cbs_h265_free_vps(void *opaque, uint8_t *content)
-{
-H265RawVPS *vps = (H265RawVPS*)content;
-av_buffer_unref(>extension_data.data_ref);
-av_freep();
-}
-
-static void cbs_h265_free_sps(void *opaque, uint8_t *content)
-{
-H265RawSPS *sps = (H265RawSPS*)content;
-av_buffer_unref(>extension_data.data_ref);
-av_freep();
-}
-
-static void cbs_h265_free_pps(void *opaque, uint8_t *content)
-{
-H265RawPPS *pps = (H265RawPPS*)content;
-av_buffer_unref(>extension_data.data_ref);
-av_freep();
-}
-
-static void cbs_h265_free_slice(void *opaque, uint8_t *content)
-{
-H265RawSlice *slice = (H265RawSlice*)content;
-av_buffer_unref(>data_ref);
-av_freep();
-}
-
-static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload)
-{
-switch (payload->payload_type) {
-case HEVC_SEI_TYPE_BUFFERING_PERIOD:
-case HEVC_SEI_TYPE_PICTURE_TIMING:
-case HEVC_SEI_TYPE_PAN_SCAN_RECT:
-case HEVC_SEI_TYPE_RECOVERY_POINT:
-case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
-case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS:
-case HEVC_SEI_TYPE_DECODED_PICTURE_HASH:
-case HEVC_SEI_TYPE_TIME_CODE:
-case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO:
-case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
-case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
-case HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO:
-break;
-case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
-av_buffer_unref(>payload.user_data_registered.data_ref);
-break;
-case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED:
-av_buffer_unref(>payload.user_data_unregistered.data_ref);
-break;
-default:
-av_buffer_unref(>payload.other.data_ref);
-break;
-}
-}
-
-static void cbs_h265_free_sei(void *opaque, uint8_t *content)
-{
-H265RawSEI *sei = (H265RawSEI*)content;
-int i;
-for (i = 0; i < sei->payload_count; i++)
-cbs_h265_free_sei_payload(>payload[i]);
-av_freep();
-}
-
 static int cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx,
CodedBitstreamFragment *frag,
const H2645Packet *packet)
@@ -863,16 +798,14 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 if (err < 0)
 return err;
 
+err = ff_cbs_alloc_unit_content2(ctx, unit);
+if (err < 0)
+return err;
+
 switch (unit->type) {
 case HEVC_NAL_VPS:
 {
-H265RawVPS *vps;
-
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*vps),
-_h265_free_vps);
-if (err < 0)
-return err;
-vps = unit->content;
+H265RawVPS *vps = unit->content;
 
 err = cbs_h265_read_vps(ctx, , vps);
 if (err < 0)
@@ -885,13 +818,7 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 break;
 case HEVC_NAL_SPS:
 {
-H265RawSPS *sps;
-
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*sps),
-_h265_free_sps);
-if (err < 0)
-return err;
-sps = unit->content;
+H265RawSPS *sps = unit->content;
 
 err = cbs_h265_read_sps(ctx, , sps);
 if (err < 0)
@@ -905,13 +832,7 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case HEVC_NAL_PPS:
 {
-H265RawPPS *pps;
-
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*pps),
-_h265_free_pps);
-if (err < 0)
-return err;
-pps = unit->content;
+H265RawPPS *pps = unit->content;
 
 err = cbs_h265_read_pps(ctx, , pps);
 if (err < 0)
@@ -940,15 +861,9 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 case HEVC_NAL_IDR_N_LP:
 case HEVC_NAL_CRA_NUT:
 {
-H265RawSlice *slice;
+H265RawSlice *slice = unit->content;
 int pos, len;
 
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*slice),
-_h265_free_slice);
-if (err < 0)
-return err;
-slice = unit->content;
-
 err = cbs_h265_read_slice_segment_header(ctx, , 
>header);
 if (err < 0)
 return err;
@@ -974,11 +889,6 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case HEVC_NAL_AUD:
 {
-

[FFmpeg-devel] [PATCH 15/18] cbs_h264: Add a function to turn stereo 3D metadata into SEI

2019-10-02 Thread Mark Thompson
---
 libavcodec/cbs_h264.c | 47 +++
 libavcodec/cbs_h264.h |  8 
 2 files changed, 55 insertions(+)

diff --git a/libavcodec/cbs_h264.c b/libavcodec/cbs_h264.c
index 75759c7f25..cc52f68550 100644
--- a/libavcodec/cbs_h264.c
+++ b/libavcodec/cbs_h264.c
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/stereo3d.h"
+
 #include "cbs_h264.h"
 
 int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx,
@@ -104,3 +106,48 @@ void ff_cbs_h264_delete_sei_message(CodedBitstreamContext 
*ctx,
 (sei->payload_count - position) * sizeof(*sei->payload));
 }
 }
+
+void 
ff_cbs_h264_fill_sei_frame_packing_arrangement(H264RawSEIFramePackingArrangement
 *fp,
+const AVStereo3D *st)
+{
+static const int type_map[] = {
+[AV_STEREO3D_2D]  = 6,
+[AV_STEREO3D_SIDEBYSIDE]  = 3,
+[AV_STEREO3D_TOPBOTTOM]   = 4,
+[AV_STEREO3D_FRAMESEQUENCE]   = 5,
+[AV_STEREO3D_CHECKERBOARD]= 0,
+[AV_STEREO3D_SIDEBYSIDE_QUINCUNX] = 3,
+[AV_STEREO3D_LINES]   = 2,
+[AV_STEREO3D_COLUMNS] = 1,
+};
+
+memset(fp, 0, sizeof(*fp));
+
+if (st->type >= FF_ARRAY_ELEMS(type_map))
+return;
+
+fp->frame_packing_arrangement_type = type_map[st->type];
+
+fp->quincunx_sampling_flag =
+st->type == AV_STEREO3D_CHECKERBOARD ||
+st->type == AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+
+if (st->type == AV_STEREO3D_2D)
+fp->content_interpretation_type = 0;
+else if (st->flags & AV_STEREO3D_FLAG_INVERT)
+fp->content_interpretation_type = 2;
+else
+fp->content_interpretation_type = 1;
+
+if (st->type == AV_STEREO3D_FRAMESEQUENCE) {
+if (st->flags & AV_STEREO3D_FLAG_INVERT)
+fp->current_frame_is_frame0_flag =
+st->view == AV_STEREO3D_VIEW_RIGHT;
+else
+fp->current_frame_is_frame0_flag =
+st->view == AV_STEREO3D_VIEW_LEFT;
+}
+
+fp->frame_packing_arrangement_repetition_period =
+st->type != AV_STEREO3D_FRAMESEQUENCE;
+}
diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index 512674ec07..76211c976b 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -525,4 +525,12 @@ void ff_cbs_h264_delete_sei_message(CodedBitstreamContext 
*ctx,
 CodedBitstreamUnit *nal_unit,
 int position);
 
+struct AVStereo3D;
+/**
+ * Fill an SEI Frame Packing Arrangement structure with values derived from
+ * the AVStereo3D side-data structure.
+ */
+void 
ff_cbs_h264_fill_sei_frame_packing_arrangement(H264RawSEIFramePackingArrangement
 *fp,
+const struct AVStereo3D 
*st);
+
 #endif /* AVCODEC_CBS_H264_H */
-- 
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 v3 01/18] cbs: Mention all codecs in unit type comment

2019-10-02 Thread Mark Thompson
---
Now in alphabetical order.


 libavcodec/cbs.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 7c341bffe7..be986df4e4 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -45,8 +45,10 @@ struct CodedBitstreamType;
 /**
  * The codec-specific type of a bitstream unit.
  *
+ * AV1: obu_type
  * H.264 / AVC: nal_unit_type
  * H.265 / HEVC: nal_unit_type
+ * JPEG: marker value (without 0xff prefix)
  * MPEG-2: start code value (without prefix)
  * VP9: unused, set to zero (every unit is a frame)
  */
-- 
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 14/18] cbs_h264: Add support for frame packing arrangement SEI messages

2019-10-02 Thread Mark Thompson
---
 libavcodec/cbs_h264.h | 24 
 libavcodec/cbs_h2645.c|  1 +
 libavcodec/cbs_h264_syntax_template.c | 40 +++
 3 files changed, 65 insertions(+)

diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index abc0c1b732..512674ec07 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -296,6 +296,29 @@ typedef struct H264RawSEIRecoveryPoint {
 uint8_t changing_slice_group_idc;
 } H264RawSEIRecoveryPoint;
 
+typedef struct H264RawSEIFramePackingArrangement {
+uint32_t frame_packing_arrangement_id;
+uint8_t  frame_packing_arrangement_cancel_flag;
+
+uint8_t  frame_packing_arrangement_type;
+uint8_t  quincunx_sampling_flag;
+uint8_t  content_interpretation_type;
+uint8_t  spatial_flipping_flag;
+uint8_t  frame0_flipped_flag;
+uint8_t  field_views_flag;
+uint8_t  current_frame_is_frame0_flag;
+uint8_t  frame0_self_contained_flag;
+uint8_t  frame1_self_contained_flag;
+uint8_t  frame0_grid_position_x;
+uint8_t  frame0_grid_position_y;
+uint8_t  frame1_grid_position_x;
+uint8_t  frame1_grid_position_y;
+uint8_t  frame_packing_arrangement_reserved_byte;
+uint16_t frame_packing_arrangement_repetition_period;
+
+uint8_t  frame_packing_arrangement_extension_flag;
+} H264RawSEIFramePackingArrangement;
+
 typedef struct H264RawSEIDisplayOrientation {
 uint8_t display_orientation_cancel_flag;
 uint8_t hor_flip;
@@ -329,6 +352,7 @@ typedef struct H264RawSEIPayload {
 H264RawSEIUserDataRegistered user_data_registered;
 H264RawSEIUserDataUnregistered user_data_unregistered;
 H264RawSEIRecoveryPoint recovery_point;
+H264RawSEIFramePackingArrangement frame_packing_arrangement;
 H264RawSEIDisplayOrientation display_orientation;
 H264RawSEIMasteringDisplayColourVolume mastering_display_colour_volume;
 H264RawSEIAlternativeTransferCharacteristics
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 16e685174f..51deac3851 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1385,6 +1385,7 @@ void ff_cbs_h264_free_sei_payload(H264RawSEIPayload 
*payload)
 case H264_SEI_TYPE_PIC_TIMING:
 case H264_SEI_TYPE_PAN_SCAN_RECT:
 case H264_SEI_TYPE_RECOVERY_POINT:
+case H264_SEI_TYPE_FRAME_PACKING:
 case H264_SEI_TYPE_DISPLAY_ORIENTATION:
 case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
 case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
diff --git a/libavcodec/cbs_h264_syntax_template.c 
b/libavcodec/cbs_h264_syntax_template.c
index 1671a15d33..123752882f 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -779,6 +779,42 @@ static int FUNC(sei_recovery_point)(CodedBitstreamContext 
*ctx, RWContext *rw,
 return 0;
 }
 
+static int FUNC(sei_frame_packing_arrangement)(CodedBitstreamContext *ctx, 
RWContext *rw,
+   
H264RawSEIFramePackingArrangement *current)
+{
+int err;
+
+HEADER("Frame Packing Arrangement");
+
+ue(frame_packing_arrangement_id, 0, UINT32_MAX - 1);
+flag(frame_packing_arrangement_cancel_flag);
+
+if (!current->frame_packing_arrangement_cancel_flag) {
+u(7, frame_packing_arrangement_type, 0, 7);
+flag(quincunx_sampling_flag);
+u(6, content_interpretation_type, 0, 2);
+flag(spatial_flipping_flag);
+flag(frame0_flipped_flag);
+flag(field_views_flag);
+flag(current_frame_is_frame0_flag);
+flag(frame0_self_contained_flag);
+flag(frame1_self_contained_flag);
+if (!current->quincunx_sampling_flag &&
+current->frame_packing_arrangement_type != 5) {
+ub(4, frame0_grid_position_x);
+ub(4, frame0_grid_position_y);
+ub(4, frame1_grid_position_x);
+ub(4, frame1_grid_position_y);
+}
+u(8, frame_packing_arrangement_reserved_byte, 0, 0);
+ue(frame_packing_arrangement_repetition_period, 0, 16384);
+}
+
+flag(frame_packing_arrangement_extension_flag);
+
+return 0;
+}
+
 static int FUNC(sei_display_orientation)(CodedBitstreamContext *ctx, RWContext 
*rw,
  H264RawSEIDisplayOrientation *current)
 {
@@ -879,6 +915,10 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, 
RWContext *rw,
 CHECK(FUNC(sei_display_orientation)
   (ctx, rw, >payload.display_orientation));
 break;
+case H264_SEI_TYPE_FRAME_PACKING:
+CHECK(FUNC(sei_frame_packing_arrangement)
+  (ctx, rw, >payload.frame_packing_arrangement));
+break;
 case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
 CHECK(FUNC(sei_mastering_display_colour_volume)
   (ctx, rw, >payload.mastering_display_colour_volume));
-- 
2.20.1

___
ffmpeg-devel mailing list

[FFmpeg-devel] [PATCH 16/18] vaapi_encode_h264: Support stereo 3D metadata

2019-10-02 Thread Mark Thompson
Insert frame packing arrangement messages into the stream when input
frames have associated stereo 3D side-data.
---
This was requested recently on ffmpeg-user - 
.  Easy to 
add, so here you go.

Output matches that produced by libx264 in the cases I could test.


 libavcodec/vaapi_encode_h264.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index f4965d8b09..58eae613c4 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -25,6 +25,7 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
+#include "libavutil/stereo3d.h"
 
 #include "avcodec.h"
 #include "cbs.h"
@@ -39,6 +40,7 @@ enum {
 SEI_TIMING = 0x01,
 SEI_IDENTIFIER = 0x02,
 SEI_RECOVERY_POINT = 0x04,
+SEI_FRAME_PACKING  = 0x20,
 };
 
 // Random (version 4) ISO 11578 UUID.
@@ -96,6 +98,7 @@ typedef struct VAAPIEncodeH264Context {
 H264RawSEIBufferingPeriod  sei_buffering_period;
 H264RawSEIPicTimingsei_pic_timing;
 H264RawSEIRecoveryPointsei_recovery_point;
+H264RawSEIFramePackingArrangement sei_frame_packing;
 H264RawSEIUserDataUnregistered sei_identifier;
 char  *sei_identifier_string;
 
@@ -251,6 +254,12 @@ static int 
vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
 sei->payload[i].payload.recovery_point = priv->sei_recovery_point;
 ++i;
 }
+if (priv->sei_needed & SEI_FRAME_PACKING) {
+sei->payload[i].payload_type = H264_SEI_TYPE_FRAME_PACKING;
+sei->payload[i].payload.frame_packing_arrangement =
+priv->sei_frame_packing;
+++i;
+}
 
 sei->payload_count = i;
 av_assert0(sei->payload_count > 0);
@@ -700,6 +709,17 @@ static int 
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
 priv->sei_needed |= SEI_RECOVERY_POINT;
 }
 
+if (priv->sei & SEI_FRAME_PACKING) {
+AVFrameSideData *sd = av_frame_get_side_data(pic->input_image,
+ AV_FRAME_DATA_STEREO3D);
+if (sd) {
+ff_cbs_h264_fill_sei_frame_packing_arrangement(
+>sei_frame_packing, (const AVStereo3D*)sd->data);
+}
+
+priv->sei_needed |= SEI_FRAME_PACKING;
+}
+
 vpic->CurrPic = (VAPictureH264) {
 .picture_id  = pic->recon_surface,
 .frame_idx   = hpic->frame_num,
@@ -1271,7 +1291,7 @@ static const AVOption vaapi_encode_h264_options[] = {
 
 { "sei", "Set SEI to include",
   OFFSET(sei), AV_OPT_TYPE_FLAGS,
-  { .i64 = SEI_IDENTIFIER | SEI_TIMING | SEI_RECOVERY_POINT },
+  { .i64 = SEI_IDENTIFIER | SEI_TIMING | SEI_RECOVERY_POINT | 
SEI_FRAME_PACKING },
   0, INT_MAX, FLAGS, "sei" },
 { "identifier", "Include encoder version identifier",
   0, AV_OPT_TYPE_CONST, { .i64 = SEI_IDENTIFIER },
@@ -1282,6 +1302,9 @@ static const AVOption vaapi_encode_h264_options[] = {
 { "recovery_point", "Include recovery points where appropriate",
   0, AV_OPT_TYPE_CONST, { .i64 = SEI_RECOVERY_POINT },
   INT_MIN, INT_MAX, FLAGS, "sei" },
+{ "frame_packing", "Include frame packing arrangement for stereo 3D",
+  0, AV_OPT_TYPE_CONST, { .i64 = SEI_FRAME_PACKING },
+  INT_MIN, INT_MAX, FLAGS, "sei" },
 
 { "profile", "Set profile (profile_idc and constraint_set*_flag)",
   OFFSET(profile), AV_OPT_TYPE_INT,
-- 
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 v3 08/18] h264_redundant_pps: Make it reference-compatible

2019-10-02 Thread Mark Thompson
From: Andreas Rheinhardt 

Since c6a63e11092c975b89d824f08682fe31948d3686, the parameter sets
modified as content of PPS units were references shared with the
CodedBitstreamH264Context, so modifying them alters the parsing process
of future access units which meant that frames often got discarded
because invalid values were parsed. This patch makes h264_redundant_pps
compatible with the reality of reference-counted parameter sets.

Signed-off-by: Andreas Rheinhardt 
Signed-off-by: Mark Thompson 
---
 libavcodec/h264_redundant_pps_bsf.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/libavcodec/h264_redundant_pps_bsf.c 
b/libavcodec/h264_redundant_pps_bsf.c
index 8405738c4b..4d5dd9a90f 100644
--- a/libavcodec/h264_redundant_pps_bsf.c
+++ b/libavcodec/h264_redundant_pps_bsf.c
@@ -40,8 +40,19 @@ typedef struct H264RedundantPPSContext {
 
 
 static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx,
-H264RawPPS *pps)
+CodedBitstreamUnit *unit)
 {
+H264RawPPS *pps;
+int err;
+
+// The changes we are about to perform affect the parsing process,
+// so we must make sure that the PPS is writable, otherwise the
+// parsing of future slices will be incorrect and even raise errors.
+err = ff_cbs_make_unit_writable(ctx->input, unit);
+if (err < 0)
+return err;
+pps = unit->content;
+
 // Record the current value of pic_init_qp in order to fix up
 // following slices, then overwrite with the global value.
 ctx->current_pic_init_qp = pps->pic_init_qp_minus26 + 26;
@@ -88,7 +99,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, 
AVPacket *pkt)
 if (nal->type == H264_NAL_SPS)
 au_has_sps = 1;
 if (nal->type == H264_NAL_PPS) {
-err = h264_redundant_pps_fixup_pps(ctx, nal->content);
+err = h264_redundant_pps_fixup_pps(ctx, nal);
 if (err < 0)
 goto fail;
 if (!au_has_sps) {
@@ -144,7 +155,7 @@ static int h264_redundant_pps_init(AVBSFContext *bsf)
 
 for (i = 0; i < au->nb_units; i++) {
 if (au->units[i].type == H264_NAL_PPS) {
-err = h264_redundant_pps_fixup_pps(ctx, au->units[i].content);
+err = h264_redundant_pps_fixup_pps(ctx, >units[i]);
 if (err < 0)
 goto fail;
 }
-- 
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 v3 06/18] cbs: Add support functions for handling unit content references

2019-10-02 Thread Mark Thompson
Use the unit type table to determine what we need to do to clone the
internals of the unit content when making copies for refcounting or
writeability.  (This will still fail for units with complex content
if they do not have a defined clone function.)

Setup and naming from a patch by Andreas Rheinhardt
, but with the implementation
changed to use the unit type information if possible rather than
requiring a codec-specific function.
---
I decided against pushing this into the AVBuffer layer for now - there would be 
new external API in that, and I'm not sure exactly what it would look like.  
This code can be simplified a lot if that gets revisited in future, though.


 libavcodec/cbs.c  | 172 ++
 libavcodec/cbs.h  |  29 +++
 libavcodec/cbs_internal.h |   1 +
 3 files changed, 202 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 57f0c2257a..f689221945 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -816,3 +816,175 @@ int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
 
 return 0;
 }
+
+static int cbs_clone_unit_content(AVBufferRef **clone_ref,
+  CodedBitstreamUnit *unit,
+  const CodedBitstreamUnitTypeDescriptor *desc)
+{
+uint8_t *src, *copy;
+uint8_t **src_ptr, **copy_ptr;
+AVBufferRef **src_buf, **copy_buf;
+int err, i;
+
+av_assert0(unit->content);
+src = unit->content;
+
+copy = av_malloc(desc->content_size);
+if (!copy)
+return AVERROR(ENOMEM);
+
+memcpy(copy, src, desc->content_size);
+
+for (i = 0; i < desc->nb_ref_offsets; i++) {
+src_ptr  = (uint8_t**)(src + desc->ref_offsets[i]);
+src_buf  = (AVBufferRef**)(src_ptr + 1);
+copy_ptr = (uint8_t**)(copy + desc->ref_offsets[i]);
+copy_buf = (AVBufferRef**)(copy_ptr + 1);
+
+if (!*src_ptr) {
+av_assert0(!*src_buf);
+continue;
+}
+if (!*src_buf) {
+// We can't handle a non-refcounted pointer here - we don't
+// have enough information to handle whatever structure lies
+// at the other end of it.
+err = AVERROR(EINVAL);
+goto fail;
+}
+
+// src_ptr is required to point somewhere inside src_buf.  If it
+// doesn't, there is a bug somewhere.
+av_assert0(*src_ptr >= (*src_buf)->data &&
+   *src_ptr <  (*src_buf)->data + (*src_buf)->size);
+
+*copy_buf = av_buffer_ref(*src_buf);
+if (!*copy_buf) {
+err = AVERROR(ENOMEM);
+goto fail;
+}
+
+err = av_buffer_make_writable(copy_buf);
+if (err < 0) {
+av_buffer_unref(copy_buf);
+goto fail;
+}
+
+*copy_ptr = (*copy_buf)->data + (*src_ptr - (*src_buf)->data);
+}
+
+*clone_ref = av_buffer_create(copy, desc->content_size,
+  desc->content_free ? desc->content_free :
+  cbs_default_free_unit_content,
+  (void*)desc, 0);
+if (!*clone_ref) {
+err = AVERROR(ENOMEM);
+goto fail;
+}
+
+return 0;
+
+fail:
+for (--i; i >= 0; i--)
+av_buffer_unref((AVBufferRef**)(copy + desc->ref_offsets[i]));
+av_freep();
+*clone_ref = NULL;
+return err;
+}
+
+int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx,
+CodedBitstreamUnit *unit)
+{
+const CodedBitstreamUnitTypeDescriptor *desc;
+AVBufferRef *ref;
+int err;
+
+av_assert0(unit->content);
+if (unit->content_ref) {
+// Already refcounted, nothing to do.
+return 0;
+}
+
+desc = cbs_find_unit_type_desc(ctx, unit);
+if (!desc)
+return AVERROR(ENOSYS);
+
+switch (desc->content_type) {
+case CBS_CONTENT_TYPE_POD:
+ref = av_buffer_alloc(desc->content_size);
+if (!ref)
+return AVERROR(ENOMEM);
+memcpy(ref->data, unit->content, desc->content_size);
+err = 0;
+break;
+
+case CBS_CONTENT_TYPE_INTERNAL_REFS:
+err = cbs_clone_unit_content(, unit, desc);
+break;
+
+case CBS_CONTENT_TYPE_COMPLEX:
+if (!desc->content_clone)
+return AVERROR_PATCHWELCOME;
+err = desc->content_clone(, unit);
+break;
+
+default:
+av_assert0(0 && "Invalid content type.");
+}
+
+if (err < 0)
+return err;
+
+unit->content_ref = ref;
+unit->content = ref->data;
+return 0;
+}
+
+int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,
+  CodedBitstreamUnit *unit)
+{
+const CodedBitstreamUnitTypeDescriptor *desc;
+AVBufferRef *ref;
+int err;
+
+// This can only be applied to refcounted units.
+err = ff_cbs_make_unit_refcounted(ctx, unit);
+if (err < 0)
+return err;
+ 

[FFmpeg-devel] [PATCH v3 02/18] cbs: Ensure that reference fields always follow the associated pointer

2019-10-02 Thread Mark Thompson
Hvaing these together allows us to find both pointers given the address
of only one of them.
---
 libavcodec/cbs_av1.h   |  6 +++---
 libavcodec/cbs_h264.h  | 18 +-
 libavcodec/cbs_h265.h  | 16 
 libavcodec/cbs_jpeg.h  |  2 +-
 libavcodec/cbs_mpeg2.h | 10 +-
 libavcodec/cbs_vp9.h   |  2 +-
 6 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 1fb668ada4..a87cbc030b 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -284,8 +284,8 @@ typedef struct AV1RawFrameHeader {
 
 typedef struct AV1RawTileData {
 uint8_t *data;
-size_t   data_size;
 AVBufferRef *data_ref;
+size_t   data_size;
 } AV1RawTileData;
 
 typedef struct AV1RawTileGroup {
@@ -346,8 +346,8 @@ typedef struct AV1RawMetadataITUTT35 {
 uint8_t itu_t_t35_country_code_extension_byte;
 
 uint8_t *payload;
-size_t   payload_size;
 AVBufferRef *payload_ref;
+size_t   payload_size;
 } AV1RawMetadataITUTT35;
 
 typedef struct AV1RawMetadataTimecode {
@@ -379,8 +379,8 @@ typedef struct AV1RawMetadata {
 
 typedef struct AV1RawPadding {
 uint8_t *payload;
-size_t   payload_size;
 AVBufferRef *payload_ref;
+size_t   payload_size;
 } AV1RawPadding;
 
 
diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index 9f7c2a0d30..65659ae52c 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -277,16 +277,16 @@ typedef struct H264RawSEIPanScanRect {
 typedef struct H264RawSEIUserDataRegistered {
 uint8_t itu_t_t35_country_code;
 uint8_t itu_t_t35_country_code_extension_byte;
-uint8_t *data;
-size_t data_length;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_length;
 } H264RawSEIUserDataRegistered;
 
 typedef struct H264RawSEIUserDataUnregistered {
 uint8_t uuid_iso_iec_11578[16];
-uint8_t *data;
-size_t data_length;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_length;
 } H264RawSEIUserDataUnregistered;
 
 typedef struct H264RawSEIRecoveryPoint {
@@ -334,9 +334,9 @@ typedef struct H264RawSEIPayload {
 H264RawSEIAlternativeTransferCharacteristics
 alternative_transfer_characteristics;
 struct {
-uint8_t *data;
-size_t data_length;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_length;
 } other;
 } payload;
 } H264RawSEIPayload;
@@ -429,10 +429,10 @@ typedef struct H264RawSliceHeader {
 typedef struct H264RawSlice {
 H264RawSliceHeader header;
 
-uint8_t *data;
-size_t   data_size;
-int  data_bit_start;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_size;
+int  data_bit_start;
 } H264RawSlice;
 
 typedef struct H264RawFiller {
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index ad746bf35f..f5eb5af5b2 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -184,8 +184,8 @@ typedef struct H265RawVUI {
 
 typedef struct H265RawPSExtensionData {
 uint8_t *data;
-size_t bit_length;
 AVBufferRef *data_ref;
+size_t bit_length;
 } H265RawPSExtensionData;
 
 typedef struct H265RawVPS {
@@ -541,10 +541,10 @@ typedef struct  H265RawSliceHeader {
 typedef struct H265RawSlice {
 H265RawSliceHeader header;
 
-uint8_t *data;
-size_t   data_size;
-int  data_bit_start;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_size;
+int  data_bit_start;
 } H265RawSlice;
 
 
@@ -600,15 +600,15 @@ typedef struct H265RawSEIUserDataRegistered {
 uint8_t itu_t_t35_country_code;
 uint8_t itu_t_t35_country_code_extension_byte;
 uint8_t *data;
-size_t   data_length;
 AVBufferRef *data_ref;
+size_t   data_length;
 } H265RawSEIUserDataRegistered;
 
 typedef struct H265RawSEIUserDataUnregistered {
 uint8_t uuid_iso_iec_11578[16];
 uint8_t *data;
-size_t   data_length;
 AVBufferRef *data_ref;
+size_t   data_length;
 } H265RawSEIUserDataUnregistered;
 
 typedef struct H265RawSEIRecoveryPoint {
@@ -710,9 +710,9 @@ typedef struct H265RawSEIPayload {
 alternative_transfer_characteristics;
 H265RawSEIAlphaChannelInfo alpha_channel_info;
 struct {
-uint8_t *data;
-size_t data_length;
+uint8_t *data;
 AVBufferRef *data_ref;
+size_t   data_length;
 } other;
 } payload;
 } H265RawSEIPayload;
diff --git a/libavcodec/cbs_jpeg.h b/libavcodec/cbs_jpeg.h
index 913d3f90f6..d51c83845b 100644
--- a/libavcodec/cbs_jpeg.h
+++ b/libavcodec/cbs_jpeg.h
@@ -80,8 +80,8 @@ typedef struct JPEGRawScanHeader {
 typedef struct JPEGRawScan {
 JPEGRawScanHeader header;
 uint8_t  *data;
-size_tdata_size;
 AVBufferRef  *data_ref;
+size_t

[FFmpeg-devel] [PATCH 13/18] cbs_h264: Simplify SEI addition

2019-10-02 Thread Mark Thompson
At the same time, move the H.264 SEI functions to a new file - the combined
H.26[45] CBS file is already very large, and these functions do not require
any of the common read/write elements.
---
 libavcodec/Makefile|   2 +-
 libavcodec/cbs_h264.c  | 106 +
 libavcodec/cbs_h264.h  |  11 +
 libavcodec/cbs_h2645.c |  96 +
 4 files changed, 120 insertions(+), 95 deletions(-)
 create mode 100644 libavcodec/cbs_h264.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 37a84a6bb4..86e512b605 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -64,7 +64,7 @@ OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o
 OBJS-$(CONFIG_CABAC)   += cabac.o
 OBJS-$(CONFIG_CBS) += cbs.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
-OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_h264.o h2645_parse.o
 OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o
 OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
diff --git a/libavcodec/cbs_h264.c b/libavcodec/cbs_h264.c
new file mode 100644
index 00..75759c7f25
--- /dev/null
+++ b/libavcodec/cbs_h264.c
@@ -0,0 +1,106 @@
+/*
+ * 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 "cbs_h264.h"
+
+int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx,
+CodedBitstreamFragment *au,
+H264RawSEIPayload *payload)
+{
+H264RawSEI *sei = NULL;
+int err, i;
+
+// Find an existing SEI NAL unit to add to.
+for (i = 0; i < au->nb_units; i++) {
+if (au->units[i].type == H264_NAL_SEI) {
+sei = au->units[i].content;
+if (sei->payload_count < H264_MAX_SEI_PAYLOADS)
+break;
+
+sei = NULL;
+}
+}
+
+if (!sei) {
+// Need to make a new SEI NAL unit.  Insert it before the first
+// slice data NAL unit; if no slice data, add at the end.
+CodedBitstreamUnit *unit;
+
+for (i = 0; i < au->nb_units; i++) {
+if (au->units[i].type == H264_NAL_SLICE ||
+au->units[i].type == H264_NAL_IDR_SLICE)
+break;
+}
+
+err = ff_cbs_insert_unit(ctx, au, i);
+if (err < 0)
+goto fail;
+unit = >units[i];
+
+err = ff_cbs_alloc_unit_content2(ctx, unit);
+if (err < 0) {
+ff_cbs_delete_unit(ctx, au, i);
+goto fail;
+}
+sei = unit->content;
+
+*sei = (H264RawSEI) {
+.nal_unit_header = {
+.nal_unit_type = H264_NAL_SEI,
+},
+};
+}
+
+memcpy(>payload[sei->payload_count], payload, sizeof(*payload));
+++sei->payload_count;
+
+return 0;
+fail:
+ff_cbs_h264_free_sei_payload(payload);
+return err;
+}
+
+void ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx,
+CodedBitstreamFragment *au,
+CodedBitstreamUnit *nal,
+int position)
+{
+H264RawSEI *sei = nal->content;
+
+av_assert0(nal->type == H264_NAL_SEI);
+av_assert0(position >= 0 && position < sei->payload_count);
+
+if (position == 0 && sei->payload_count == 1) {
+// Deleting NAL unit entirely.
+int i;
+
+for (i = 0; i < au->nb_units; i++) {
+if (>units[i] == nal)
+break;
+}
+
+ff_cbs_delete_unit(ctx, au, i);
+} else {
+ff_cbs_h264_free_sei_payload(>payload[position]);
+
+--sei->payload_count;
+memmove(sei->payload + position,
+sei->payload + position + 1,
+(sei->payload_count - position) * sizeof(*sei->payload));
+}
+}
diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index 65659ae52c..abc0c1b732 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -466,11 +466,22 @@ typedef struct CodedBitstreamH264Context {
 } CodedBitstreamH264Context;
 
 
+/**
+ * Free an SEI payload structure.
+ *
+ 

[FFmpeg-devel] [PATCH 18/18] vaapi_encode_h265: Use common handling for HDR metadata

2019-10-02 Thread Mark Thompson
---
 libavcodec/vaapi_encode_h265.c | 45 +-
 1 file changed, 6 insertions(+), 39 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 538862a9d5..443139dfdb 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -750,39 +750,10 @@ static int 
vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
 AVMasteringDisplayMetadata *mdm =
 (AVMasteringDisplayMetadata *)sd->data;
 
-// SEI is needed when both the primaries and luminance are set
+// Only needed when both primaries and luminance are set.
 if (mdm->has_primaries && mdm->has_luminance) {
-H265RawSEIMasteringDisplayColourVolume *mdcv =
->sei_mastering_display;
-const int mapping[3] = {1, 2, 0};
-const int chroma_den = 5;
-const int luma_den   = 1;
-
-for (i = 0; i < 3; i++) {
-const int j = mapping[i];
-mdcv->display_primaries_x[i] =
-FFMIN(lrint(chroma_den *
-av_q2d(mdm->display_primaries[j][0])),
-  chroma_den);
-mdcv->display_primaries_y[i] =
-FFMIN(lrint(chroma_den *
-av_q2d(mdm->display_primaries[j][1])),
-  chroma_den);
-}
-
-mdcv->white_point_x =
-FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[0])),
-  chroma_den);
-mdcv->white_point_y =
-FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[1])),
-  chroma_den);
-
-mdcv->max_display_mastering_luminance =
-lrint(luma_den * av_q2d(mdm->max_luminance));
-mdcv->min_display_mastering_luminance =
-FFMIN(lrint(luma_den * av_q2d(mdm->min_luminance)),
-  mdcv->max_display_mastering_luminance);
-
+ff_cbs_h265_fill_sei_mastering_display(
+>sei_mastering_display, mdm);
 priv->sei_needed |= SEI_MASTERING_DISPLAY;
 }
 }
@@ -795,13 +766,9 @@ static int 
vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
 
 if (sd) {
-AVContentLightMetadata *clm =
-(AVContentLightMetadata *)sd->data;
-H265RawSEIContentLightLevelInfo *clli =
->sei_content_light_level;
-
-clli->max_content_light_level = FFMIN(clm->MaxCLL,  65535);
-clli->max_pic_average_light_level = FFMIN(clm->MaxFALL, 65535);
+ff_cbs_h265_fill_sei_content_light_level(
+>sei_content_light_level,
+(const AVContentLightMetadata*)sd->data);
 
 priv->sei_needed |= SEI_CONTENT_LIGHT_LEVEL;
 }
-- 
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 v3 10/18] cbs_vp9: Use table-based alloc/free

2019-10-02 Thread Mark Thompson
---
 libavcodec/cbs_vp9.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c
index bd172100fc..df480f42e5 100644
--- a/libavcodec/cbs_vp9.c
+++ b/libavcodec/cbs_vp9.c
@@ -474,13 +474,6 @@ static int cbs_vp9_split_fragment(CodedBitstreamContext 
*ctx,
 return 0;
 }
 
-static void cbs_vp9_free_frame(void *opaque, uint8_t *content)
-{
-VP9RawFrame *frame = (VP9RawFrame*)content;
-av_buffer_unref(>data_ref);
-av_freep();
-}
-
 static int cbs_vp9_read_unit(CodedBitstreamContext *ctx,
  CodedBitstreamUnit *unit)
 {
@@ -492,8 +485,7 @@ static int cbs_vp9_read_unit(CodedBitstreamContext *ctx,
 if (err < 0)
 return err;
 
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*frame),
-_vp9_free_frame);
+err = ff_cbs_alloc_unit_content2(ctx, unit);
 if (err < 0)
 return err;
 frame = unit->content;
@@ -678,11 +670,18 @@ static void cbs_vp9_close(CodedBitstreamContext *ctx)
 av_freep(>write_buffer);
 }
 
+static const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types[] = {
+CBS_UNIT_TYPE_INTERNAL_REF(0, VP9RawFrame, data),
+CBS_UNIT_TYPE_END_OF_LIST
+};
+
 const CodedBitstreamType ff_cbs_type_vp9 = {
 .codec_id  = AV_CODEC_ID_VP9,
 
 .priv_data_size= sizeof(CodedBitstreamVP9Context),
 
+.unit_types= cbs_vp9_unit_types,
+
 .split_fragment= _vp9_split_fragment,
 .read_unit = _vp9_read_unit,
 .write_unit= _vp9_write_unit,
-- 
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 v3 03/18] cbs: Describe allocate/free methods in tabular form

2019-10-02 Thread Mark Thompson
Unit types are split into three categories, depending on how their
content is managed:
* POD structure - these require no special treatment.
* Structure containing references to refcounted buffers - these can use
  a common free function when the offsets of all the internal references
  are known.
* More complex structures - these still require ad-hoc treatment.

For each codec we can then maintain a table of descriptors for each set of
equivalent unit types, defining the mechanism needed to allocate/free that
unit content.  This is not required to be used immediately - a new alloc
function supports this, but does not replace the old one which works without
referring to these tables.
---
I switched to a fixed-size array of unit types in each descriptor to handle the 
case where multiple types need the same handling.  I wonder whether that might 
be better as a pointer, using a compound literal array in each entry - any 
opinion on that?


 libavcodec/cbs.c  | 63 +++
 libavcodec/cbs.h  |  9 ++
 libavcodec/cbs_internal.h | 42 ++
 3 files changed, 114 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 1a43cd2694..57f0c2257a 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -753,3 +753,66 @@ void ff_cbs_delete_unit(CodedBitstreamContext *ctx,
 frag->units + position + 1,
 (frag->nb_units - position) * sizeof(*frag->units));
 }
+
+static void cbs_default_free_unit_content(void *opaque, uint8_t *data)
+{
+const CodedBitstreamUnitTypeDescriptor *desc = opaque;
+if (desc->content_type == CBS_CONTENT_TYPE_INTERNAL_REFS) {
+int i;
+for (i = 0; i < desc->nb_ref_offsets; i++) {
+void **ptr = (void**)(data + desc->ref_offsets[i]);
+av_buffer_unref((AVBufferRef**)(ptr + 1));
+}
+}
+av_free(data);
+}
+
+static const CodedBitstreamUnitTypeDescriptor
+*cbs_find_unit_type_desc(CodedBitstreamContext *ctx,
+ CodedBitstreamUnit *unit)
+{
+const CodedBitstreamUnitTypeDescriptor *desc;
+int i, j;
+
+if (!ctx->codec->unit_types)
+return NULL;
+
+for (i = 0;; i++) {
+desc = >codec->unit_types[i];
+if (desc->nb_unit_types == 0)
+break;
+for (j = 0; j < desc->nb_unit_types; j++) {
+if (desc->unit_types[j] == unit->type)
+return desc;
+}
+}
+return NULL;
+}
+
+int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
+   CodedBitstreamUnit *unit)
+{
+const CodedBitstreamUnitTypeDescriptor *desc;
+
+av_assert0(!unit->content && !unit->content_ref);
+
+desc = cbs_find_unit_type_desc(ctx, unit);
+if (!desc)
+return AVERROR(ENOSYS);
+
+unit->content = av_mallocz(desc->content_size);
+if (!unit->content)
+return AVERROR(ENOMEM);
+
+unit->content_ref =
+av_buffer_create(unit->content, desc->content_size,
+ desc->content_free ? desc->content_free
+: cbs_default_free_unit_content,
+ (void*)desc, 0);
+if (!unit->content_ref) {
+av_freep(>content);
+return AVERROR(ENOMEM);
+}
+
+return 0;
+}
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index be986df4e4..42896042c1 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -345,6 +345,15 @@ int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx,
   size_t size,
   void (*free)(void *opaque, uint8_t *content));
 
+/**
+ * Allocate a new internal content buffer matching the type of the unit.
+ *
+ * The content will be zeroed.
+ */
+int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
+   CodedBitstreamUnit *unit);
+
+
 /**
  * Allocate a new internal data buffer of the given size in the unit.
  *
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index dd4babf092..7ed8ea0049 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -25,11 +25,53 @@
 #include "put_bits.h"
 
 
+enum {
+// Unit content is a simple structure.
+CBS_CONTENT_TYPE_POD,
+// Unit content contains some references to other structures, but all
+// managed via buffer reference counting.  The descriptor defines the
+// structure offsets of every buffer reference.
+CBS_CONTENT_TYPE_INTERNAL_REFS,
+// Unit content is something more complex.  The descriptor defines
+// special functions to manage the content.
+CBS_CONTENT_TYPE_COMPLEX,
+};
+
+enum {
+  // Maximum number of unit types described by the same unit type
+  // descriptor.
+  CBS_MAX_UNIT_TYPES = 16,
+  // Maximum number of reference buffer offsets in any one unit.
+  CBS_MAX_REF_OFFSETS = 1,
+};
+
+typedef struct CodedBitstreamUnitTypeDescriptor {
+int

[FFmpeg-devel] [PATCH v3 04/18] cbs: Add macros to support defining unit type tables

2019-10-02 Thread Mark Thompson
---
 libavcodec/cbs_internal.h | 24 
 1 file changed, 24 insertions(+)

diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index 7ed8ea0049..2b83c03408 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -146,6 +146,30 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, 
PutBitContext *pbc,
 #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
 
 
+#define CBS_UNIT_TYPE_POD(type, structure) { \
+.nb_unit_types  = 1, \
+.unit_types = { type }, \
+.content_type   = CBS_CONTENT_TYPE_POD, \
+.content_size   = sizeof(structure), \
+}
+#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field) { \
+.nb_unit_types  = 1, \
+.unit_types = { type }, \
+.content_type   = CBS_CONTENT_TYPE_INTERNAL_REFS, \
+.content_size   = sizeof(structure), \
+.nb_ref_offsets = 1, \
+.ref_offsets= { offsetof(structure, ref_field) }, \
+}
+#define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func) { \
+.nb_unit_types  = 1, \
+.unit_types = { type }, \
+.content_type   = CBS_CONTENT_TYPE_COMPLEX, \
+.content_size   = sizeof(structure), \
+.content_free   = free_func, \
+}
+#define CBS_UNIT_TYPE_END_OF_LIST { .nb_unit_types = 0 }
+
+
 extern const CodedBitstreamType ff_cbs_type_av1;
 extern const CodedBitstreamType ff_cbs_type_h264;
 extern const CodedBitstreamType ff_cbs_type_h265;
-- 
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 v3 05/18] cbs_h264: Use table-based alloc/free

2019-10-02 Thread Mark Thompson
---
 libavcodec/cbs_h2645.c | 163 ++---
 1 file changed, 70 insertions(+), 93 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 5dd371153a..6c4315e152 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -443,52 +443,6 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
*gbc)
 #undef allocate
 
 
-static void cbs_h264_free_pps(void *opaque, uint8_t *content)
-{
-H264RawPPS *pps = (H264RawPPS*)content;
-av_buffer_unref(>slice_group_id_ref);
-av_freep();
-}
-
-static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload)
-{
-switch (payload->payload_type) {
-case H264_SEI_TYPE_BUFFERING_PERIOD:
-case H264_SEI_TYPE_PIC_TIMING:
-case H264_SEI_TYPE_PAN_SCAN_RECT:
-case H264_SEI_TYPE_RECOVERY_POINT:
-case H264_SEI_TYPE_DISPLAY_ORIENTATION:
-case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
-case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
-break;
-case H264_SEI_TYPE_USER_DATA_REGISTERED:
-av_buffer_unref(>payload.user_data_registered.data_ref);
-break;
-case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
-av_buffer_unref(>payload.user_data_unregistered.data_ref);
-break;
-default:
-av_buffer_unref(>payload.other.data_ref);
-break;
-}
-}
-
-static void cbs_h264_free_sei(void *opaque, uint8_t *content)
-{
-H264RawSEI *sei = (H264RawSEI*)content;
-int i;
-for (i = 0; i < sei->payload_count; i++)
-cbs_h264_free_sei_payload(>payload[i]);
-av_freep();
-}
-
-static void cbs_h264_free_slice(void *opaque, uint8_t *content)
-{
-H264RawSlice *slice = (H264RawSlice*)content;
-av_buffer_unref(>data_ref);
-av_freep();
-}
-
 static void cbs_h265_free_vps(void *opaque, uint8_t *content)
 {
 H265RawVPS *vps = (H265RawVPS*)content;
@@ -784,15 +738,14 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 if (err < 0)
 return err;
 
+err = ff_cbs_alloc_unit_content2(ctx, unit);
+if (err < 0)
+return err;
+
 switch (unit->type) {
 case H264_NAL_SPS:
 {
-H264RawSPS *sps;
-
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*sps), NULL);
-if (err < 0)
-return err;
-sps = unit->content;
+H264RawSPS *sps = unit->content;
 
 err = cbs_h264_read_sps(ctx, , sps);
 if (err < 0)
@@ -806,12 +759,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case H264_NAL_SPS_EXT:
 {
-err = ff_cbs_alloc_unit_content(ctx, unit,
-sizeof(H264RawSPSExtension),
-NULL);
-if (err < 0)
-return err;
-
 err = cbs_h264_read_sps_extension(ctx, , unit->content);
 if (err < 0)
 return err;
@@ -820,13 +767,7 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case H264_NAL_PPS:
 {
-H264RawPPS *pps;
-
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*pps),
-_h264_free_pps);
-if (err < 0)
-return err;
-pps = unit->content;
+H264RawPPS *pps = unit->content;
 
 err = cbs_h264_read_pps(ctx, , pps);
 if (err < 0)
@@ -842,15 +783,9 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 case H264_NAL_IDR_SLICE:
 case H264_NAL_AUXILIARY_SLICE:
 {
-H264RawSlice *slice;
+H264RawSlice *slice = unit->content;
 int pos, len;
 
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*slice),
-_h264_free_slice);
-if (err < 0)
-return err;
-slice = unit->content;
-
 err = cbs_h264_read_slice_header(ctx, , >header);
 if (err < 0)
 return err;
@@ -876,11 +811,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case H264_NAL_AUD:
 {
-err = ff_cbs_alloc_unit_content(ctx, unit,
-sizeof(H264RawAUD), NULL);
-if (err < 0)
-return err;
-
 err = cbs_h264_read_aud(ctx, , unit->content);
 if (err < 0)
 return err;
@@ -889,11 +819,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
*ctx,
 
 case H264_NAL_SEI:
 {
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(H264RawSEI),
-_h264_free_sei);
-if (err < 0)
-return err;
-
 err = cbs_h264_read_sei(ctx, , unit->content);
 if (err < 0)
 return err;
@@ -902,11 +827,6 @@ static int 

[FFmpeg-devel] [PATCH v3 11/18] cbs_av1: Use table-based alloc/free

2019-10-02 Thread Mark Thompson
---
 libavcodec/cbs_av1.c | 85 
 1 file changed, 39 insertions(+), 46 deletions(-)

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index c027933218..67caaf3eea 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -810,50 +810,6 @@ fail:
 return err;
 }
 
-static void cbs_av1_free_tile_data(AV1RawTileData *td)
-{
-av_buffer_unref(>data_ref);
-}
-
-static void cbs_av1_free_padding(AV1RawPadding *pd)
-{
-av_buffer_unref(>payload_ref);
-}
-
-static void cbs_av1_free_metadata(AV1RawMetadata *md)
-{
-switch (md->metadata_type) {
-case AV1_METADATA_TYPE_ITUT_T35:
-av_buffer_unref(>metadata.itut_t35.payload_ref);
-break;
-}
-}
-
-static void cbs_av1_free_obu(void *opaque, uint8_t *content)
-{
-AV1RawOBU *obu = (AV1RawOBU*)content;
-
-switch (obu->header.obu_type) {
-case AV1_OBU_TILE_GROUP:
-cbs_av1_free_tile_data(>obu.tile_group.tile_data);
-break;
-case AV1_OBU_FRAME:
-cbs_av1_free_tile_data(>obu.frame.tile_group.tile_data);
-break;
-case AV1_OBU_TILE_LIST:
-cbs_av1_free_tile_data(>obu.tile_list.tile_data);
-break;
-case AV1_OBU_METADATA:
-cbs_av1_free_metadata(>obu.metadata);
-break;
-case AV1_OBU_PADDING:
-cbs_av1_free_padding(>obu.padding);
-break;
-}
-
-av_freep();
-}
-
 static int cbs_av1_ref_tile_data(CodedBitstreamContext *ctx,
  CodedBitstreamUnit *unit,
  GetBitContext *gbc,
@@ -888,8 +844,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
 GetBitContext gbc;
 int err, start_pos, end_pos;
 
-err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*obu),
-_av1_free_obu);
+err = ff_cbs_alloc_unit_content2(ctx, unit);
 if (err < 0)
 return err;
 obu = unit->content;
@@ -1302,11 +1257,49 @@ static void cbs_av1_close(CodedBitstreamContext *ctx)
 av_freep(>write_buffer);
 }
 
+static void cbs_av1_free_metadata(void *unit, uint8_t *content)
+{
+AV1RawOBU *obu = (AV1RawOBU*)content;
+AV1RawMetadata *md;
+
+av_assert0(obu->header.obu_type == AV1_OBU_METADATA);
+md = >obu.metadata;
+
+switch (md->metadata_type) {
+case AV1_METADATA_TYPE_ITUT_T35:
+av_buffer_unref(>metadata.itut_t35.payload_ref);
+break;
+}
+}
+
+static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = {
+CBS_UNIT_TYPE_POD(AV1_OBU_SEQUENCE_HEADER,AV1RawOBU),
+CBS_UNIT_TYPE_POD(AV1_OBU_TEMPORAL_DELIMITER, AV1RawOBU),
+CBS_UNIT_TYPE_POD(AV1_OBU_FRAME_HEADER,   AV1RawOBU),
+CBS_UNIT_TYPE_POD(AV1_OBU_REDUNDANT_FRAME_HEADER, AV1RawOBU),
+
+CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_TILE_GROUP, AV1RawOBU,
+   obu.tile_group.tile_data.data),
+CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_FRAME,  AV1RawOBU,
+   obu.frame.tile_group.tile_data.data),
+CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_TILE_LIST,  AV1RawOBU,
+   obu.tile_list.tile_data.data),
+CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_PADDING,AV1RawOBU,
+   obu.padding.payload),
+
+CBS_UNIT_TYPE_COMPLEX(AV1_OBU_METADATA, AV1RawOBU,
+  _av1_free_metadata),
+
+CBS_UNIT_TYPE_END_OF_LIST
+};
+
 const CodedBitstreamType ff_cbs_type_av1 = {
 .codec_id  = AV_CODEC_ID_AV1,
 
 .priv_data_size= sizeof(CodedBitstreamAV1Context),
 
+.unit_types= cbs_av1_unit_types,
+
 .split_fragment= _av1_split_fragment,
 .read_unit = _av1_read_unit,
 .write_unit= _av1_write_unit,
-- 
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 v3 07/18] cbs_h2645: Ensure that non-refcounted parameter sets are fully copied

2019-10-02 Thread Mark Thompson
Only copying the main structure is not necessarily sufficient - there
could be references to substructures.
---
 libavcodec/cbs_h2645.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 6c4315e152..4aba615bef 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -702,18 +702,20 @@ static int cbs_h26 ## h26n ## _replace_ ## 
ps_var(CodedBitstreamContext *ctx, \
 CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
 H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
 unsigned int id = ps_var->id_element; \
+int err; \
 if (id >= FF_ARRAY_ELEMS(priv->ps_var)) { \
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid " #ps_name \
" id : %d.\n", id); \
 return AVERROR_INVALIDDATA; \
 } \
+err = ff_cbs_make_unit_refcounted(ctx, unit); \
+if (err < 0) \
+return err; \
 if (priv->ps_var[id] == priv->active_ ## ps_var) \
 priv->active_ ## ps_var = NULL ; \
 av_buffer_unref(>ps_var ## _ref[id]); \
-if (unit->content_ref) \
-priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
-else \
-priv->ps_var ## _ref[id] = av_buffer_alloc(sizeof(*ps_var)); \
+av_assert0(unit->content_ref); \
+priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
 if (!priv->ps_var ## _ref[id]) \
 return AVERROR(ENOMEM); \
 priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## 
_ref[id]->data; \
-- 
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 17/18] cbs_h265: Add functions to turn HDR metadata into SEI

2019-10-02 Thread Mark Thompson
---
With intent to add some sort of support for this in H.265 metadata, though it's 
not in this set.

Is there any thought on what a human-usable text serialisation of 
AVMasteringDisplayMetadata should look like?  Ideally it wants to be something 
which would require no escaping when using it on the command-line.  (This is 
relevant to video filters as well.)


 libavcodec/Makefile   |  2 +-
 libavcodec/cbs_h265.c | 94 +++
 libavcodec/cbs_h265.h | 18 +
 3 files changed, 113 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/cbs_h265.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 86e512b605..d383d4a539 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -65,7 +65,7 @@ OBJS-$(CONFIG_CABAC)   += cabac.o
 OBJS-$(CONFIG_CBS) += cbs.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_h264.o h2645_parse.o
-OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_h265.o h2645_parse.o
 OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
 OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
diff --git a/libavcodec/cbs_h265.c b/libavcodec/cbs_h265.c
new file mode 100644
index 00..b4850bd565
--- /dev/null
+++ b/libavcodec/cbs_h265.c
@@ -0,0 +1,94 @@
+/*
+ * 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/mathematics.h"
+#include "libavutil/mastering_display_metadata.h"
+
+#include "cbs_h265.h"
+
+
+static unsigned int rescale(AVRational value, unsigned int max)
+{
+int64_t scaled = av_rescale(max, value.num, value.den);
+return av_clip(scaled, 0, max);
+}
+
+void 
ff_cbs_h265_fill_sei_mastering_display(H265RawSEIMasteringDisplayColourVolume 
*mdcv,
+const AVMasteringDisplayMetadata 
*mdm)
+{
+memset(mdcv, 0, sizeof(*mdcv));
+
+if (mdm->has_primaries) {
+// The values in the metadata are rationals in the range [0, 1],
+// while the SEI structure contains fixed-point values with an
+// increment of 0.2.  So, scale up by 5 to convert between
+// them.
+
+for (int a = 0; a < 3; a++) {
+// The metadata stores this in RGB order, but the SEI wants it
+// in GBR order.
+int b = (a + 1) % 3;
+mdcv->display_primaries_x[a] =
+rescale(mdm->display_primaries[b][0], 5);
+mdcv->display_primaries_y[a] =
+rescale(mdm->display_primaries[b][1], 5);
+}
+
+mdcv->white_point_x = rescale(mdm->white_point[0], 5);
+mdcv->white_point_y = rescale(mdm->white_point[1], 5);
+}
+
+if (mdm->has_luminance) {
+// Metadata are rational values in candelas per square metre, SEI
+// contains fixed point in units of 0.0001 candelas per square
+// metre.  So, scale up by 1 to convert between them.
+
+mdcv->max_display_mastering_luminance =
+rescale(mdm->max_luminance, 1);
+mdcv->min_display_mastering_luminance =
+rescale(mdm->min_luminance, 1);
+
+// The spec has a hard requirement that min is less than the max,
+// and the SEI-writing code enforces that.
+if (!(mdcv->min_display_mastering_luminance <
+  mdcv->max_display_mastering_luminance)) {
+if (mdcv->max_display_mastering_luminance == 1)
+mdcv->min_display_mastering_luminance =
+mdcv->max_display_mastering_luminance - 1;
+else
+mdcv->max_display_mastering_luminance =
+mdcv->min_display_mastering_luminance + 1;
+}
+} else {
+mdcv->max_display_mastering_luminance = 1;
+mdcv->min_display_mastering_luminance = 0;
+}
+}
+
+void ff_cbs_h265_fill_sei_content_light_level(H265RawSEIContentLightLevelInfo 
*cll,
+  const AVContentLightMetadata 
*clm)
+{
+memset(cll, 0, sizeof(*cll));
+
+// Both the metadata and the SEI are in units of 

[FFmpeg-devel] [PATCH 12/18] cbs: Expose the function to insert a new empty unit into a fragment

2019-10-02 Thread Mark Thompson
This will be helpful when adding new SEI to an existing access unit.
---
 libavcodec/cbs.c | 10 +-
 libavcodec/cbs.h |  7 +++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index f689221945..c9098b09b5 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -624,9 +624,9 @@ int ff_cbs_alloc_unit_data(CodedBitstreamContext *ctx,
 return 0;
 }
 
-static int cbs_insert_unit(CodedBitstreamContext *ctx,
-   CodedBitstreamFragment *frag,
-   int position)
+int ff_cbs_insert_unit(CodedBitstreamContext *ctx,
+   CodedBitstreamFragment *frag,
+   int position)
 {
 CodedBitstreamUnit *units;
 
@@ -686,7 +686,7 @@ int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx,
 content_ref = NULL;
 }
 
-err = cbs_insert_unit(ctx, frag, position);
+err = ff_cbs_insert_unit(ctx, frag, position);
 if (err < 0) {
 av_buffer_unref(_ref);
 return err;
@@ -722,7 +722,7 @@ int ff_cbs_insert_unit_data(CodedBitstreamContext *ctx,
 if (!data_ref)
 return AVERROR(ENOMEM);
 
-err = cbs_insert_unit(ctx, frag, position);
+err = ff_cbs_insert_unit(ctx, frag, position);
 if (err < 0) {
 av_buffer_unref(_ref);
 return err;
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 1144b9f186..0770d6c7cb 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -363,6 +363,13 @@ int ff_cbs_alloc_unit_data(CodedBitstreamContext *ctx,
CodedBitstreamUnit *unit,
size_t size);
 
+/**
+ * Insert a new empty unit into a fragment.
+ */
+int ff_cbs_insert_unit(CodedBitstreamContext *ctx,
+   CodedBitstreamFragment *frag,
+   int position);
+
 /**
  * Insert a new unit into a fragment with the given content.
  *
-- 
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 v3] avformat/movenc: split empty text sample when duration overflow

2019-10-02 Thread Jun Li
On Wed, Oct 2, 2019 at 3:22 PM Carl Eugen Hoyos  wrote:

> Am Mi., 2. Okt. 2019 um 02:21 Uhr schrieb Jun Li :
> >
> > On Tue, Oct 1, 2019 at 4:19 AM Carl Eugen Hoyos 
> wrote:
> >
> > > Am Di., 10. Sept. 2019 um 21:12 Uhr schrieb Jun Li <
> junli1...@gmail.com>:
> > > >
> > > > Fix #7637
> > > > One empty/end sample is created and inserted between two caption
> lines
> > > when there is a gap.
> > > > This patch is to split the sample into multiple ones when its
> duration
> > > is too long (>= INT_MAX).
> > > > ---
> > > >  libavformat/movenc.c  | 24
> ++-
> > > >  tests/fate/subtitles.mak  |  6 +
> > > >  tests/ref/fate/binsub-movtextenc-long-dur |  1 +
> > > >  .../fate/binsub-movtextenc-long-dur-timebase  |  1 +
> > > >  4 files changed, 26 insertions(+), 6 deletions(-)
> > > >  create mode 100644 tests/ref/fate/binsub-movtextenc-long-dur
> > > >  create mode 100644
> tests/ref/fate/binsub-movtextenc-long-dur-timebase
> > > >
> > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> > > > index edddfeeb00..aeb7de351f 100644
> > > > --- a/libavformat/movenc.c
> > > > +++ b/libavformat/movenc.c
> > > > @@ -5746,7 +5746,8 @@ static int mov_write_packet(AVFormatContext *s,
> > > AVPacket *pkt)
> > > >   *
> > > >   * 2) For each subtitle track, check if the current packet's
> > > >   * dts is past the duration of the last subtitle sample. If
> > > > - * so, we now need to write an end sample for that subtitle.
> > > > + * so, we now need to write one or multiple end samples for
> > > > + * that subtitle.
> > > >   *
> > > >   * This must be done conditionally to allow for subtitles
> that
> > > >   * immediately replace each other, in which case an end
> sample
> > > > @@ -5760,11 +5761,22 @@ static int mov_write_packet(AVFormatContext
> *s,
> > > AVPacket *pkt)
> > > >  int ret;
> > > >
> > > >  if (trk->par->codec_id == AV_CODEC_ID_MOV_TEXT &&
> > > > -trk->track_duration < pkt->dts &&
> > > > -(trk->entry == 0 ||
> !trk->last_sample_is_subtitle_end))
> > > {
> > > > -ret = mov_write_subtitle_end_packet(s, i,
> > > trk->track_duration);
> > > > -if (ret < 0) return ret;
> > > > -trk->last_sample_is_subtitle_end = 1;
> > > > +trk->track_duration < pkt->dts) {
> > > > +int max_duration = INT_MAX - 1;
> > > > +if (trk->entry == 0 ||
> > > !trk->last_sample_is_subtitle_end) {
> > > > +ret = mov_write_subtitle_end_packet(s, i,
> > > trk->track_duration);
> > >
> > > > +if (ret < 0) return ret;
> > >
> > > > +trk->last_sample_is_subtitle_end = 1;
> > > > +}
> > > > +if (trk->last_sample_is_subtitle_end &&
> > > > +pkt->dts - trk->track_duration > max_duration) {
> > > > +int64_t dts = trk->track_duration;
> > > > +while(pkt->dts - dts > max_duration) {
> > > > +dts += max_duration;
> > > > +ret = mov_write_subtitle_end_packet(s, i,
> dts);
> > >
> > > > +if (ret < 0) return ret;
> > >
> > > Please add two CRLFs and I am threatening to push this.
> > >
> > > 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".
> >
> >
> > Thanks Carl for review. Code is updated as follows.
>
> git returns an error message ("corrupt line") when I try to
> commit this patch.
>
> Thanks for your time, I rebased the code and re-generated a patch,
together with the fate test file, in the attachments.
Could you please help do a re-try ? Thanks.

-Jun


> 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".
From 105e15e6008f58a3ca77e780164fbfc12aab81dd Mon Sep 17 00:00:00 2001
From: Jun Li 
Date: Tue, 1 Oct 2019 17:16:55 -0700
Subject: [PATCH v4] avformat/movenc: split empty text sample when duration
 overflowa

Fix #7637
One empty/end sample is created and inserted between two caption lines when there is a gap.
This patch is to split the sample into multiple ones when its duration is too long (>= INT_MAX)
---
 libavformat/movenc.c  | 26 ++-
 tests/fate/subtitles.mak  |  6 +
 tests/ref/fate/binsub-movtextenc-long-dur |  1 +
 .../fate/binsub-movtextenc-long-dur-timebase  |  1 +
 4 files 

Re: [FFmpeg-devel] [PATCH v3] avformat/movenc: split empty text sample when duration overflow

2019-10-02 Thread Carl Eugen Hoyos
Am Mi., 2. Okt. 2019 um 02:21 Uhr schrieb Jun Li :
>
> On Tue, Oct 1, 2019 at 4:19 AM Carl Eugen Hoyos  wrote:
>
> > Am Di., 10. Sept. 2019 um 21:12 Uhr schrieb Jun Li :
> > >
> > > Fix #7637
> > > One empty/end sample is created and inserted between two caption lines
> > when there is a gap.
> > > This patch is to split the sample into multiple ones when its duration
> > is too long (>= INT_MAX).
> > > ---
> > >  libavformat/movenc.c  | 24 ++-
> > >  tests/fate/subtitles.mak  |  6 +
> > >  tests/ref/fate/binsub-movtextenc-long-dur |  1 +
> > >  .../fate/binsub-movtextenc-long-dur-timebase  |  1 +
> > >  4 files changed, 26 insertions(+), 6 deletions(-)
> > >  create mode 100644 tests/ref/fate/binsub-movtextenc-long-dur
> > >  create mode 100644 tests/ref/fate/binsub-movtextenc-long-dur-timebase
> > >
> > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> > > index edddfeeb00..aeb7de351f 100644
> > > --- a/libavformat/movenc.c
> > > +++ b/libavformat/movenc.c
> > > @@ -5746,7 +5746,8 @@ static int mov_write_packet(AVFormatContext *s,
> > AVPacket *pkt)
> > >   *
> > >   * 2) For each subtitle track, check if the current packet's
> > >   * dts is past the duration of the last subtitle sample. If
> > > - * so, we now need to write an end sample for that subtitle.
> > > + * so, we now need to write one or multiple end samples for
> > > + * that subtitle.
> > >   *
> > >   * This must be done conditionally to allow for subtitles that
> > >   * immediately replace each other, in which case an end sample
> > > @@ -5760,11 +5761,22 @@ static int mov_write_packet(AVFormatContext *s,
> > AVPacket *pkt)
> > >  int ret;
> > >
> > >  if (trk->par->codec_id == AV_CODEC_ID_MOV_TEXT &&
> > > -trk->track_duration < pkt->dts &&
> > > -(trk->entry == 0 || !trk->last_sample_is_subtitle_end))
> > {
> > > -ret = mov_write_subtitle_end_packet(s, i,
> > trk->track_duration);
> > > -if (ret < 0) return ret;
> > > -trk->last_sample_is_subtitle_end = 1;
> > > +trk->track_duration < pkt->dts) {
> > > +int max_duration = INT_MAX - 1;
> > > +if (trk->entry == 0 ||
> > !trk->last_sample_is_subtitle_end) {
> > > +ret = mov_write_subtitle_end_packet(s, i,
> > trk->track_duration);
> >
> > > +if (ret < 0) return ret;
> >
> > > +trk->last_sample_is_subtitle_end = 1;
> > > +}
> > > +if (trk->last_sample_is_subtitle_end &&
> > > +pkt->dts - trk->track_duration > max_duration) {
> > > +int64_t dts = trk->track_duration;
> > > +while(pkt->dts - dts > max_duration) {
> > > +dts += max_duration;
> > > +ret = mov_write_subtitle_end_packet(s, i, dts);
> >
> > > +if (ret < 0) return ret;
> >
> > Please add two CRLFs and I am threatening to push this.
> >
> > 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".
>
>
> Thanks Carl for review. Code is updated as follows.

git returns an error message ("corrupt line") when I try to
commit this patch.

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 v3] avformat/movenc: split empty text sample when duration overflow

2019-10-02 Thread Jun Li
On Tue, Oct 1, 2019 at 5:20 PM Jun Li  wrote:

>
>
> On Tue, Oct 1, 2019 at 4:19 AM Carl Eugen Hoyos 
> wrote:
>
>> Am Di., 10. Sept. 2019 um 21:12 Uhr schrieb Jun Li :
>> >
>> > Fix #7637
>> > One empty/end sample is created and inserted between two caption lines
>> when there is a gap.
>> > This patch is to split the sample into multiple ones when its duration
>> is too long (>= INT_MAX).
>> > ---
>> >  libavformat/movenc.c  | 24 ++-
>> >  tests/fate/subtitles.mak  |  6 +
>> >  tests/ref/fate/binsub-movtextenc-long-dur |  1 +
>> >  .../fate/binsub-movtextenc-long-dur-timebase  |  1 +
>> >  4 files changed, 26 insertions(+), 6 deletions(-)
>> >  create mode 100644 tests/ref/fate/binsub-movtextenc-long-dur
>> >  create mode 100644 tests/ref/fate/binsub-movtextenc-long-dur-timebase
>> >
>> > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>> > index edddfeeb00..aeb7de351f 100644
>> > --- a/libavformat/movenc.c
>> > +++ b/libavformat/movenc.c
>> > @@ -5746,7 +5746,8 @@ static int mov_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>> >   *
>> >   * 2) For each subtitle track, check if the current packet's
>> >   * dts is past the duration of the last subtitle sample. If
>> > - * so, we now need to write an end sample for that subtitle.
>> > + * so, we now need to write one or multiple end samples for
>> > + * that subtitle.
>> >   *
>> >   * This must be done conditionally to allow for subtitles that
>> >   * immediately replace each other, in which case an end sample
>> > @@ -5760,11 +5761,22 @@ static int mov_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>> >  int ret;
>> >
>> >  if (trk->par->codec_id == AV_CODEC_ID_MOV_TEXT &&
>> > -trk->track_duration < pkt->dts &&
>> > -(trk->entry == 0 ||
>> !trk->last_sample_is_subtitle_end)) {
>> > -ret = mov_write_subtitle_end_packet(s, i,
>> trk->track_duration);
>> > -if (ret < 0) return ret;
>> > -trk->last_sample_is_subtitle_end = 1;
>> > +trk->track_duration < pkt->dts) {
>> > +int max_duration = INT_MAX - 1;
>> > +if (trk->entry == 0 ||
>> !trk->last_sample_is_subtitle_end) {
>> > +ret = mov_write_subtitle_end_packet(s, i,
>> trk->track_duration);
>>
>> > +if (ret < 0) return ret;
>>
>> > +trk->last_sample_is_subtitle_end = 1;
>> > +}
>> > +if (trk->last_sample_is_subtitle_end &&
>> > +pkt->dts - trk->track_duration > max_duration) {
>> > +int64_t dts = trk->track_duration;
>> > +while(pkt->dts - dts > max_duration) {
>> > +dts += max_duration;
>> > +ret = mov_write_subtitle_end_packet(s, i, dts);
>>
>> > +if (ret < 0) return ret;
>>
>> Please add two CRLFs and I am threatening to push this.
>>
>> 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".
>
>
> Thanks Carl for review. Code is updated as follows.
>
>
>
> Fix #7637
> One empty/end sample is created and inserted between two caption lines
> when there is a gap.
> This patch is to split the sample into multiple ones when its duration is
> too long (>= INT_MAX)
> ---
>  libavformat/movenc.c  | 26 ++-
>  tests/fate/subtitles.mak  |  6 +
>  tests/ref/fate/binsub-movtextenc-long-dur |  1 +
>  .../fate/binsub-movtextenc-long-dur-timebase  |  1 +
>  4 files changed, 28 insertions(+), 6 deletions(-)
>  create mode 100644 tests/ref/fate/binsub-movtextenc-long-dur
>  create mode 100644 tests/ref/fate/binsub-movtextenc-long-dur-timebase
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index edddfeeb00..db6f5afefc 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -5746,7 +5746,8 @@ static int mov_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>   *
>   * 2) For each subtitle track, check if the current packet's
>   * dts is past the duration of the last subtitle sample. If
> - * so, we now need to write an end sample for that subtitle.
> + * so, we now need to write one or multiple end samples for
> + * that subtitle.
>   *
>   * This must be done conditionally to allow for subtitles that
>   * immediately replace each other, in which case an end sample
> @@ -5760,11 +5761,24 @@ static int mov_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>  int ret;
>
>  if 

[FFmpeg-devel] [PATCH 4/5] avcodec/tiff: Set FF_CODEC_CAP_INIT_CLEANUP

2019-10-02 Thread Michael Niedermayer
Fixes: memleaks
Fixes: 
17813/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5145600206569472

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/tiff.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 9f24796a88..f537e99b5a 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -2090,8 +2090,6 @@ static av_cold int tiff_init(AVCodecContext *avctx)
 s->avctx_mjpeg->idct_algo = avctx->idct_algo;
 ret = ff_codec_open2_recursive(s->avctx_mjpeg, codec, NULL);
 if (ret < 0) {
-av_frame_free(>jpgframe);
-avcodec_free_context(>avctx_mjpeg);
 return ret;
 }
 
@@ -2142,5 +2140,6 @@ AVCodec ff_tiff_decoder = {
 .decode = decode_frame,
 .init_thread_copy = ONLY_IF_THREADS_ENABLED(tiff_init),
 .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .priv_class = _decoder_class,
 };
-- 
2.23.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 5/5] avcodec/ptx: Check that the input contains at least one line

2019-10-02 Thread Michael Niedermayer
Fixes: Timeout (19sec -> 44ms)
Fixes: 
17816/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PTX_fuzzer-5704459950227456

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/ptx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c
index 42147f4afc..19f9305cda 100644
--- a/libavcodec/ptx.c
+++ b/libavcodec/ptx.c
@@ -55,6 +55,9 @@ static int ptx_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 
 buf += offset;
 
+if (buf_end - buf < w * bytes_per_pixel)
+return AVERROR_INVALIDDATA;
+
 if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
 return ret;
 
-- 
2.23.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 2/5] avcodec/vc1_block: Fix invalid left shift in vc1_decode_p_mb()

2019-10-02 Thread Michael Niedermayer
Fixes: left shift of negative value -6
Fixes: 
17810/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5638541240958976

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vc1_block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index fe7dbf8b1d..f1c9f41f30 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -1481,7 +1481,7 @@ static int vc1_decode_p_mb(VC1Context *v)
 
v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
 if (v->rangeredfrm)
 for (j = 0; j < 64; j++)
-v->block[v->cur_blk_idx][block_map[i]][j] <<= 1;
+v->block[v->cur_blk_idx][block_map[i]][j] *= 2;
 block_cbp   |= 0xF << (i << 2);
 block_intra |= 1 << i;
 } else if (is_coded[i]) {
-- 
2.23.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 3/5] avcodec/dstdec: Check for input exhaustion

2019-10-02 Thread Michael Niedermayer
Fixes: Timeout (239sec -> 16sec)
Fixes: 
17811/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-5715508149616640

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/dstdec.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c
index 8a1bc6a738..48271b10f7 100644
--- a/libavcodec/dstdec.c
+++ b/libavcodec/dstdec.c
@@ -56,6 +56,7 @@ static const int8_t probs_code_pred_coeff[3][3] = {
 typedef struct ArithCoder {
 unsigned int a;
 unsigned int c;
+int overread;
 } ArithCoder;
 
 typedef struct Table {
@@ -172,6 +173,7 @@ static void ac_init(ArithCoder *ac, GetBitContext *gb)
 {
 ac->a = 4095;
 ac->c = get_bits(gb, 12);
+ac->overread = 0;
 }
 
 static av_always_inline void ac_get(ArithCoder *ac, GetBitContext *gb, int p, 
int *e)
@@ -191,6 +193,8 @@ static av_always_inline void ac_get(ArithCoder *ac, 
GetBitContext *gb, int p, in
 if (ac->a < 2048) {
 int n = 11 - av_log2(ac->a);
 ac->a <<= n;
+if (get_bits_left(gb) < n)
+ac->overread ++;
 ac->c = (ac->c << n) | get_bits(gb, n);
 }
 }
@@ -339,6 +343,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 prob = 128;
 }
 
+if (ac->overread > 16)
+return AVERROR_INVALIDDATA;
+
 ac_get(ac, gb, prob, );
 v = ((predict >> 15) ^ residual) & 1;
 dsd[((i >> 3) * channels + ch) << 2] |= v << (7 - (i & 0x7 ));
-- 
2.23.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 1/5] avcodec/wmaprodec: Check if there is a stream

2019-10-02 Thread Michael Niedermayer
Fixes: null pointer dereference
Fixes: signed integer overflow: 512 * 2147483647 cannot be represented in type 
'int'
Fixes: 
17809/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA1_fuzzer-5634409947987968

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/wmaprodec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index d0fa974c80..6ce2dd4adb 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -1902,7 +1902,9 @@ static av_cold int xma_decode_init(AVCodecContext *avctx)
 }
 
 /* encoder supports up to 64 streams / 64*2 channels (would have to alloc 
arrays) */
-if (avctx->channels > XMA_MAX_CHANNELS || s->num_streams > 
XMA_MAX_STREAMS) {
+if (avctx->channels > XMA_MAX_CHANNELS || s->num_streams > XMA_MAX_STREAMS 
||
+s->num_streams <= 0
+) {
 avpriv_request_sample(avctx, "More than %d channels in %d streams", 
XMA_MAX_CHANNELS, s->num_streams);
 return AVERROR_PATCHWELCOME;
 }
-- 
2.23.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] avformat/amr: reduce raw amr false positive detection

2019-10-02 Thread Carl Eugen Hoyos
Am Mi., 2. Okt. 2019 um 22:27 Uhr schrieb Carl Eugen Hoyos :

> Another idea is to require different modes

This would work for amr-wb but not amr-nb:
Silence encoded with libopencore_amrnb looks
similar to the provided sample that decodes to
noise.

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] avformat/amr: reduce raw amr false positive detection

2019-10-02 Thread Carl Eugen Hoyos
Am Mi., 2. Okt. 2019 um 22:18 Uhr schrieb Carl Eugen Hoyos :
>
> Am Mi., 2. Okt. 2019 um 20:19 Uhr schrieb Paul B Mahol :
> >
> > Signed-off-by: Paul B Mahol 
> > ---
> >  libavformat/amr.c | 18 --
> >  1 file changed, 12 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavformat/amr.c b/libavformat/amr.c
> > index 42840a50a3..600cb1b0f0 100644
> > --- a/libavformat/amr.c
> > +++ b/libavformat/amr.c
> > @@ -190,9 +190,12 @@ static int amrnb_probe(const AVProbeData *p)
> >  if (b[++i] != last)
> >  break;
> >  }
> > -if (size > 0) {
> > -valid++;
> > -i += size;
> > +while (size--) {
> > +if (b[i])
> > +valid++;
> > +else
> > +invalid++;
> > +i++;
> >  }
> >  } else {
> >  valid = 0;
> > @@ -246,9 +249,12 @@ static int amrwb_probe(const AVProbeData *p)
> >  if (b[++i] != last)
> >  break;
> >  }
> > -if (size > 0) {
> > -valid++;
> > -i += size;
> > +while (size--) {
> > +if (b[i])
> > +valid++;
> > +else
> > +invalid++;
> > +i++;
> >  }
> >  } else {
> >  valid = 0;
>
> The changes to amrwb are unneeded for the file you provided.
> (A "PGP Secret Sub-key" according to file.)
>
> I encoded a few amr files and "00 00" seems common and not
> invalid.
>
> The following works here but I believe the main issue is that
> our amr decoder happily decodes the "PGP Secret Sub-key"
> without any error messages so I wonder if the detection is
> wrong at all.
>
> diff --git a/libavformat/amr.c b/libavformat/amr.c
> index 42840a50a3..2645af95c2 100644
> --- a/libavformat/amr.c
> +++ b/libavformat/amr.c
> @@ -186,8 +186,18 @@ static int amrnb_probe(const AVProbeData *p)
>  if (mode < 9 && (b[i] & 0x4) == 0x4) {
>  int last = b[i];
>  int size = amrnb_packed_size[mode];
> +int changes = 0, repeats = 0;
>  while (size--) {
>  if (b[++i] != last)
> +changes++;
> +else
> +repeats++;
> +last = b[i];
> +if (repeats >= 2) {
> +i += size;
> +size = 0;
> +break;
> +} else if (changes > 4)
>  break;
>  }
>  if (size > 0) {
> @@ -200,7 +210,7 @@ static int amrnb_probe(const AVProbeData *p)
>  i++;
>  }
>  }
> -if (valid > 100 && valid >> 4 > invalid)
> +if (valid > 120 && valid >> 4 > invalid)

Another idea is to require different modes, that should be simpler if you
believe that the sample should not get detected.

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] avformat/amr: reduce raw amr false positive detection

2019-10-02 Thread Carl Eugen Hoyos
Am Mi., 2. Okt. 2019 um 20:19 Uhr schrieb Paul B Mahol :
>
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/amr.c | 18 --
>  1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/libavformat/amr.c b/libavformat/amr.c
> index 42840a50a3..600cb1b0f0 100644
> --- a/libavformat/amr.c
> +++ b/libavformat/amr.c
> @@ -190,9 +190,12 @@ static int amrnb_probe(const AVProbeData *p)
>  if (b[++i] != last)
>  break;
>  }
> -if (size > 0) {
> -valid++;
> -i += size;
> +while (size--) {
> +if (b[i])
> +valid++;
> +else
> +invalid++;
> +i++;
>  }
>  } else {
>  valid = 0;
> @@ -246,9 +249,12 @@ static int amrwb_probe(const AVProbeData *p)
>  if (b[++i] != last)
>  break;
>  }
> -if (size > 0) {
> -valid++;
> -i += size;
> +while (size--) {
> +if (b[i])
> +valid++;
> +else
> +invalid++;
> +i++;
>  }
>  } else {
>  valid = 0;

The changes to amrwb are unneeded for the file you provided.
(A "PGP Secret Sub-key" according to file.)

I encoded a few amr files and "00 00" seems common and not
invalid.

The following works here but I believe the main issue is that
our amr decoder happily decodes the "PGP Secret Sub-key"
without any error messages so I wonder if the detection is
wrong at all.

diff --git a/libavformat/amr.c b/libavformat/amr.c
index 42840a50a3..2645af95c2 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -186,8 +186,18 @@ static int amrnb_probe(const AVProbeData *p)
 if (mode < 9 && (b[i] & 0x4) == 0x4) {
 int last = b[i];
 int size = amrnb_packed_size[mode];
+int changes = 0, repeats = 0;
 while (size--) {
 if (b[++i] != last)
+changes++;
+else
+repeats++;
+last = b[i];
+if (repeats >= 2) {
+i += size;
+size = 0;
+break;
+} else if (changes > 4)
 break;
 }
 if (size > 0) {
@@ -200,7 +210,7 @@ static int amrnb_probe(const AVProbeData *p)
 i++;
 }
 }
-if (valid > 100 && valid >> 4 > invalid)
+if (valid > 120 && valid >> 4 > invalid)
 return AVPROBE_SCORE_EXTENSION / 2 + 1;
 return 0;
 }


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] [PATCH] avfilter: add arnndn filter

2019-10-02 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi |   11 +
 libavfilter/Makefile |1 +
 libavfilter/af_arnndn.c  | 1543 ++
 libavfilter/allfilters.c |1 +
 4 files changed, 1556 insertions(+)
 create mode 100644 libavfilter/af_arnndn.c

diff --git a/doc/filters.texi b/doc/filters.texi
index e46839bfec..1a75d2eb4a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2029,6 +2029,17 @@ atrim=end=5,areverse
 @end example
 @end itemize
 
+@section arnndn
+
+Reduce noise from speech using Recurrent Neural Networks.
+
+This filter accepts the following options:
+
+@table @option
+@item model, m
+Set train model file to load. This option is always required.
+@end table
+
 @section asetnsamples
 
 Set the number of samples per each output audio frame.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 182fe9df4b..c43fdd662a 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -71,6 +71,7 @@ OBJS-$(CONFIG_APULSATOR_FILTER)  += af_apulsator.o
 OBJS-$(CONFIG_AREALTIME_FILTER)  += f_realtime.o
 OBJS-$(CONFIG_ARESAMPLE_FILTER)  += af_aresample.o
 OBJS-$(CONFIG_AREVERSE_FILTER)   += f_reverse.o
+OBJS-$(CONFIG_ARNNDN_FILTER) += af_arnndn.o
 OBJS-$(CONFIG_ASELECT_FILTER)+= f_select.o
 OBJS-$(CONFIG_ASENDCMD_FILTER)   += f_sendcmd.o
 OBJS-$(CONFIG_ASETNSAMPLES_FILTER)   += af_asetnsamples.o
diff --git a/libavfilter/af_arnndn.c b/libavfilter/af_arnndn.c
new file mode 100644
index 00..3a1b4b40ec
--- /dev/null
+++ b/libavfilter/af_arnndn.c
@@ -0,0 +1,1543 @@
+/* Copyright (c) 2018 Gregor Richards
+ * Copyright (c) 2017 Mozilla
+ * Copyright (c) 2005-2009 Xiph.Org Foundation
+ * Copyright (c) 2007-2008 CSIRO
+ * Copyright (c) 2008-2011 Octasic Inc.
+ * Copyright (c) Jean-Marc Valin
+ * Copyright (c) 2019 Paul B Mahol
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include "libavutil/avassert.h"
+#include "libavutil/avstring.h"
+#include "libavutil/float_dsp.h"
+#include "libavutil/opt.h"
+#include "libavutil/tx.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "filters.h"
+#include "formats.h"
+
+#define FRAME_SIZE_SHIFT 2
+#define FRAME_SIZE (120name->input_weights); \
+av_free((void *) model->name->bias); \
+av_free((void *) model->name); \
+} \
+} while (0)
+#define FREE_GRU(name) do { \
+if (model->name) { \
+av_free((void *) model->name->input_weights); \
+av_free((void *) model->name->recurrent_weights); \
+av_free((void *) model->name->bias); \
+av_free((void *) model->name); \
+} \
+} while (0)
+
+if (!model)
+return;
+FREE_DENSE(input_dense);
+FREE_GRU(vad_gru);
+FREE_GRU(noise_gru);
+FREE_GRU(denoise_gru);
+FREE_DENSE(denoise_output);
+FREE_DENSE(vad_output);
+av_free(model);
+}
+
+static RNNModel *rnnoise_model_from_file(FILE *f)
+{
+RNNModel *ret;
+DenseLayer *input_dense;
+GRULayer *vad_gru;
+GRULayer *noise_gru;
+GRULayer *denoise_gru;
+DenseLayer *denoise_output;
+DenseLayer *vad_output;
+int in;
+
+if (fscanf(f, "rnnoise-nu model file version %d\n", ) != 1 || in != 1)
+return NULL;
+
+ret = av_calloc(1, sizeof(RNNModel));
+if (!ret)
+return NULL;
+
+#define ALLOC_LAYER(type, name) \
+name = av_calloc(1, sizeof(type)); \
+if (!name) { \
+rnnoise_model_free(ret); \
+return NULL; \
+} \
+ret->name = name
+
+ALLOC_LAYER(DenseLayer, input_dense);
+ALLOC_LAYER(GRULayer, vad_gru);
+

Re: [FFmpeg-devel] [PATCH v2 0/2] AltiVec/VSX fixes in swscale

2019-10-02 Thread Daniel Kolesa
On Tue, Oct 1, 2019, at 17:26, Lauri Kasanen wrote:
> Hi,
> 
> I'll apply these in a couple days if no objections. Works ok in my
> tests.

Cool. Lemme know in case anything needs to get fixed.

> 
> - Lauri
> ___
> 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] avfilter/setpts: switch to activate

2019-10-02 Thread Nicolas George
Paul B Mahol (12019-09-30):
> Also properly handle EOF timestamps.
> Fixes #6833.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/setpts.c | 74 
>  1 file changed, 55 insertions(+), 19 deletions(-)
> 
> diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c
> index 800ba6a83f..076534c518 100644
> --- a/libavfilter/setpts.c
> +++ b/libavfilter/setpts.c
> @@ -33,6 +33,7 @@
>  #include "libavutil/time.h"
>  #include "audio.h"
>  #include "avfilter.h"
> +#include "filters.h"
>  #include "internal.h"
>  #include "video.h"
>  
> @@ -154,6 +155,28 @@ static inline char *double2int64str(char *buf, double v)
>  return buf;
>  }
>  
> +static double eval_pts(SetPTSContext *setpts, AVFilterLink *inlink, AVFrame 
> *frame, int64_t pts)
> +{
> +if (isnan(setpts->var_values[VAR_STARTPTS])) {
> +setpts->var_values[VAR_STARTPTS] = TS2D(pts);
> +setpts->var_values[VAR_STARTT  ] = TS2T(pts, inlink->time_base);
> +}
> +setpts->var_values[VAR_PTS   ] = TS2D(pts);
> +setpts->var_values[VAR_T ] = TS2T(pts, inlink->time_base);
> +setpts->var_values[VAR_POS   ] = !frame || frame->pkt_pos == -1 ? 
> NAN : frame->pkt_pos;
> +setpts->var_values[VAR_RTCTIME   ] = av_gettime();
> +
> +if (frame) {
> +if (inlink->type == AVMEDIA_TYPE_VIDEO) {
> +setpts->var_values[VAR_INTERLACED] = frame->interlaced_frame;
> +} else if (inlink->type == AVMEDIA_TYPE_AUDIO) {
> +setpts->var_values[VAR_S] = frame->nb_samples;
> +setpts->var_values[VAR_NB_SAMPLES] = frame->nb_samples;
> +}
> +}
> +
> +return av_expr_eval(setpts->expr, setpts->var_values, NULL);
> +}
>  #define d2istr(v) double2int64str((char[BUF_SIZE]){0}, v)
>  
>  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
> @@ -162,23 +185,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *frame)
>  int64_t in_pts = frame->pts;
>  double d;
>  
> -if (isnan(setpts->var_values[VAR_STARTPTS])) {
> -setpts->var_values[VAR_STARTPTS] = TS2D(frame->pts);
> -setpts->var_values[VAR_STARTT  ] = TS2T(frame->pts, 
> inlink->time_base);
> -}
> -setpts->var_values[VAR_PTS   ] = TS2D(frame->pts);
> -setpts->var_values[VAR_T ] = TS2T(frame->pts, inlink->time_base);
> -setpts->var_values[VAR_POS   ] = frame->pkt_pos == -1 ? NAN : 
> frame->pkt_pos;
> -setpts->var_values[VAR_RTCTIME   ] = av_gettime();
> -
> -if (inlink->type == AVMEDIA_TYPE_VIDEO) {
> -setpts->var_values[VAR_INTERLACED] = frame->interlaced_frame;
> -} else if (inlink->type == AVMEDIA_TYPE_AUDIO) {
> -setpts->var_values[VAR_S] = frame->nb_samples;
> -setpts->var_values[VAR_NB_SAMPLES] = frame->nb_samples;
> -}
> -
> -d = av_expr_eval(setpts->expr, setpts->var_values, NULL);
> +d = eval_pts(setpts, inlink, frame, frame->pts);
>  frame->pts = D2TS(d);
>  

>  av_log(inlink->dst, AV_LOG_TRACE,

I think there should be a LOG_TRACE for the output timestamp too.

> @@ -216,6 +223,35 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *frame)
>  return ff_filter_frame(inlink->dst->outputs[0], frame);
>  }
>  
> +static int activate(AVFilterContext *ctx)
> +{
> +SetPTSContext *setpts = ctx->priv;
> +AVFilterLink *inlink = ctx->inputs[0];
> +AVFilterLink *outlink = ctx->outputs[0];
> +AVFrame *in;
> +int status;
> +int64_t pts;
> +int ret;
> +
> +FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
> +
> +ret = ff_inlink_consume_frame(inlink, );
> +if (ret < 0)
> +return ret;
> +if (ret > 0)
> +return filter_frame(inlink, in);
> +
> +if (ff_inlink_acknowledge_status(inlink, , )) {
> +pts = D2TS(eval_pts(setpts, inlink, NULL, pts));
> +ff_outlink_set_status(outlink, status, pts);
> +return 0;
> +}
> +
> +FF_FILTER_FORWARD_WANTED(outlink, inlink);
> +
> +return FFERROR_NOT_READY;
> +}
> +
>  static av_cold void uninit(AVFilterContext *ctx)
>  {
>  SetPTSContext *setpts = ctx->priv;
> @@ -239,7 +275,6 @@ static const AVFilterPad avfilter_vf_setpts_inputs[] = {
>  .name = "default",
>  .type = AVMEDIA_TYPE_VIDEO,
>  .config_props = config_input,
> -.filter_frame = filter_frame,
>  },
>  { NULL }
>  };
> @@ -256,6 +291,7 @@ AVFilter ff_vf_setpts = {
>  .name  = "setpts",
>  .description = NULL_IF_CONFIG_SMALL("Set PTS for the output video 
> frame."),
>  .init  = init,
> +.activate  = activate,
>  .uninit= uninit,
>  
>  .priv_size = sizeof(SetPTSContext),
> @@ -276,7 +312,6 @@ static const AVFilterPad asetpts_inputs[] = {
>  .name = "default",
>  .type = AVMEDIA_TYPE_AUDIO,
>  .config_props = config_input,
> -.filter_frame = filter_frame,
>  },
>  { NULL }
>  };
> @@ -293,6 +328,7 @@ 

[FFmpeg-devel] [PATCH] avformat/amr: reduce raw amr false positive detection

2019-10-02 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/amr.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/libavformat/amr.c b/libavformat/amr.c
index 42840a50a3..600cb1b0f0 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -190,9 +190,12 @@ static int amrnb_probe(const AVProbeData *p)
 if (b[++i] != last)
 break;
 }
-if (size > 0) {
-valid++;
-i += size;
+while (size--) {
+if (b[i])
+valid++;
+else
+invalid++;
+i++;
 }
 } else {
 valid = 0;
@@ -246,9 +249,12 @@ static int amrwb_probe(const AVProbeData *p)
 if (b[++i] != last)
 break;
 }
-if (size > 0) {
-valid++;
-i += size;
+while (size--) {
+if (b[i])
+valid++;
+else
+invalid++;
+i++;
 }
 } else {
 valid = 0;
-- 
2.17.1

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

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

Re: [FFmpeg-devel] libavfilter new filter proposal

2019-10-02 Thread Carl Eugen Hoyos
Am Mi., 2. Okt. 2019 um 16:54 Uhr schrieb Alexandre Buisson
:

> I developed a simple filter to process all the video frame using
> any other external process while keeping the simplicity of the
> ffmpeg command line to transcode and keep all the properties
> of the original file (audio, subtitle, close caption, etc...)

Not sure if this is acceptable but sending the patch to this mailing
list is the only way to find out.

> I would check if that filter respect the ffmpeg license ?

Only filters under GPL or a less strict license are accepted.

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] avfilter: add acomb filter

2019-10-02 Thread Paul B Mahol
On 10/2/19, James Almer  wrote:
> On 10/2/2019 12:37 PM, Paul B Mahol wrote:
>> On 10/2/19, James Almer  wrote:
>>> On 10/2/2019 12:11 PM, Paul B Mahol wrote:
 Signed-off-by: Paul B Mahol 
 ---
  doc/filters.texi |  28 ++
  libavfilter/Makefile |   1 +
  libavfilter/af_acomb.c   | 188 +++
  libavfilter/allfilters.c |   1 +
  4 files changed, 218 insertions(+)
  create mode 100644 libavfilter/af_acomb.c

 diff --git a/doc/filters.texi b/doc/filters.texi
 index e46839bfec..9c50b2e4b2 100644
 --- a/doc/filters.texi
 +++ b/doc/filters.texi
 @@ -355,6 +355,34 @@ build.

  Below is a description of the currently available audio filters.

 +@section acomb
 +Apply comb audio filtering.
 +
 +Amplifies or attenuates certain frequencies by the superposition of a
 +delayed version of the original audio signal onto itself.
 +
 +@table @option
 +@item t
 +Set comb filtering type.
 +
 +It accepts the following values:
 +@table @option
 +@item f
 +set feedforward type
 +@item b
 +set feedback type
 +@end table
 +
 +@item b0
 +Set direct signal gain. Default is 1. Allowed range is from 0 to 1.
 +
 +@item xM
 +Set delayed line gain. Default is 0.5. Allowed range is from 0 to 1.
 +
 +@item M
 +Set delay in number of samples. Default is 10. Allowed range is from 1
 to
 327680.
 +@end table
 +
  @section acompressor

  A compressor is mainly used to reduce the dynamic range of a signal.
 diff --git a/libavfilter/Makefile b/libavfilter/Makefile
 index 182fe9df4b..d8a16d6e15 100644
 --- a/libavfilter/Makefile
 +++ b/libavfilter/Makefile
 @@ -31,6 +31,7 @@ include $(SRC_PATH)/libavfilter/dnn/Makefile

  # audio filters
  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
 +OBJS-$(CONFIG_ACOMB_FILTER)  += af_acomb.o
  OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
  OBJS-$(CONFIG_ACONTRAST_FILTER)  += af_acontrast.o
  OBJS-$(CONFIG_ACOPY_FILTER)  += af_acopy.o
 diff --git a/libavfilter/af_acomb.c b/libavfilter/af_acomb.c
 new file mode 100644
 index 00..3b0730c363
 --- /dev/null
 +++ b/libavfilter/af_acomb.c
 @@ -0,0 +1,188 @@
 +/*
 + * 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/opt.h"
 +#include "audio.h"
 +#include "avfilter.h"
 +#include "internal.h"
 +
 +typedef struct AudioCombContext {
 +const AVClass *class;
 +
 +double b0, xM;
 +int t, M;
 +
 +int head;
 +int tail;
 +
 +AVFrame *delayframe;
 +
 +void (*filter)(struct AudioCombContext *s, AVFrame *in, AVFrame
 *out);
 +} AudioCombContext;
 +
 +#define OFFSET(x) offsetof(AudioCombContext, x)
 +#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 +
 +static const AVOption acomb_options[] = {
 +{ "t",  "set comb filter type",   OFFSET(t),
 AV_OPT_TYPE_INT,{.i64=0}, 0, 1, A, "t" },
 +{ "f",  "feedforward",0,
 AV_OPT_TYPE_CONST,  {.i64=0}, 0, 0, A, "t" },
 +{ "b",  "feedback",   0,
 AV_OPT_TYPE_CONST,  {.i64=1}, 0, 0, A, "t" },
 +{ "b0", "set direct signal gain", OFFSET(b0),
 AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, A },
 +{ "xM", "set delayed line gain",  OFFSET(xM),
 AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, A },
 +{ "M",  "set delay in number of samples", OFFSET(M),
 AV_OPT_TYPE_INT,{.i64=10}, 1, 327680, A },
 +{ NULL }
 +};
 +
 +AVFILTER_DEFINE_CLASS(acomb);
 +
 +static int query_formats(AVFilterContext *ctx)
 +{
 +AVFilterFormats *formats = NULL;
 +AVFilterChannelLayouts *layouts = NULL;
 +static const enum AVSampleFormat sample_fmts[] = {
 +AV_SAMPLE_FMT_FLTP,
 +AV_SAMPLE_FMT_DBLP,
 +

Re: [FFmpeg-devel] [PATCH] avfilter: add acomb filter

2019-10-02 Thread Paul B Mahol
On 10/2/19, Paul B Mahol  wrote:
> On 10/2/19, James Almer  wrote:
>> On 10/2/2019 12:11 PM, Paul B Mahol wrote:
>>> Signed-off-by: Paul B Mahol 
>>> ---
>>>  doc/filters.texi |  28 ++
>>>  libavfilter/Makefile |   1 +
>>>  libavfilter/af_acomb.c   | 188 +++
>>>  libavfilter/allfilters.c |   1 +
>>>  4 files changed, 218 insertions(+)
>>>  create mode 100644 libavfilter/af_acomb.c
>>>
>>> diff --git a/doc/filters.texi b/doc/filters.texi
>>> index e46839bfec..9c50b2e4b2 100644
>>> --- a/doc/filters.texi
>>> +++ b/doc/filters.texi
>>> @@ -355,6 +355,34 @@ build.
>>>
>>>  Below is a description of the currently available audio filters.
>>>
>>> +@section acomb
>>> +Apply comb audio filtering.
>>> +
>>> +Amplifies or attenuates certain frequencies by the superposition of a
>>> +delayed version of the original audio signal onto itself.
>>> +
>>> +@table @option
>>> +@item t
>>> +Set comb filtering type.
>>> +
>>> +It accepts the following values:
>>> +@table @option
>>> +@item f
>>> +set feedforward type
>>> +@item b
>>> +set feedback type
>>> +@end table
>>> +
>>> +@item b0
>>> +Set direct signal gain. Default is 1. Allowed range is from 0 to 1.
>>> +
>>> +@item xM
>>> +Set delayed line gain. Default is 0.5. Allowed range is from 0 to 1.
>>> +
>>> +@item M
>>> +Set delay in number of samples. Default is 10. Allowed range is from 1
>>> to
>>> 327680.
>>> +@end table
>>> +
>>>  @section acompressor
>>>
>>>  A compressor is mainly used to reduce the dynamic range of a signal.
>>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>>> index 182fe9df4b..d8a16d6e15 100644
>>> --- a/libavfilter/Makefile
>>> +++ b/libavfilter/Makefile
>>> @@ -31,6 +31,7 @@ include $(SRC_PATH)/libavfilter/dnn/Makefile
>>>
>>>  # audio filters
>>>  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
>>> +OBJS-$(CONFIG_ACOMB_FILTER)  += af_acomb.o
>>>  OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
>>>  OBJS-$(CONFIG_ACONTRAST_FILTER)  += af_acontrast.o
>>>  OBJS-$(CONFIG_ACOPY_FILTER)  += af_acopy.o
>>> diff --git a/libavfilter/af_acomb.c b/libavfilter/af_acomb.c
>>> new file mode 100644
>>> index 00..3b0730c363
>>> --- /dev/null
>>> +++ b/libavfilter/af_acomb.c
>>> @@ -0,0 +1,188 @@
>>> +/*
>>> + * 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/opt.h"
>>> +#include "audio.h"
>>> +#include "avfilter.h"
>>> +#include "internal.h"
>>> +
>>> +typedef struct AudioCombContext {
>>> +const AVClass *class;
>>> +
>>> +double b0, xM;
>>> +int t, M;
>>> +
>>> +int head;
>>> +int tail;
>>> +
>>> +AVFrame *delayframe;
>>> +
>>> +void (*filter)(struct AudioCombContext *s, AVFrame *in, AVFrame
>>> *out);
>>> +} AudioCombContext;
>>> +
>>> +#define OFFSET(x) offsetof(AudioCombContext, x)
>>> +#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
>>> +
>>> +static const AVOption acomb_options[] = {
>>> +{ "t",  "set comb filter type",   OFFSET(t),
>>> AV_OPT_TYPE_INT,{.i64=0}, 0, 1, A, "t" },
>>> +{ "f",  "feedforward",0,
>>> AV_OPT_TYPE_CONST,  {.i64=0}, 0, 0, A, "t" },
>>> +{ "b",  "feedback",   0,
>>> AV_OPT_TYPE_CONST,  {.i64=1}, 0, 0, A, "t" },
>>> +{ "b0", "set direct signal gain", OFFSET(b0),
>>> AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, A },
>>> +{ "xM", "set delayed line gain",  OFFSET(xM),
>>> AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, A },
>>> +{ "M",  "set delay in number of samples", OFFSET(M),
>>> AV_OPT_TYPE_INT,{.i64=10}, 1, 327680, A },
>>> +{ NULL }
>>> +};
>>> +
>>> +AVFILTER_DEFINE_CLASS(acomb);
>>> +
>>> +static int query_formats(AVFilterContext *ctx)
>>> +{
>>> +AVFilterFormats *formats = NULL;
>>> +AVFilterChannelLayouts *layouts = NULL;
>>> +static const enum AVSampleFormat sample_fmts[] = {
>>> +AV_SAMPLE_FMT_FLTP,
>>> +AV_SAMPLE_FMT_DBLP,
>>> +AV_SAMPLE_FMT_NONE
>>> +};
>>> +int ret;
>>> +
>>> +formats = ff_make_format_list(sample_fmts);
>>> +if (!formats)
>>> +return AVERROR(ENOMEM);
>>> +ret = 

Re: [FFmpeg-devel] [PATCH] avfilter: add acomb filter

2019-10-02 Thread James Almer
On 10/2/2019 12:37 PM, Paul B Mahol wrote:
> On 10/2/19, James Almer  wrote:
>> On 10/2/2019 12:11 PM, Paul B Mahol wrote:
>>> Signed-off-by: Paul B Mahol 
>>> ---
>>>  doc/filters.texi |  28 ++
>>>  libavfilter/Makefile |   1 +
>>>  libavfilter/af_acomb.c   | 188 +++
>>>  libavfilter/allfilters.c |   1 +
>>>  4 files changed, 218 insertions(+)
>>>  create mode 100644 libavfilter/af_acomb.c
>>>
>>> diff --git a/doc/filters.texi b/doc/filters.texi
>>> index e46839bfec..9c50b2e4b2 100644
>>> --- a/doc/filters.texi
>>> +++ b/doc/filters.texi
>>> @@ -355,6 +355,34 @@ build.
>>>
>>>  Below is a description of the currently available audio filters.
>>>
>>> +@section acomb
>>> +Apply comb audio filtering.
>>> +
>>> +Amplifies or attenuates certain frequencies by the superposition of a
>>> +delayed version of the original audio signal onto itself.
>>> +
>>> +@table @option
>>> +@item t
>>> +Set comb filtering type.
>>> +
>>> +It accepts the following values:
>>> +@table @option
>>> +@item f
>>> +set feedforward type
>>> +@item b
>>> +set feedback type
>>> +@end table
>>> +
>>> +@item b0
>>> +Set direct signal gain. Default is 1. Allowed range is from 0 to 1.
>>> +
>>> +@item xM
>>> +Set delayed line gain. Default is 0.5. Allowed range is from 0 to 1.
>>> +
>>> +@item M
>>> +Set delay in number of samples. Default is 10. Allowed range is from 1 to
>>> 327680.
>>> +@end table
>>> +
>>>  @section acompressor
>>>
>>>  A compressor is mainly used to reduce the dynamic range of a signal.
>>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>>> index 182fe9df4b..d8a16d6e15 100644
>>> --- a/libavfilter/Makefile
>>> +++ b/libavfilter/Makefile
>>> @@ -31,6 +31,7 @@ include $(SRC_PATH)/libavfilter/dnn/Makefile
>>>
>>>  # audio filters
>>>  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
>>> +OBJS-$(CONFIG_ACOMB_FILTER)  += af_acomb.o
>>>  OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
>>>  OBJS-$(CONFIG_ACONTRAST_FILTER)  += af_acontrast.o
>>>  OBJS-$(CONFIG_ACOPY_FILTER)  += af_acopy.o
>>> diff --git a/libavfilter/af_acomb.c b/libavfilter/af_acomb.c
>>> new file mode 100644
>>> index 00..3b0730c363
>>> --- /dev/null
>>> +++ b/libavfilter/af_acomb.c
>>> @@ -0,0 +1,188 @@
>>> +/*
>>> + * 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/opt.h"
>>> +#include "audio.h"
>>> +#include "avfilter.h"
>>> +#include "internal.h"
>>> +
>>> +typedef struct AudioCombContext {
>>> +const AVClass *class;
>>> +
>>> +double b0, xM;
>>> +int t, M;
>>> +
>>> +int head;
>>> +int tail;
>>> +
>>> +AVFrame *delayframe;
>>> +
>>> +void (*filter)(struct AudioCombContext *s, AVFrame *in, AVFrame
>>> *out);
>>> +} AudioCombContext;
>>> +
>>> +#define OFFSET(x) offsetof(AudioCombContext, x)
>>> +#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
>>> +
>>> +static const AVOption acomb_options[] = {
>>> +{ "t",  "set comb filter type",   OFFSET(t),
>>> AV_OPT_TYPE_INT,{.i64=0}, 0, 1, A, "t" },
>>> +{ "f",  "feedforward",0,
>>> AV_OPT_TYPE_CONST,  {.i64=0}, 0, 0, A, "t" },
>>> +{ "b",  "feedback",   0,
>>> AV_OPT_TYPE_CONST,  {.i64=1}, 0, 0, A, "t" },
>>> +{ "b0", "set direct signal gain", OFFSET(b0),
>>> AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, A },
>>> +{ "xM", "set delayed line gain",  OFFSET(xM),
>>> AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, A },
>>> +{ "M",  "set delay in number of samples", OFFSET(M),
>>> AV_OPT_TYPE_INT,{.i64=10}, 1, 327680, A },
>>> +{ NULL }
>>> +};
>>> +
>>> +AVFILTER_DEFINE_CLASS(acomb);
>>> +
>>> +static int query_formats(AVFilterContext *ctx)
>>> +{
>>> +AVFilterFormats *formats = NULL;
>>> +AVFilterChannelLayouts *layouts = NULL;
>>> +static const enum AVSampleFormat sample_fmts[] = {
>>> +AV_SAMPLE_FMT_FLTP,
>>> +AV_SAMPLE_FMT_DBLP,
>>> +AV_SAMPLE_FMT_NONE
>>> +};
>>> +int ret;
>>> +
>>> +formats = ff_make_format_list(sample_fmts);
>>> +if (!formats)
>>> +return AVERROR(ENOMEM);
>>> +ret 

Re: [FFmpeg-devel] [PATCH] avfilter: add acomb filter

2019-10-02 Thread Paul B Mahol
On 10/2/19, James Almer  wrote:
> On 10/2/2019 12:11 PM, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  doc/filters.texi |  28 ++
>>  libavfilter/Makefile |   1 +
>>  libavfilter/af_acomb.c   | 188 +++
>>  libavfilter/allfilters.c |   1 +
>>  4 files changed, 218 insertions(+)
>>  create mode 100644 libavfilter/af_acomb.c
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index e46839bfec..9c50b2e4b2 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -355,6 +355,34 @@ build.
>>
>>  Below is a description of the currently available audio filters.
>>
>> +@section acomb
>> +Apply comb audio filtering.
>> +
>> +Amplifies or attenuates certain frequencies by the superposition of a
>> +delayed version of the original audio signal onto itself.
>> +
>> +@table @option
>> +@item t
>> +Set comb filtering type.
>> +
>> +It accepts the following values:
>> +@table @option
>> +@item f
>> +set feedforward type
>> +@item b
>> +set feedback type
>> +@end table
>> +
>> +@item b0
>> +Set direct signal gain. Default is 1. Allowed range is from 0 to 1.
>> +
>> +@item xM
>> +Set delayed line gain. Default is 0.5. Allowed range is from 0 to 1.
>> +
>> +@item M
>> +Set delay in number of samples. Default is 10. Allowed range is from 1 to
>> 327680.
>> +@end table
>> +
>>  @section acompressor
>>
>>  A compressor is mainly used to reduce the dynamic range of a signal.
>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>> index 182fe9df4b..d8a16d6e15 100644
>> --- a/libavfilter/Makefile
>> +++ b/libavfilter/Makefile
>> @@ -31,6 +31,7 @@ include $(SRC_PATH)/libavfilter/dnn/Makefile
>>
>>  # audio filters
>>  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
>> +OBJS-$(CONFIG_ACOMB_FILTER)  += af_acomb.o
>>  OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
>>  OBJS-$(CONFIG_ACONTRAST_FILTER)  += af_acontrast.o
>>  OBJS-$(CONFIG_ACOPY_FILTER)  += af_acopy.o
>> diff --git a/libavfilter/af_acomb.c b/libavfilter/af_acomb.c
>> new file mode 100644
>> index 00..3b0730c363
>> --- /dev/null
>> +++ b/libavfilter/af_acomb.c
>> @@ -0,0 +1,188 @@
>> +/*
>> + * 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/opt.h"
>> +#include "audio.h"
>> +#include "avfilter.h"
>> +#include "internal.h"
>> +
>> +typedef struct AudioCombContext {
>> +const AVClass *class;
>> +
>> +double b0, xM;
>> +int t, M;
>> +
>> +int head;
>> +int tail;
>> +
>> +AVFrame *delayframe;
>> +
>> +void (*filter)(struct AudioCombContext *s, AVFrame *in, AVFrame
>> *out);
>> +} AudioCombContext;
>> +
>> +#define OFFSET(x) offsetof(AudioCombContext, x)
>> +#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
>> +
>> +static const AVOption acomb_options[] = {
>> +{ "t",  "set comb filter type",   OFFSET(t),
>> AV_OPT_TYPE_INT,{.i64=0}, 0, 1, A, "t" },
>> +{ "f",  "feedforward",0,
>> AV_OPT_TYPE_CONST,  {.i64=0}, 0, 0, A, "t" },
>> +{ "b",  "feedback",   0,
>> AV_OPT_TYPE_CONST,  {.i64=1}, 0, 0, A, "t" },
>> +{ "b0", "set direct signal gain", OFFSET(b0),
>> AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, A },
>> +{ "xM", "set delayed line gain",  OFFSET(xM),
>> AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, A },
>> +{ "M",  "set delay in number of samples", OFFSET(M),
>> AV_OPT_TYPE_INT,{.i64=10}, 1, 327680, A },
>> +{ NULL }
>> +};
>> +
>> +AVFILTER_DEFINE_CLASS(acomb);
>> +
>> +static int query_formats(AVFilterContext *ctx)
>> +{
>> +AVFilterFormats *formats = NULL;
>> +AVFilterChannelLayouts *layouts = NULL;
>> +static const enum AVSampleFormat sample_fmts[] = {
>> +AV_SAMPLE_FMT_FLTP,
>> +AV_SAMPLE_FMT_DBLP,
>> +AV_SAMPLE_FMT_NONE
>> +};
>> +int ret;
>> +
>> +formats = ff_make_format_list(sample_fmts);
>> +if (!formats)
>> +return AVERROR(ENOMEM);
>> +ret = ff_set_common_formats(ctx, formats);
>> +if (ret < 0)
>> +return ret;
>> +
>> +layouts = ff_all_channel_counts();
>> +if (!layouts)
>> +return 

Re: [FFmpeg-devel] [PATCH] avfilter: add acomb filter

2019-10-02 Thread James Almer
On 10/2/2019 12:11 PM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi |  28 ++
>  libavfilter/Makefile |   1 +
>  libavfilter/af_acomb.c   | 188 +++
>  libavfilter/allfilters.c |   1 +
>  4 files changed, 218 insertions(+)
>  create mode 100644 libavfilter/af_acomb.c
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index e46839bfec..9c50b2e4b2 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -355,6 +355,34 @@ build.
>  
>  Below is a description of the currently available audio filters.
>  
> +@section acomb
> +Apply comb audio filtering.
> +
> +Amplifies or attenuates certain frequencies by the superposition of a
> +delayed version of the original audio signal onto itself.
> +
> +@table @option
> +@item t
> +Set comb filtering type.
> +
> +It accepts the following values:
> +@table @option
> +@item f
> +set feedforward type
> +@item b
> +set feedback type
> +@end table
> +
> +@item b0
> +Set direct signal gain. Default is 1. Allowed range is from 0 to 1.
> +
> +@item xM
> +Set delayed line gain. Default is 0.5. Allowed range is from 0 to 1.
> +
> +@item M
> +Set delay in number of samples. Default is 10. Allowed range is from 1 to 
> 327680.
> +@end table
> +
>  @section acompressor
>  
>  A compressor is mainly used to reduce the dynamic range of a signal.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 182fe9df4b..d8a16d6e15 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -31,6 +31,7 @@ include $(SRC_PATH)/libavfilter/dnn/Makefile
>  
>  # audio filters
>  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
> +OBJS-$(CONFIG_ACOMB_FILTER)  += af_acomb.o
>  OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
>  OBJS-$(CONFIG_ACONTRAST_FILTER)  += af_acontrast.o
>  OBJS-$(CONFIG_ACOPY_FILTER)  += af_acopy.o
> diff --git a/libavfilter/af_acomb.c b/libavfilter/af_acomb.c
> new file mode 100644
> index 00..3b0730c363
> --- /dev/null
> +++ b/libavfilter/af_acomb.c
> @@ -0,0 +1,188 @@
> +/*
> + * 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/opt.h"
> +#include "audio.h"
> +#include "avfilter.h"
> +#include "internal.h"
> +
> +typedef struct AudioCombContext {
> +const AVClass *class;
> +
> +double b0, xM;
> +int t, M;
> +
> +int head;
> +int tail;
> +
> +AVFrame *delayframe;
> +
> +void (*filter)(struct AudioCombContext *s, AVFrame *in, AVFrame *out);
> +} AudioCombContext;
> +
> +#define OFFSET(x) offsetof(AudioCombContext, x)
> +#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
> +
> +static const AVOption acomb_options[] = {
> +{ "t",  "set comb filter type",   OFFSET(t),  AV_OPT_TYPE_INT,   
>  {.i64=0}, 0, 1, A, "t" },
> +{ "f",  "feedforward",0,  AV_OPT_TYPE_CONST, 
>  {.i64=0}, 0, 0, A, "t" },
> +{ "b",  "feedback",   0,  AV_OPT_TYPE_CONST, 
>  {.i64=1}, 0, 0, A, "t" },
> +{ "b0", "set direct signal gain", OFFSET(b0), 
> AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, A },
> +{ "xM", "set delayed line gain",  OFFSET(xM), 
> AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, A },
> +{ "M",  "set delay in number of samples", OFFSET(M),  AV_OPT_TYPE_INT,   
>  {.i64=10}, 1, 327680, A },
> +{ NULL }
> +};
> +
> +AVFILTER_DEFINE_CLASS(acomb);
> +
> +static int query_formats(AVFilterContext *ctx)
> +{
> +AVFilterFormats *formats = NULL;
> +AVFilterChannelLayouts *layouts = NULL;
> +static const enum AVSampleFormat sample_fmts[] = {
> +AV_SAMPLE_FMT_FLTP,
> +AV_SAMPLE_FMT_DBLP,
> +AV_SAMPLE_FMT_NONE
> +};
> +int ret;
> +
> +formats = ff_make_format_list(sample_fmts);
> +if (!formats)
> +return AVERROR(ENOMEM);
> +ret = ff_set_common_formats(ctx, formats);
> +if (ret < 0)
> +return ret;
> +
> +layouts = ff_all_channel_counts();
> +if (!layouts)
> +return AVERROR(ENOMEM);
> +
> +ret = ff_set_common_channel_layouts(ctx, layouts);
> +if (ret < 0)
> +return ret;
> +
> +formats = 

[FFmpeg-devel] [PATCH] MAINTAINERS: add myself to setpts

2019-10-02 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7f60ef0021..b0fa38ae99 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -365,6 +365,7 @@ Filters:
   vf_tonemap_opencl.c   Ruiling Song
   vf_yadif.cMichael Niedermayer
   vf_zoompan.c  Paul B Mahol
+  setpts.c  Paul B Mahol
 
 Sources:
   vsrc_mandelbrot.c Michael Niedermayer
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH] avfilter: add acomb filter

2019-10-02 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi |  28 ++
 libavfilter/Makefile |   1 +
 libavfilter/af_acomb.c   | 188 +++
 libavfilter/allfilters.c |   1 +
 4 files changed, 218 insertions(+)
 create mode 100644 libavfilter/af_acomb.c

diff --git a/doc/filters.texi b/doc/filters.texi
index e46839bfec..9c50b2e4b2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -355,6 +355,34 @@ build.
 
 Below is a description of the currently available audio filters.
 
+@section acomb
+Apply comb audio filtering.
+
+Amplifies or attenuates certain frequencies by the superposition of a
+delayed version of the original audio signal onto itself.
+
+@table @option
+@item t
+Set comb filtering type.
+
+It accepts the following values:
+@table @option
+@item f
+set feedforward type
+@item b
+set feedback type
+@end table
+
+@item b0
+Set direct signal gain. Default is 1. Allowed range is from 0 to 1.
+
+@item xM
+Set delayed line gain. Default is 0.5. Allowed range is from 0 to 1.
+
+@item M
+Set delay in number of samples. Default is 10. Allowed range is from 1 to 
327680.
+@end table
+
 @section acompressor
 
 A compressor is mainly used to reduce the dynamic range of a signal.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 182fe9df4b..d8a16d6e15 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -31,6 +31,7 @@ include $(SRC_PATH)/libavfilter/dnn/Makefile
 
 # audio filters
 OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
+OBJS-$(CONFIG_ACOMB_FILTER)  += af_acomb.o
 OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
 OBJS-$(CONFIG_ACONTRAST_FILTER)  += af_acontrast.o
 OBJS-$(CONFIG_ACOPY_FILTER)  += af_acopy.o
diff --git a/libavfilter/af_acomb.c b/libavfilter/af_acomb.c
new file mode 100644
index 00..3b0730c363
--- /dev/null
+++ b/libavfilter/af_acomb.c
@@ -0,0 +1,188 @@
+/*
+ * 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/opt.h"
+#include "audio.h"
+#include "avfilter.h"
+#include "internal.h"
+
+typedef struct AudioCombContext {
+const AVClass *class;
+
+double b0, xM;
+int t, M;
+
+int head;
+int tail;
+
+AVFrame *delayframe;
+
+void (*filter)(struct AudioCombContext *s, AVFrame *in, AVFrame *out);
+} AudioCombContext;
+
+#define OFFSET(x) offsetof(AudioCombContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption acomb_options[] = {
+{ "t",  "set comb filter type",   OFFSET(t),  AV_OPT_TYPE_INT,
{.i64=0}, 0, 1, A, "t" },
+{ "f",  "feedforward",0,  AV_OPT_TYPE_CONST,  
{.i64=0}, 0, 0, A, "t" },
+{ "b",  "feedback",   0,  AV_OPT_TYPE_CONST,  
{.i64=1}, 0, 0, A, "t" },
+{ "b0", "set direct signal gain", OFFSET(b0), AV_OPT_TYPE_DOUBLE, 
{.dbl=1}, 0, 1, A },
+{ "xM", "set delayed line gain",  OFFSET(xM), AV_OPT_TYPE_DOUBLE, 
{.dbl=0.5}, 0, 1, A },
+{ "M",  "set delay in number of samples", OFFSET(M),  AV_OPT_TYPE_INT,
{.i64=10}, 1, 327680, A },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(acomb);
+
+static int query_formats(AVFilterContext *ctx)
+{
+AVFilterFormats *formats = NULL;
+AVFilterChannelLayouts *layouts = NULL;
+static const enum AVSampleFormat sample_fmts[] = {
+AV_SAMPLE_FMT_FLTP,
+AV_SAMPLE_FMT_DBLP,
+AV_SAMPLE_FMT_NONE
+};
+int ret;
+
+formats = ff_make_format_list(sample_fmts);
+if (!formats)
+return AVERROR(ENOMEM);
+ret = ff_set_common_formats(ctx, formats);
+if (ret < 0)
+return ret;
+
+layouts = ff_all_channel_counts();
+if (!layouts)
+return AVERROR(ENOMEM);
+
+ret = ff_set_common_channel_layouts(ctx, layouts);
+if (ret < 0)
+return ret;
+
+formats = ff_all_samplerates();
+return ff_set_common_samplerates(ctx, formats);
+}
+
+#define COMB(name, type, dir, t)\
+static void acomb_## name ## _ ##dir(AudioCombContext *s,   \
+ AVFrame *in, AVFrame *out) \
+{   \
+const type b0 = 

Re: [FFmpeg-devel] libavfilter new filter proposal

2019-10-02 Thread James Almer
On 10/2/2019 11:54 AM, Alexandre Buisson wrote:
>  Hi,
> I developed a simple filter to process all the video frame using any other
> external process while keeping the simplicity of the ffmpeg command line to
> transcode and keep all the properties of the original file (audio,
> subtitle, close caption, etc...)
> 
> I would check if that filter respect the ffmpeg license ? and if the ffmpeg
> community is interested.
> If yes I will try to create a request under github

Github pull requests are ignored. You need to send the patch to this
mailing list.
If you can't set up git send-email, then simply create a patch using git
format-patch and attach it to an email.

> 
> please find below a first draft I used to test if the idea worked
> 
> 

___
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] libavfilter new filter proposal

2019-10-02 Thread Alexandre Buisson
 Hi,
I developed a simple filter to process all the video frame using any other
external process while keeping the simplicity of the ffmpeg command line to
transcode and keep all the properties of the original file (audio,
subtitle, close caption, etc...)

I would check if that filter respect the ffmpeg license ? and if the ffmpeg
community is interested.
If yes I will try to create a request under github

please find below a first draft I used to test if the idea worked


-- 
Regards,
Alexandre
___
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] avcodec/g2meet: Check for end of input in jpg_decode_block()

2019-10-02 Thread Michael Niedermayer
On Mon, Sep 30, 2019 at 08:07:30PM +0200, Tomas Härdin wrote:
> lör 2019-09-28 klockan 17:47 +0200 skrev Michael Niedermayer:
> > On Thu, Sep 12, 2019 at 11:09:16PM +0200, Tomas Härdin wrote:
> > > tor 2019-09-12 klockan 00:21 +0200 skrev Michael Niedermayer:
> > > > On Wed, Sep 11, 2019 at 11:18:47PM +0200, Tomas Härdin wrote:
> > > > > tis 2019-09-10 klockan 16:16 +0200 skrev Michael Niedermayer:
> > > > [...]
> > > > > I've said multiple times that worrying about these timeout things is
> > > > > mostly a waste of time since any serious user will know to put time
> > > > > limits on jobs. 
> > > > 
> > > > Everyone probably has timelimits on jobs but these timeouts are still
> > > > a big problem. And i think this was discussed before ...
> > > > 
> > > > I think if you just think about what timeout to use for each case
> > > > A. a web browser loading image, video and audio files
> > > 
> > > Presumably browser devs know how to use TBB and friends. They also
> > > don't use g2meet, or cinepak, or anything else that isn't H.26* or VP*
> > > etc. Closest thing is GIF
> > > 
> > > > > Resources would be better spent gearing the fuzzing
> > > > > toward finding memory corruption issues, since the harm from them is
> > > > > far more serious.
> > > > 
> > > > Then fixing the timeouts would be a priority as they hold the fuzzer
> > > > up from finding other issues.
> > > > Time spend waiting for a timeout is time the fuzzer cannot search for
> > > > other issues
> > > 
> > > I see this more as a fuzzer tuning thing. When I last did fuzzing with
> > > afl I certainly made sure to give it tiny samples and not a lot of time
> > > per round
> > > 
> > > Question: is the fuzzer really allowed to spend 120 seconds on a test
> > > case like this one? Or is that timing just an after-the-fact thing?
> > 
> > The fuzzer has a timeout of 25 seconds IIRC. Thats on the machiene
> > google runs it on. So local times (which is what would be listed in a
> > patch) will always differ a bit
> 
> OK, that sounds a bit more reasonable.
> 
> > So what shall we do about these 2 patches here ?
> > Ok to push or do you want me to do something else ?
> 
> Nah go ahead. They don't seem to hurt, beyond being a few more lines of
> code.

ok will apply

thanks

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

Observe your enemies, for they first find out your faults. -- Antisthenes


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] avformat/ivf: Change the length field to 32 bits

2019-10-02 Thread Raphaël Zumer
On Tue, 2019-10-01 at 15:57 -0400, Calvin Walton wrote:
> On Tue, 2019-10-01 at 21:41 +0200, Carl Eugen Hoyos wrote:
> > Am Di., 1. Okt. 2019 um 21:35 Uhr schrieb Raphaël Zumer <
> > rzu...@tebako.net>:
> > > On Tue, 2019-10-01 at 20:09 +0100, Derek Buitenhuis wrote:
> > > > Why not just write zero?
> > > > 
> > > > It's, to me, worse to leave a bogus 64-bit write to appease
> > > > bugs
> > > > in
> > > > our
> > > > own demuxer. It's confusing and misleading for any readers of
> > > > the
> > > > code.
> > > 
> > > In that case I would prefer changing the initial written value to
> > > 0
> > > rather than 0xULL. Writing over the unused bytes
> > > twice
> > > to get around an old error is a bit odd as well.
> > 
> > That may needlessly break non-seekable output.
> 
> Writing a 0 as the initial value is consistent with the behaviour of
> libvpx.
> 
> libvpx writes 0 initially:
> https://github.com/webmproject/libvpx/blob/v1.8.1/vpxenc.c#L1191
> then updates afterwards with the length (if output is seekable):
> https://github.com/webmproject/libvpx/blob/v1.8.1/vpxenc.c#L1209
> 
> (for reference, the ivf_write_file_header function is here: 
> https://github.com/webmproject/libvpx/blob/v1.8.1/ivfenc.c#L16 )
> 
> So we need to make sure that ffmpeg can handle 0 values in this field
> regardless.
> 

For now I sent a patch in reply to Derek's message, which writes the
length field as a 32-bit value explicitly, and zeroes out the unused
bytes.

But I agree that if ffmpeg cannot decode a zero length field properly,
and this is how libvpx codes unseekable files, that is another problem.

___
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] avformat/ivfenc: Change the length fields to 32 bits

2019-10-02 Thread Raphaël Zumer
There is no change in the encoded bitstream, but this
ensures that the written field length is consistent
with the reference implementation.

Unused bytes are zeroed out for backwards compatibility.

Signed-off-by: Raphaël Zumer 
---
 libavformat/ivfenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
index ae461a872b..eb70421c44 100644
--- a/libavformat/ivfenc.c
+++ b/libavformat/ivfenc.c
@@ -84,7 +84,8 @@ static int ivf_write_trailer(AVFormatContext *s)
 
 avio_seek(pb, 24, SEEK_SET);
 // overwrite the "length" field (duration)
-avio_wl64(pb, ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 
1));
+avio_wl32(pb, ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 
1));
+avio_wl32(pb, 0); // zero out unused bytes
 avio_seek(pb, end, SEEK_SET);
 }
 
-- 
2.23.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] avformat: Add max_probe_packets option

2019-10-02 Thread Andriy Gelman
On Fri, 27. Sep 16:26, Andriy Gelman wrote:
> From: Andriy Gelman 
> 
> This allows the user to set a maximum number of buffered packets when
> probing a codec. It was a hard-coded parameter before this commit.
> ---
>  doc/formats.texi| 4 
>  libavformat/avformat.h  | 7 +++
>  libavformat/internal.h  | 2 --
>  libavformat/options_table.h | 1 +
>  libavformat/utils.c | 7 ---
>  libavformat/version.h   | 2 +-
>  6 files changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/doc/formats.texi b/doc/formats.texi
> index d689fbadfa..fc80ce1d2b 100644
> --- a/doc/formats.texi
> +++ b/doc/formats.texi
> @@ -27,6 +27,10 @@ stream information. A higher value will enable detecting 
> more
>  information in case it is dispersed into the stream, but will increase
>  latency. Must be an integer not lesser than 32. It is 500 by default.
>  
> +@item max_probe_packets @var{integer} (@emph{input})
> +Set the maximum number of buffered packets when probing a codec.
> +Default is 2500 packets.
> +
>  @item packetsize @var{integer} (@emph{output})
>  Set packet size.
>  
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 6eb329f13f..d4d9a3b06e 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1951,6 +1951,13 @@ typedef struct AVFormatContext {
>   * - decoding: set by user
>   */
>  int skip_estimate_duration_from_pts;
> +
> +/**
> + * Maximum number of packets that can be probed
> + * - encoding: unused
> + * - decoding: set by user
> + */
> +int max_probe_packets;
>  } AVFormatContext;
>  
>  #if FF_API_FORMAT_GET_SET
> diff --git a/libavformat/internal.h b/libavformat/internal.h
> index 67c35cc3e1..ec9a29907a 100644
> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -33,8 +33,6 @@
>  #define PROBE_BUF_MIN 2048
>  #define PROBE_BUF_MAX (1 << 20)
>  
> -#define MAX_PROBE_PACKETS 2500
> -
>  #ifdef DEBUG
>  #define hex_dump_debug(class, buf, size) av_hex_dump_log(class, 
> AV_LOG_DEBUG, buf, size)
>  #else
> diff --git a/libavformat/options_table.h b/libavformat/options_table.h
> index f2f077b34f..618726512b 100644
> --- a/libavformat/options_table.h
> +++ b/libavformat/options_table.h
> @@ -111,6 +111,7 @@ static const AVOption avformat_options[] = {
>  {"protocol_blacklist", "List of protocols that are not allowed to be used", 
> OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL },  CHAR_MIN, 
> CHAR_MAX, D },
>  {"max_streams", "maximum number of streams", OFFSET(max_streams), 
> AV_OPT_TYPE_INT, { .i64 = 1000 }, 0, INT_MAX, D },
>  {"skip_estimate_duration_from_pts", "skip duration calculation in 
> estimate_timings_from_pts", OFFSET(skip_estimate_duration_from_pts), 
> AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D},
> +{"max_probe_packets", "Maximum number of packets to probe a codec", 
> OFFSET(max_probe_packets), AV_OPT_TYPE_INT, {.i64 = 2500 }, 0, INT_MAX, D },
>  {NULL},
>  };
>  
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 9f8a5bfb63..23b5379030 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -363,7 +363,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, 
> AVStream *st,
>  int i;
>  av_log(s, AV_LOG_DEBUG,
> "Probe with size=%d, packets=%d detected %s with score=%d\n",
> -   pd->buf_size, MAX_PROBE_PACKETS - st->probe_packets,
> +   pd->buf_size, s->max_probe_packets - st->probe_packets,
> fmt->name, score);
>  for (i = 0; fmt_id_type[i].name; i++) {
>  if (!strcmp(fmt->name, fmt_id_type[i].name)) {
> @@ -835,6 +835,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
>  int ret, i, err;
>  AVStream *st;
>  
> +
>  for (;;) {
>  AVPacketList *pktl = s->internal->raw_packet_buffer;
>  const AVPacket *pkt1;
> @@ -1954,7 +1955,7 @@ void ff_read_frame_flush(AVFormatContext *s)
>  /* We set the current DTS to an unspecified origin. */
>  st->cur_dts = AV_NOPTS_VALUE;
>  
> -st->probe_packets = MAX_PROBE_PACKETS;
> +st->probe_packets = s->max_probe_packets;
>  
>  for (j = 0; j < MAX_REORDER_DELAY + 1; j++)
>  st->pts_buffer[j] = AV_NOPTS_VALUE;
> @@ -4552,7 +4553,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  st->start_time = AV_NOPTS_VALUE;
>  st->duration   = AV_NOPTS_VALUE;
>  st->first_dts = AV_NOPTS_VALUE;
> -st->probe_packets = MAX_PROBE_PACKETS;
> +st->probe_packets = s->max_probe_packets;
>  st->pts_wrap_reference = AV_NOPTS_VALUE;
>  st->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
>  
> diff --git a/libavformat/version.h b/libavformat/version.h
> index bcd0408d28..dce5a124c7 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 

Re: [FFmpeg-devel] [PATCH v5 1/3] hevc_mp4toannexb: Insert correct parameter sets before IRAP

2019-10-02 Thread Andriy Gelman
On Thu, 26. Sep 14:09, Andriy Gelman wrote:
> From: Andriy Gelman 
> 
> Fixes #7799
> 
> Currently, the mp4toannexb filter always inserts the same extradata at
> the start of the first IRAP unit. As in ticket #7799, this can lead to
> decoding errors if modified parameter sets are signalled in-band.
> 
> This commit keeps track of the VPS/SPS/PPS parameter sets during the
> conversion. The correct combination is inserted at the start of the
> first IRAP. SEIs from extradata are inserted before each IRAP.
> 
> This commit also makes an update to the hevc-bsf-mp4toannexb fate test
> since the result before this patch contained duplicate parameter sets
> in-band.
> ---
>  libavcodec/hevc_mp4toannexb_bsf.c | 488 --
>  tests/fate/hevc.mak   |   2 +-
>  2 files changed, 456 insertions(+), 34 deletions(-)
> 
> diff --git a/libavcodec/hevc_mp4toannexb_bsf.c 
> b/libavcodec/hevc_mp4toannexb_bsf.c
> index 09bce5b34c..90a4d17d25 100644
> --- a/libavcodec/hevc_mp4toannexb_bsf.c
> +++ b/libavcodec/hevc_mp4toannexb_bsf.c
> @@ -23,19 +23,209 @@
>  
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/mem.h"
> +#include "libavutil/avassert.h"
>  
>  #include "avcodec.h"
>  #include "bsf.h"
>  #include "bytestream.h"
>  #include "hevc.h"
> +#include "h2645_parse.h"
> +#include "hevc_ps.h"
> +#include "golomb.h"
>  
>  #define MIN_HEVCC_LENGTH 23
> +#define PROFILE_WITHOUT_IDC_BITS88
> +#define IS_IRAP(s)  ((s)->type >= 16 && (s)->type <= 23)
> +#define IS_PARAMSET(s)  ((s)->type >= 32 && (s)->type <= 34)
> +
> +/*reserved VCLs not included*/
> +#define IS_VCL(s)   ((s)->type <= 9 || ((s)->type >= 16 && 
> (s)->type <= 21))
> +#define HEVC_NAL_HEADER_BITS16
> +
> +/*
> + *Copies data from input buffer to output buffer. Appends annexb startcode.
> + *out must be allocated at least out_len + in_len + 4.
> + */
> +#define WRITE_NAL(out, out_len, in, in_len) do {\
> +AV_WB32((out) + (out_len), 1);  \
> +(out_len) += 4; \
> +memcpy((out) + (out_len), (in), (in_len));  \
> +(out_len) += (in_len);  \
> +} while (0)
> +
> +typedef struct Param {
> +uint8_t *raw_data;  /*raw data to store param set payload*/
> +int  raw_size;  /*size of raw_data*/
> +size_t   allocated_size;/*allocated size of raw_data*/
> +int  ref;   /*stores the ref of the higher level 
> parameter set*/
> +int  is_signalled;  /*indicates whether this param has already 
> been signalled in the cvs*/
> +} Param;
> +
> +/*modified version of HEVCParamSets to store bytestream and reference to 
> previous level*/
> +typedef struct ParamSets {
> +Param vps_list[HEVC_MAX_VPS_COUNT];
> +Param sps_list[HEVC_MAX_SPS_COUNT];
> +Param pps_list[HEVC_MAX_PPS_COUNT];
> +
> +Param sei; /*cached SEIs from extradata in annexb format*/
> +} ParamSets;
>  
>  typedef struct HEVCBSFContext {
>  uint8_t  length_size;
>  int  extradata_parsed;
> +ParamSets ps; /*cached VPS/SPS/PPS parameter sets + SEI from extradata*/
>  } HEVCBSFContext;
>  
> +static int update_cached_paramset(AVBSFContext *ctx, Param *cached_param,
> +  H2645NAL *nal, int ref)
> +{
> +int ret;
> +
> +if (cached_param->raw_data && cached_param->raw_size == nal->raw_size &&
> +!memcmp(cached_param->raw_data, nal->raw_data, nal->raw_size)) {
> +av_log(ctx, AV_LOG_DEBUG, "NAL unit: %d. Copy already exists in 
> parameter set.\n", nal->type);
> +} else {
> +if (nal->raw_size > cached_param->allocated_size) {
> +ret = av_reallocp(_param->raw_data, nal->raw_size);
> +if (ret < 0)
> +return ret;
> +cached_param->allocated_size = nal->raw_size;
> +}
> +memcpy(cached_param->raw_data, nal->raw_data, nal->raw_size);
> +cached_param->raw_size = nal->raw_size;
> +cached_param->ref  = ref;
> +cached_param->is_signalled = 0;
> +}
> +return 0;
> +}
> +
> +static int parse_vps(AVBSFContext *ctx, H2645NAL *nal)
> +{
> +int vps_id, ret;
> +
> +HEVCBSFContext *s = ctx->priv_data;
> +ParamSets *ps = >ps;
> +
> +GetBitContext *gb = >gb;
> +gb->index = HEVC_NAL_HEADER_BITS;
> +
> +vps_id = get_bits(gb, 4);
> +
> +av_log(ctx, AV_LOG_TRACE, "Updating VPS id: %d\n", vps_id);
> +ret = update_cached_paramset(ctx, >vps_list[vps_id], nal, 0);
> +return ret;
> +}
> +
> +static int parse_sps(AVBSFContext *ctx, H2645NAL *nal)
> +{
> +int i, ret;
> +int sps_id, vps_ref, max_sub_layers_minus1;
> +
> +HEVCBSFContext *s = ctx->priv_data;
> +ParamSets *ps = >ps;
> +
> +uint8_t 

Re: [FFmpeg-devel] [PATCH] Fix segment muxer

2019-10-02 Thread just . one . man
Note that the second e-mail contains a more full version of patch which also 
updates times used to generate the playlist, so playlist is now also correct.

---
Thanks,
Vasily

02.10.2019, 14:22, "Vasily" :
> When incoming media has non-zero start PTS,
> segment muxer would fail to correctly calculate
> the point where to chunk segments, as it always
> assumed that media starts with PTS==0.
>
> This change removes this assumption by remembering
> the PTS of the very first frame passed through the muxer.
>
> Also fix starting points of first segment
> ---
>  libavformat/segment.c | 12 +++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index e308206..2478d8f 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -87,6 +87,7 @@ typedef struct SegmentContext {
>  int64_t last_val; ///< remember last time for wrap around detection
>  int cut_pending;
>  int header_written; ///< whether we've already called 
> avformat_write_header
> + int64_t start_pts; ///< pts of the very first packet processed, used to 
> compute correct segment length
>
>  char *entry_prefix; ///< prefix to add to list entry filenames
>  int list_type; ///< set the list type
> @@ -702,6 +703,7 @@ static int seg_init(AVFormatContext *s)
>  if ((ret = parse_frames(s, >frames, >nb_frames, 
> seg->frames_str)) < 0)
>  return ret;
>  } else {
> + seg->start_pts = -1;
>  /* set default value if not specified */
>  if (!seg->time_str)
>  seg->time_str = av_strdup("2");
> @@ -914,7 +916,15 @@ calc_times:
>  seg->cut_pending = 1;
>  seg->last_val = wrapped_val;
>  } else {
> - end_pts = seg->time * (seg->segment_count + 1);
> + if (seg->start_pts != -1) {
> + end_pts = seg->start_pts + seg->time * (seg->segment_count + 1);
> + } else if (pkt->stream_index == seg->reference_stream_index && pkt->pts != 
> AV_NOPTS_VALUE) {
> + // this is the first packet of the reference stream we see, initialize 
> start point
> + seg->start_pts = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q);
> + seg->cur_entry.start_time = (double)pkt->pts * av_q2d(st->time_base);
> + seg->cur_entry.start_pts = seg->start_pts;
> + end_pts = seg->start_pts + seg->time * (seg->segment_count + 1);
> + }
>  }
>  }
>
> --
> 1.7.9.5
___
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] Various build errors with armasm64 and armasm after update to FFmpeg 4.2

2019-10-02 Thread Martin Storsjö

> On Oct 1, 2019, at 23:07, Lukas Fellechner  wrote:
> 
> This has worked very well for quite a long time. But after upgrading to 
> FFmpeg 4.2, the build fails. A lot of changes and additions have been done 
> for ARM/NEON 64-bit, and it looks like many of them are not compatible with 
> armasm64. First I had to fix gas-preprocessor, a patch has been submitted 
> today. But now, many other errors occur, which have to do with the ARM64 
> assembly code itself. I don’t have any knowledge of ARM/NEON assembly code, 
> so I cannot help much with the investigation or fixes.

The issue you posted about, and the other arm64 assembler issue you’ve linked, 
are already fixed since a very long time in libav’s gas-preprocessor, 
https://git.libav.org/?p=gas-preprocessor.git;a=summary.

> On ARM platform, I also see build errors. Interestingly, those files have not 
> even changed. Only the referenced file libavutil/arm/asm.S has changed. Even 
> when I undo the last changes there, the build still fails, so I am out of 
> ideas here right now. When I switch back to FFmpeg 4.1.4, everything builds 
> fine. Maybe there is a config change which causes those errors?

> Errors with ARM target (32 bit):
> 
> C:\Source\FFmpegInterop-lukasf\ffmpeg\Output\Windows10\ARM\libavcodec\arm\ac3dsp_arm.o.asm(72)
>  : error A2173: syntax error in expression
>it gt

This seems to be a new regression in armasm in MSVC 2019 16.3 (released a 
couple weeks ago), see 
https://developercommunity.visualstudio.com/content/problem/757709/armasm-fails-to-handle-it-instructions.html.
 I don’t see how it would work for you with an earlier version of FFmpeg 
though, maybe those files are around from an earlier build and you didn’t try 
doing a full rebuild?

You can apply 
https://lists.libav.org/pipermail/libav-devel/2019-October/086581.html on your 
copy of gas-preprocessor to work around this issue, but I’m not sure if it’s 
worth keeping the fix permanently (if the bug gets fixed in 16.4).

// Martin

___
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] Fix gas-preprocessor to translate .rdata sections for armasm and armasm64

2019-10-02 Thread Martin Storsjö

> On Oct 1, 2019, at 21:37, Lukas Fellechner  wrote:
> 
> Compiling FFmpeg with gas-preprocessor.pl and armasm or armasm64 fails since 
> FFmpeg 4.2.
> 
> New .rdata sections have been added in ARM NEON assembly code (e.g. 
> libavutil/aarch64/asm.S).
> This fix allows gas-preprocessor to translate those sections to armasm 
> compatible code.
> 
> Gas-preprocessor is maintained in https://github.com/FFmpeg/gas-preprocessor
> 
> ---
> gas-preprocessor.pl | 1 +
> 1 file changed, 1 insertion(+)

A fix for this issue, and a lot of other fixes as well not present in the repo 
referenced above, exist at 
https://git.libav.org/?p=gas-preprocessor.git;a=summary.

// Martin

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

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

Re: [FFmpeg-devel] [PATCH 2/3] avformat/aiffenc: Fix potential memleak upon failure

2019-10-02 Thread Matthieu Bouron
On Wed, Oct 02, 2019 at 06:04:11AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/aiffenc.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
> index dd8b8c3d01..0b837cd264 100644
> --- a/libavformat/aiffenc.c
> +++ b/libavformat/aiffenc.c
> @@ -235,7 +235,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket 
> *pkt)
>  
>  static int aiff_write_trailer(AVFormatContext *s)
>  {
> -int ret;
> +int ret = 0;
>  AVIOContext *pb = s->pb;
>  AIFFOutputContext *aiff = s->priv_data;
>  AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar;
> @@ -263,7 +263,7 @@ static int aiff_write_trailer(AVFormatContext *s)
>  /* Write ID3 tags */
>  if (aiff->write_id3v2)
>  if ((ret = put_id3v2_tags(s, aiff)) < 0)
> -return ret;
> +goto free;
>  
>  /* File length */
>  file_size = avio_tell(pb);
> @@ -273,9 +273,10 @@ static int aiff_write_trailer(AVFormatContext *s)
>  avio_flush(pb);
>  }
>  
> +free:
>  ff_packet_list_free(>pict_list, >pict_list_end);
>  
> -return 0;
> +return ret;
>  }
>  
>  #define OFFSET(x) offsetof(AIFFOutputContext, x)
> -- 
> 2.21.0

LGTM.

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

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

Re: [FFmpeg-devel] [PATCH 1/3] avformat/aiffenc: Use standard packet list functions

2019-10-02 Thread Matthieu Bouron
On Wed, Oct 02, 2019 at 06:04:10AM +0200, Andreas Rheinhardt wrote:
> Up until now, aiffenc didn't rely on the standard functions for adding
> an element to a linked list and freeing the list, but instead
> reimplemented them. This has been changed.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/aiffenc.c | 33 -
>  1 file changed, 4 insertions(+), 29 deletions(-)
> 
> diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
> index aab37418f0..dd8b8c3d01 100644
> --- a/libavformat/aiffenc.c
> +++ b/libavformat/aiffenc.c
> @@ -36,7 +36,7 @@ typedef struct AIFFOutputContext {
>  int64_t frames;
>  int64_t ssnd;
>  int audio_stream_idx;
> -AVPacketList *pict_list;
> +AVPacketList *pict_list, *pict_list_end;
>  int write_id3v2;
>  int id3v2_version;
>  } AIFFOutputContext;
> @@ -215,9 +215,6 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket 
> *pkt)
>  if (pkt->stream_index == aiff->audio_stream_idx)
>  avio_write(pb, pkt->data, pkt->size);
>  else {
> -int ret;
> -AVPacketList *pict_list, *last;
> -
>  if (s->streams[pkt->stream_index]->codecpar->codec_type != 
> AVMEDIA_TYPE_VIDEO)
>  return 0;
>  
> @@ -229,24 +226,8 @@ static int aiff_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  if (s->streams[pkt->stream_index]->nb_frames >= 1)
>  return 0;
>  
> -pict_list = av_mallocz(sizeof(AVPacketList));
> -if (!pict_list)
> -return AVERROR(ENOMEM);
> -
> -ret = av_packet_ref(_list->pkt, pkt);
> -if (ret < 0) {
> -av_freep(_list);
> -return ret;
> -}
> -
> -if (!aiff->pict_list)
> -aiff->pict_list = pict_list;
> -else {
> -last = aiff->pict_list;
> -while (last->next)
> -last = last->next;
> -last->next = pict_list;
> -}
> +return ff_packet_list_put(>pict_list, >pict_list_end,
> +  pkt, FF_PACKETLIST_FLAG_REF_PACKET);
>  }
>  
>  return 0;
> @@ -257,7 +238,6 @@ static int aiff_write_trailer(AVFormatContext *s)
>  int ret;
>  AVIOContext *pb = s->pb;
>  AIFFOutputContext *aiff = s->priv_data;
> -AVPacketList *pict_list = aiff->pict_list;
>  AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar;
>  
>  /* Chunks sizes must be even */
> @@ -293,12 +273,7 @@ static int aiff_write_trailer(AVFormatContext *s)
>  avio_flush(pb);
>  }
>  
> -while (pict_list) {
> -AVPacketList *next = pict_list->next;
> -av_packet_unref(_list->pkt);
> -av_freep(_list);
> -pict_list = next;
> -}
> +ff_packet_list_free(>pict_list, >pict_list_end);
>  
>  return 0;
>  }
> -- 
> 2.21.0

LGTM.

Fate passes and patch tested with a few remux of aiff files containing
id3v2 tags + attached pics (ffmpeg -i input.aiff -write_id3v2 1
output.aiff).

Thanks.

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

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

Re: [FFmpeg-devel] [PATCH 3/3] avformat/aiffenc: Remove wrong and redundant check

2019-10-02 Thread Matthieu Bouron
On Wed, Oct 02, 2019 at 06:04:12AM +0200, Andreas Rheinhardt wrote:
> The check "if (!pb->seekable & AVIO_SEEKABLE_NORMAL)" is wrong, because
> ! has higher precendence than &. But it is also redundant, because this
> part of the code is only ever reached when the AVIO_SEEKABLE_NORMAL flag
> is set for pb. So simply remove the check.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/aiffenc.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
> index 0b837cd264..d09c9afb95 100644
> --- a/libavformat/aiffenc.c
> +++ b/libavformat/aiffenc.c
> @@ -49,9 +49,6 @@ static int put_id3v2_tags(AVFormatContext *s, 
> AIFFOutputContext *aiff)
>  AVIOContext *pb = s->pb;
>  AVPacketList *pict_list = aiff->pict_list;
>  
> -if (!pb->seekable & AVIO_SEEKABLE_NORMAL)
> -return 0;
> -
>  if (!s->metadata && !aiff->pict_list)
>  return 0;
>  
> -- 
> 2.21.0

LGTM.

-- 
Matthieu B.
___
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 11/14] avfilter/vf_crop: add logging context to log

2019-10-02 Thread Steven Liu
Reviewed-by: Paul B Mahol 
Signed-off-by: Steven Liu 
---
 libavfilter/vf_crop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
index 9fca7a7309..d6b4feb513 100644
--- a/libavfilter/vf_crop.c
+++ b/libavfilter/vf_crop.c
@@ -244,7 +244,7 @@ static int config_input(AVFilterLink *link)
 return 0;
 
 fail_expr:
-av_log(NULL, AV_LOG_ERROR, "Error when evaluating the expression '%s'\n", 
expr);
+av_log(ctx, AV_LOG_ERROR, "Error when evaluating the expression '%s'\n", 
expr);
 return ret;
 }
 
-- 
2.15.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 v2 08/14] avcodec/mpegvideo_enc: add logging context to log

2019-10-02 Thread Steven Liu
Reviewed-by: Paul B Mahol 
Signed-off-by: Steven Liu 
---
 libavcodec/mpegvideo_enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index ae3b131229..f12e603215 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -165,7 +165,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64],
 }
 }
 if (shift) {
-av_log(NULL, AV_LOG_INFO,
+av_log(s->avctx, AV_LOG_INFO,
"Warning, QMAT_SHIFT is larger than %d, overflows possible\n",
QMAT_SHIFT - shift);
 }
-- 
2.15.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 v2 10/14] avcodec/pngdec: add logging context to log

2019-10-02 Thread Steven Liu
Reviewed-by: Paul B Mahol 
Signed-off-by: Steven Liu 
---
 libavcodec/pngdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 2d6c1b218e..d37dabcc4d 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -424,7 +424,7 @@ static int png_decode_idat(PNGDecContext *s, int length)
 s->zstream.next_out  = s->crow_buf;
 }
 if (ret == Z_STREAM_END && s->zstream.avail_in > 0) {
-av_log(NULL, AV_LOG_WARNING,
+av_log(s->avctx, AV_LOG_WARNING,
"%d undecompressed bytes left in buffer\n", 
s->zstream.avail_in);
 return 0;
 }
-- 
2.15.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 v2 13/14] avfilter/boxblur: add logging context to log

2019-10-02 Thread Steven Liu
Reviewed-by: Paul B Mahol 
Signed-off-by: Steven Liu 
---
 libavfilter/boxblur.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/boxblur.c b/libavfilter/boxblur.c
index 4534b456d9..2287396f2e 100644
--- a/libavfilter/boxblur.c
+++ b/libavfilter/boxblur.c
@@ -91,7 +91,7 @@ int ff_boxblur_eval_filter_params(AVFilterLink *inlink,
  NULL, NULL, NULL, NULL, NULL, 0, ctx); \
 comp->radius = res; \
 if (ret < 0) {  \
-av_log(NULL, AV_LOG_ERROR,  \
+av_log(ctx, AV_LOG_ERROR,  \
"Error when evaluating " #comp " radius expression '%s'\n", 
expr); \
 return ret; \
 }
-- 
2.15.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 v2 02/14] avformat/udp: add logging context to log

2019-10-02 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/udp.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index cf73d331e0..f4ec148a2f 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -274,7 +274,7 @@ static int udp_set_multicast_sources(URLContext *h,
 }
 return 0;
 #else
-av_log(NULL, AV_LOG_ERROR,
+av_log(h, AV_LOG_ERROR,
"Setting multicast sources only supported for IPv4\n");
 return AVERROR(EINVAL);
 #endif
@@ -283,7 +283,7 @@ static int udp_set_multicast_sources(URLContext *h,
 for (i = 0; i < nb_sources; i++) {
 struct ip_mreq_source mreqs;
 if (sources[i].ss_family != AF_INET) {
-av_log(NULL, AV_LOG_ERROR, "Source/block address %d is of 
incorrect protocol family\n", i + 1);
+av_log(h, AV_LOG_ERROR, "Source/block address %d is of incorrect 
protocol family\n", i + 1);
 return AVERROR(EINVAL);
 }
 
@@ -298,9 +298,9 @@ static int udp_set_multicast_sources(URLContext *h,
include ? IP_ADD_SOURCE_MEMBERSHIP : IP_BLOCK_SOURCE,
(const void *), sizeof(mreqs)) < 0) {
 if (include)
-ff_log_net_error(NULL, AV_LOG_ERROR, 
"setsockopt(IP_ADD_SOURCE_MEMBERSHIP)");
+ff_log_net_error(h, AV_LOG_ERROR, 
"setsockopt(IP_ADD_SOURCE_MEMBERSHIP)");
 else
-ff_log_net_error(NULL, AV_LOG_ERROR, 
"setsockopt(IP_BLOCK_SOURCE)");
+ff_log_net_error(h, AV_LOG_ERROR, 
"setsockopt(IP_BLOCK_SOURCE)");
 return ff_neterrno();
 }
 }
-- 
2.15.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 v2 14/14] avfilter/vf_pad: add logging context to log

2019-10-02 Thread Steven Liu
Reviewed-by: Paul B Mahol 
Signed-off-by: Steven Liu 
---
 libavfilter/vf_pad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index ed155578e1..186d3f028d 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -210,7 +210,7 @@ static int config_input(AVFilterLink *inlink)
 return 0;
 
 eval_fail:
-av_log(NULL, AV_LOG_ERROR,
+av_log(ctx, AV_LOG_ERROR,
"Error when evaluating the expression '%s'\n", expr);
 return ret;
 
-- 
2.15.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 v2 01/14] avformat/hlsenc: add logging context to log

2019-10-02 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 1f2bdfbe4d..ac46a82704 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1305,7 +1305,7 @@ static int create_master_playlist(AVFormatContext *s,
 ret = hlsenc_io_open(s, >m3u8_out, temp_filename, );
 av_dict_free();
 if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Failed to open master play list file 
'%s'\n",
+av_log(s, AV_LOG_ERROR, "Failed to open master play list file '%s'\n",
 temp_filename);
 goto fail;
 }
@@ -1344,7 +1344,7 @@ static int create_master_playlist(AVFormatContext *s,
 
 m3u8_rel_name = get_relative_url(hls->master_m3u8_url, vs->m3u8_name);
 if (!m3u8_rel_name) {
-av_log(NULL, AV_LOG_ERROR, "Unable to find relative URL\n");
+av_log(s, AV_LOG_ERROR, "Unable to find relative URL\n");
 goto fail;
 }
 
@@ -1358,7 +1358,7 @@ static int create_master_playlist(AVFormatContext *s,
 }
 
 if (!vid_st && !aud_st) {
-av_log(NULL, AV_LOG_WARNING, "Media stream not found\n");
+av_log(s, AV_LOG_WARNING, "Media stream not found\n");
 continue;
 }
 
@@ -1399,7 +1399,7 @@ static int create_master_playlist(AVFormatContext *s,
 }
 }
 if (j == hls->nb_ccstreams)
-av_log(NULL, AV_LOG_WARNING, "mapping ccgroup %s not found\n",
+av_log(s, AV_LOG_WARNING, "mapping ccgroup %s not found\n",
 vs->ccgroup);
 }
 
-- 
2.15.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 v2 12/14] avfilter/vf_scale_qsv: add logging context to log

2019-10-02 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavfilter/vf_scale_qsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 3cc05b64f3..1cf5367969 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -541,7 +541,7 @@ static int qsvscale_config_props(AVFilterLink *outlink)
 return 0;
 
 fail:
-av_log(NULL, AV_LOG_ERROR,
+av_log(ctx, AV_LOG_ERROR,
"Error when evaluating the expression '%s'\n", expr);
 return ret;
 }
-- 
2.15.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 v2 06/14] avformat/mmst: add logging context to log

2019-10-02 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/mmst.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/libavformat/mmst.c b/libavformat/mmst.c
index a97c2e04a2..533cbe7698 100644
--- a/libavformat/mmst.c
+++ b/libavformat/mmst.c
@@ -141,7 +141,7 @@ static int send_command_packet(MMSTContext *mmst)
 // write it out.
 write_result= ffurl_write(mms->mms_hd, mms->out_buffer, exact_length);
 if(write_result != exact_length) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Failed to write data of length %d: %d (%s)\n",
exact_length, write_result,
write_result < 0 ? strerror(AVUNERROR(write_result)) :
@@ -215,11 +215,11 @@ static int send_media_file_request(MMSTContext *mmst)
 static void handle_packet_stream_changing_type(MMSTContext *mmst)
 {
 MMSContext *mms = >mms;
-av_log(NULL, AV_LOG_TRACE, "Stream changing!\n");
+av_log(mms->mms_hd, AV_LOG_TRACE, "Stream changing!\n");
 
 // 40 is the packet header size, 7 is the prefix size.
 mmst->header_packet_id= AV_RL32(mms->in_buffer + 40 + 7);
-av_log(NULL, AV_LOG_TRACE, "Changed header prefix to 0x%x", 
mmst->header_packet_id);
+av_log(mms->mms_hd, AV_LOG_TRACE, "Changed header prefix to 0x%x", 
mmst->header_packet_id);
 }
 
 static int send_keepalive_packet(MMSTContext *mmst)
@@ -251,12 +251,12 @@ static MMSSCPacketType 
get_tcp_server_response(MMSTContext *mmst)
 read_result = ffurl_read_complete(mms->mms_hd, mms->in_buffer, 8);
 if (read_result != 8) {
 if(read_result < 0) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Error reading packet header: %d (%s)\n",
read_result, strerror(AVUNERROR(read_result)));
 packet_type = SC_PKT_CANCEL;
 } else {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"The server closed the connection\n");
 packet_type = SC_PKT_NO_DATA;
 }
@@ -270,7 +270,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext 
*mmst)
 mmst->incoming_flags= mms->in_buffer[3];
 read_result= ffurl_read_complete(mms->mms_hd, mms->in_buffer+8, 4);
 if(read_result != 4) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Reading command packet length failed: %d (%s)\n",
read_result,
read_result < 0 ? strerror(AVUNERROR(read_result)) :
@@ -279,11 +279,11 @@ static MMSSCPacketType 
get_tcp_server_response(MMSTContext *mmst)
 }
 
 length_remaining= AV_RL32(mms->in_buffer+8) + 4;
-av_log(NULL, AV_LOG_TRACE, "Length remaining is %d\n", 
length_remaining);
+av_log(mms->mms_hd, AV_LOG_TRACE, "Length remaining is %d\n", 
length_remaining);
 // read the rest of the packet.
 if (length_remaining < 0
 || length_remaining > sizeof(mms->in_buffer) - 12) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Incoming packet length %d exceeds bufsize 
%"SIZE_SPECIFIER"\n",
length_remaining, sizeof(mms->in_buffer) - 12);
 return AVERROR_INVALIDDATA;
@@ -291,7 +291,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext 
*mmst)
 read_result = ffurl_read_complete(mms->mms_hd, mms->in_buffer + 12,
 length_remaining) ;
 if (read_result != length_remaining) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Reading pkt data (length=%d) failed: %d (%s)\n",
length_remaining, read_result,
read_result < 0 ? strerror(AVUNERROR(read_result)) :
@@ -300,7 +300,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext 
*mmst)
 }
 packet_type= AV_RL16(mms->in_buffer+36);
 if (read_result >= 44 && (hr = AV_RL32(mms->in_buffer + 40))) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Server sent a message with packet type 0x%x and error 
status code 0x%08x\n", packet_type, hr);
 return AVERROR(EINVAL);
 }
@@ -319,7 +319,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext 
*mmst)
 
 if (length_remaining < 0
 || length_remaining > sizeof(mms->in_buffer) - 8) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Data length %d is invalid or too large 
(max=%"SIZE_SPECIFIER")\n",

[FFmpeg-devel] [PATCH v2 03/14] avformat/rtmpptoto: add logging context to log

2019-10-02 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/rtmpproto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index b741e421af..eb08d4d424 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2386,7 +2386,7 @@ static int handle_metadata(RTMPContext *rt, RTMPPacket 
*pkt)
 next += size + 3 + 4;
 }
 if (p != rt->flv_data + rt->flv_size) {
-av_log(NULL, AV_LOG_WARNING, "Incomplete flv packets in "
+av_log(rt, AV_LOG_WARNING, "Incomplete flv packets in "
  "RTMP_PT_METADATA packet\n");
 rt->flv_size = p - rt->flv_data;
 }
-- 
2.15.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 v2 04/14] avformat/avidec: add logging context to log

2019-10-02 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/avidec.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index e3cd844169..1ca26968fa 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -117,8 +117,8 @@ static const AVMetadataConv avi_metadata_conv[] = {
 static int avi_load_index(AVFormatContext *s);
 static int guess_ni_flag(AVFormatContext *s);
 
-#define print_tag(str, tag, size)  \
-av_log(NULL, AV_LOG_TRACE, "pos:%"PRIX64" %s: tag=%s size=0x%x\n", \
+#define print_tag(s, str, tag, size)  \
+av_log(s, AV_LOG_TRACE, "pos:%"PRIX64" %s: tag=%s size=0x%x\n", \
avio_tell(pb), str, av_fourcc2str(tag), size)  \
 
 static inline int get_duration(AVIStream *ast, int len)
@@ -504,7 +504,7 @@ static int avi_read_header(AVFormatContext *s)
 tag  = avio_rl32(pb);
 size = avio_rl32(pb);
 
-print_tag("tag", tag, size);
+print_tag(s, "tag", tag, size);
 
 switch (tag) {
 case MKTAG('L', 'I', 'S', 'T'):
@@ -512,7 +512,7 @@ static int avi_read_header(AVFormatContext *s)
 /* Ignored, except at start of video packets. */
 tag1 = avio_rl32(pb);
 
-print_tag("list", tag1, 0);
+print_tag(s, "list", tag1, 0);
 
 if (tag1 == MKTAG('m', 'o', 'v', 'i')) {
 avi->movi_list = avio_tell(pb) - 4;
@@ -520,7 +520,7 @@ static int avi_read_header(AVFormatContext *s)
 avi->movi_end = avi->movi_list + size + (size & 1);
 else
 avi->movi_end = avi->fsize;
-av_log(NULL, AV_LOG_TRACE, "movi end=%"PRIx64"\n", 
avi->movi_end);
+av_log(s, AV_LOG_TRACE, "movi end=%"PRIx64"\n", avi->movi_end);
 goto end_of_header;
 } else if (tag1 == MKTAG('I', 'N', 'F', 'O'))
 ff_read_riff_info(s, size - 4);
@@ -584,7 +584,7 @@ static int avi_read_header(AVFormatContext *s)
 tag1 = stream_index ? MKTAG('a', 'u', 'd', 's')
 : MKTAG('v', 'i', 'd', 's');
 
-print_tag("strh", tag1, -1);
+print_tag(s, "strh", tag1, -1);
 
 if (tag1 == MKTAG('i', 'a', 'v', 's') ||
 tag1 == MKTAG('i', 'v', 'a', 's')) {
@@ -802,7 +802,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 ast->has_pal = 1;
 }
 
-print_tag("video", tag1, 0);
+print_tag(s, "video", tag1, 0);
 
 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
 st->codecpar->codec_tag  = tag1;
-- 
2.15.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 v2 07/14] avformat/mms: add logging context to log

2019-10-02 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/mms.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/mms.c b/libavformat/mms.c
index 768fda6525..16babc0954 100644
--- a/libavformat/mms.c
+++ b/libavformat/mms.c
@@ -60,7 +60,7 @@ int ff_mms_asf_header_parser(MMSContext *mms)
 
 if (mms->asf_header_size < sizeof(ff_asf_guid) * 2 + 22 ||
 memcmp(p, ff_asf_header, sizeof(ff_asf_guid))) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Corrupt stream (invalid ASF header, size=%d)\n",
mms->asf_header_size);
 return AVERROR_INVALIDDATA;
@@ -77,7 +77,7 @@ int ff_mms_asf_header_parser(MMSContext *mms)
 chunksize = AV_RL64(p + sizeof(ff_asf_guid));
 }
 if (!chunksize || chunksize > end - p) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Corrupt stream (header chunksize %"PRId64" is invalid)\n",
chunksize);
 return AVERROR_INVALIDDATA;
@@ -87,7 +87,7 @@ int ff_mms_asf_header_parser(MMSContext *mms)
 if (end - p > sizeof(ff_asf_guid) * 2 + 68) {
 mms->asf_packet_len = AV_RL32(p + sizeof(ff_asf_guid) * 2 + 
64);
 if (mms->asf_packet_len <= 0 || mms->asf_packet_len > 
sizeof(mms->in_buffer)) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Corrupt stream (too large pkt_len %d)\n",
mms->asf_packet_len);
 return AVERROR_INVALIDDATA;
@@ -110,7 +110,7 @@ int ff_mms_asf_header_parser(MMSContext *mms)
 mms->streams[mms->stream_num].id = stream_id;
 mms->stream_num++;
 } else {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Corrupt stream (too many A/V streams)\n");
 return AVERROR_INVALIDDATA;
 }
@@ -121,7 +121,7 @@ int ff_mms_asf_header_parser(MMSContext *mms)
 uint64_t skip_bytes = 88;
 while (stream_count--) {
 if (end - p < skip_bytes + 4) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Corrupt stream (next stream name length is not 
in the buffer)\n");
 return AVERROR_INVALIDDATA;
 }
@@ -129,14 +129,14 @@ int ff_mms_asf_header_parser(MMSContext *mms)
 }
 while (ext_len_count--) {
 if (end - p < skip_bytes + 22) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Corrupt stream (next extension system info 
length is not in the buffer)\n");
 return AVERROR_INVALIDDATA;
 }
 skip_bytes += 22 + AV_RL32(p + skip_bytes + 18);
 }
 if (end - p < skip_bytes) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
"Corrupt stream (the last extension system info 
length is invalid)\n");
 return AVERROR_INVALIDDATA;
 }
@@ -146,7 +146,7 @@ int ff_mms_asf_header_parser(MMSContext *mms)
 } else if (!memcmp(p, ff_asf_head1_guid, sizeof(ff_asf_guid))) {
 chunksize = 46; // see references [2] section 3.4. This should be 
set 46.
 if (chunksize > end - p) {
-av_log(NULL, AV_LOG_ERROR,
+av_log(mms->mms_hd, AV_LOG_ERROR,
 "Corrupt stream (header chunksize %"PRId64" is invalid)\n",
 chunksize);
 return AVERROR_INVALIDDATA;
-- 
2.15.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 v2 09/14] avcodec/videotoolbox: add logging context to log

2019-10-02 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavcodec/videotoolbox.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index e9b3370169..8773de3393 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -617,7 +617,7 @@ static void videotoolbox_decoder_callback(void *opaque,
 }
 
 if (!image_buffer) {
-av_log(NULL, AV_LOG_DEBUG, "vt decoder cb: output image buffer is 
null\n");
+av_log(avctx, AV_LOG_DEBUG, "vt decoder cb: output image buffer is 
null\n");
 return;
 }
 
-- 
2.15.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 v2 05/14] avformat/network: add logging context to log

2019-10-02 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/network.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/network.c b/libavformat/network.c
index 5664455d18..0f5a575f77 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -238,7 +238,7 @@ int ff_accept(int fd, int timeout, URLContext *h)
 if (ret < 0)
 return ff_neterrno();
 if (ff_socket_nonblock(ret, 1) < 0)
-av_log(NULL, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
+av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
 
 return ret;
 }
@@ -264,7 +264,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
 socklen_t optlen;
 
 if (ff_socket_nonblock(fd, 1) < 0)
-av_log(NULL, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
+av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
 
 while ((ret = connect(fd, addr, addrlen))) {
 ret = ff_neterrno();
-- 
2.15.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".