Re: [FFmpeg-devel] avcodec/proresenc_aw : improve speed by replacing PutBitContext for codeword encoding

2019-03-05 Thread Martin Vignali
Hello,

do i understand correctly that there is no check that prevents out of array
> writing ?
> not even an assert
> If thats the case, then i think this is unwise.
>
>
Thanks for testing.

For the buffer check, i can add a test (assert or error), before slice
plane encoding, in order to check if there is enough space in the dst
buffer for the "worst" slice plane target size.

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


Re: [FFmpeg-devel] [PATCH 2/5] libx264: Update ROI behaviour to match documentation

2019-03-05 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Tuesday, March 05, 2019 8:52 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 2/5] libx264: Update ROI behaviour to
> match documentation
> 
> On 28/02/2019 06:38, Guo, Yejun wrote:
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >> Of myp...@gmail.com
> >> Sent: Thursday, February 28, 2019 11:26 AM
> >> To: FFmpeg development discussions and patches  >> de...@ffmpeg.org>
> >> Subject: Re: [FFmpeg-devel] [PATCH 2/5] libx264: Update ROI behaviour
> to
> >> match documentation
> >>
> >> On Thu, Feb 28, 2019 at 10:53 AM Guo, Yejun 
> wrote:
>  -Original Message-
>  From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >> Behalf
>  Of Mark Thompson
>  Sent: Thursday, February 28, 2019 6:00 AM
>  To: ffmpeg-devel@ffmpeg.org
>  Subject: [FFmpeg-devel] [PATCH 2/5] libx264: Update ROI behaviour to
>  match documentation
> 
>  Fix the quantisation offset - use the whole range, and don't change the
>  offset size based on bit depth.
> 
>  Use correct bottom/right edge locations (they are offsets from
> >> bottom/right,
>  not from top/left).
> 
>  Iterate the list in reverse order.  The regions are in order of
> >> decreasing
>  importance, so the most important must be applied last.
>  ---
>   libavcodec/libx264.c | 50 -
> ---
>   1 file changed, 27 insertions(+), 23 deletions(-)
> 
>  diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
>  index a3493f393d..475719021e 100644
>  --- a/libavcodec/libx264.c
>  +++ b/libavcodec/libx264.c
>  @@ -285,16 +285,18 @@ static int X264_frame(AVCodecContext *ctx,
>  AVPacket *pkt, const AVFrame *frame,
>   int nnal, i, ret;
>   x264_picture_t pic_out = {0};
>   int pict_type;
>  +int bit_depth;
>   int64_t *out_opaque;
>   AVFrameSideData *sd;
> 
>   x264_picture_init( &x4->pic );
>   x4->pic.img.i_csp   = x4->params.i_csp;
>   #if X264_BUILD >= 153
>  -if (x4->params.i_bitdepth > 8)
>  +bit_depth = x4->params.i_bitdepth;
>   #else
>  -if (x264_bit_depth > 8)
>  +bit_depth = x264_bit_depth;
>   #endif
>  +if (bit_depth > 8)
>   x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
>   x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
> 
>  @@ -359,45 +361,47 @@ static int X264_frame(AVCodecContext *ctx,
>  AVPacket *pkt, const AVFrame *frame,
>   if (frame->interlaced_frame == 0) {
>   int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE;
>   int mby = (frame->height + MB_SIZE - 1) / MB_SIZE;
>  +int qp_range = 51 + 6 * (bit_depth - 8);
> >>>
> >>> just found following from "$ ./x264 --fullhelp", not sure what 81 means
> >> here. Shall we change our qoffset formula accordingly?
> >>>   --qpminSet min QP [0]
> >>>   --qpmaxSet max QP [81]
> 
> libx264 applies a fixed offset to the QP range to make it nonnegative (by
> adding QpBdOffsetY).  The maximum of 81 therefore corresponds to a bit
> depth of (81-51)/6+8 = 13 bits, the higher values only being valid at the 
> higher
> depths.
> 
> I guess that's set for a higher depth than libx264 actually supports to avoid
> any future problems with range (e.g. 12-bit support would not be an
> unreasonable feature).
> 

got it, thanks.

>   int nb_rois;
>  -AVRegionOfInterest* roi;
>  -float* qoffsets;
>  +const AVRegionOfInterest *roi;
>  +float *qoffsets;
>   qoffsets = av_mallocz_array(mbx * mby,
> >> sizeof(*qoffsets));
>   if (!qoffsets)
>   return AVERROR(ENOMEM);
> 
>  -nb_rois = sd->size / sizeof(AVRegionOfInterest);
>  -roi = (AVRegionOfInterest*)sd->data;
>  -for (int count = 0; count < nb_rois; count++) {
>  -int starty = FFMIN(mby, roi->top / MB_SIZE);
>  -int endy   = FFMIN(mby, (roi->bottom + MB_SIZE
> >> - 1)/ MB_SIZE);
>  -int startx = FFMIN(mbx, roi->left / MB_SIZE);
>  -int endx   = FFMIN(mbx, (roi->right + MB_SIZE
> >> - 1)/ MB_SIZE);
>  +roi = (const AVRegionOfInterest*)sd->data;
>  +if (!roi->self_size || sd->size % roi->self_size
> >> != 0) {
>  +av_log(ctx, AV_LOG_ERROR, "Invalid
>  AVRegionOfInterest.self_size.\n");
>  + 

[FFmpeg-devel] [PATCH 0/1] avformat/dashenc: Added #EXT-X-PROGRAM-DATE-TIME to HLS playlists

2019-03-05 Thread joepadmiraal
This is the third attempt for a patch that adds the #EXT-X-PROGRAM-DATE-TIME 
tag to HLS playlists when using the Dash muxer.
Thanks for reviewing the previous patches.
I used both a _ms and a _s variable to be in line with format_date_now().
However this is redundant in my use case so I changed it.
Also removed the duration variable.

joepadmiraal (1):
  avformat/dashenc: Added #EXT-X-PROGRAM-DATE-TIME to HLS playlists

 libavformat/dashenc.c | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

--
2.17.0

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


[FFmpeg-devel] [PATCH 1/1] avformat/dashenc: Added #EXT-X-PROGRAM-DATE-TIME to HLS playlists

2019-03-05 Thread joepadmiraal
---
 libavformat/dashenc.c | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index c5e882f4ae..6bcdc9ba36 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -61,6 +61,7 @@ typedef struct Segment {
 int64_t start_pos;
 int range_length, index_length;
 int64_t time;
+double prog_date_time;
 int64_t duration;
 int n;
 } Segment;
@@ -122,6 +123,7 @@ typedef struct DASHContext {
 int64_t last_duration;
 int64_t total_duration;
 char availability_start_time[100];
+time_t start_time_s;
 char dirname[1024];
 const char *single_file_name;  /* file names as specified in options */
 const char *init_seg_name;
@@ -433,6 +435,7 @@ static void write_hls_media_playlist(OutputStream *os, 
AVFormatContext *s,
 const char *proto = avio_find_protocol_name(c->dirname);
 int use_rename = proto && !strcmp(proto, "file");
 int i, start_index, start_number;
+double prog_date_time = 0;
 
 get_start_index_number(os, c, &start_index, &start_number);
 
@@ -467,11 +470,20 @@ static void write_hls_media_playlist(OutputStream *os, 
AVFormatContext *s,
 
 for (i = start_index; i < os->nb_segments; i++) {
 Segment *seg = os->segments[i];
+
+if (prog_date_time == 0) {
+if (os->nb_segments == 1)
+prog_date_time = c->start_time_s;
+else
+prog_date_time = seg->prog_date_time;
+}
+seg->prog_date_time = prog_date_time;
+
 ret = ff_hls_write_file_entry(c->m3u8_out, 0, c->single_file,
 (double) seg->duration / timescale, 0,
 seg->range_length, seg->start_pos, NULL,
 c->single_file ? os->initfile : seg->file,
-NULL);
+&prog_date_time);
 if (ret < 0) {
 av_log(os->ctx, AV_LOG_WARNING, "ff_hls_write_file_entry get 
error\n");
 }
@@ -1592,9 +1604,13 @@ static int dash_write_packet(AVFormatContext *s, 
AVPacket *pkt)
 os->first_pts = pkt->pts;
 os->last_pts = pkt->pts;
 
-if (!c->availability_start_time[0])
+if (!c->availability_start_time[0]) {
+int64_t start_time_us = av_gettime();
+int64_t start_time_ms = start_time_us / 1000;
+c->start_time_s = start_time_ms / 1000;
 format_date_now(c->availability_start_time,
 sizeof(c->availability_start_time));
+}
 
 if (!os->availability_time_offset && pkt->duration) {
 int64_t frame_duration = av_rescale_q(pkt->duration, st->time_base,
-- 
2.17.0

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


[FFmpeg-devel] [PATCH] avformat/mov: fix hang while seek on a kind of fragmented mp4.

2019-03-05 Thread Charles Liu
1. organize fragmented information according to the tracks.
2. do NOT skip the last boxes of fragmented info.

ticket #7572

Signed-off-by: Charles Liu 
---
 libavformat/isom.h |  10 +-
 libavformat/mov.c  | 378 +
 2 files changed, 185 insertions(+), 203 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 69452cae8e..eea8fa4e8f 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -125,7 +125,7 @@ typedef struct MOVEncryptionIndex {
 } MOVEncryptionIndex;
 
 typedef struct MOVFragmentStreamInfo {
-int id;
+unsigned stsd_id;
 int64_t sidx_pts;
 int64_t first_tfra_pts;
 int64_t tfdt_dts;
@@ -136,14 +136,13 @@ typedef struct MOVFragmentStreamInfo {
 typedef struct MOVFragmentIndexItem {
 int64_t moof_offset;
 int headers_read;
-int current;
-int nb_stream_info;
-MOVFragmentStreamInfo * stream_info;
+MOVFragmentStreamInfo stream_info;
 } MOVFragmentIndexItem;
 
 typedef struct MOVFragmentIndex {
 int allocated_size;
 int complete;
+int id;  // track id
 int current;
 int nb_items;
 MOVFragmentIndexItem * item;
@@ -274,7 +273,8 @@ typedef struct MOVContext {
 int moov_retry;
 int use_mfra_for;
 int has_looked_for_mfra;
-MOVFragmentIndex frag_index;
+unsigned nb_frag_indices;
+MOVFragmentIndex *frag_indices;
 int atom_depth;
 unsigned int aax_mode;  ///< 'aax' file has been detected
 uint8_t file_key[20];
diff --git a/libavformat/mov.c b/libavformat/mov.c
index a7d444b0ee..b150710a40 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1153,59 +1153,29 @@ static int mov_read_moov(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return 0; /* now go for mdat */
 }
 
-static MOVFragmentStreamInfo * get_frag_stream_info(
-MOVFragmentIndex *frag_index,
-int index,
-int id)
+static MOVFragmentIndex *mov_find_frag_index(MOVFragmentIndex *frag_indices, 
int nb_frag_indices, int track_id)
 {
-int i;
-MOVFragmentIndexItem * item;
+unsigned i;
+MOVFragmentIndex *frag_index = NULL;
 
-if (index < 0 || index >= frag_index->nb_items)
-return NULL;
-item = &frag_index->item[index];
-for (i = 0; i < item->nb_stream_info; i++)
-if (item->stream_info[i].id == id)
-return &item->stream_info[i];
+for (i = 0; i < nb_frag_indices; i++)
+if (frag_indices[i].id == track_id)
+frag_index = &frag_indices[i];
 
-// This shouldn't happen
-return NULL;
+return frag_index;
 }
 
-static void set_frag_stream(MOVFragmentIndex *frag_index, int id)
+static MOVFragmentStreamInfo *get_current_frag_stream_info(MOVContext *c, int 
id)
 {
-int i;
-MOVFragmentIndexItem * item;
+MOVFragmentIndex *frag_index = NULL;
 
-if (frag_index->current < 0 ||
-frag_index->current >= frag_index->nb_items)
-return;
-
-item = &frag_index->item[frag_index->current];
-for (i = 0; i < item->nb_stream_info; i++)
-if (item->stream_info[i].id == id) {
-item->current = i;
-return;
-}
-
-// id not found.  This shouldn't happen.
-item->current = -1;
-}
-
-static MOVFragmentStreamInfo * get_current_frag_stream_info(
-MOVFragmentIndex *frag_index)
-{
-MOVFragmentIndexItem *item;
-if (frag_index->current < 0 ||
+frag_index = mov_find_frag_index(c->frag_indices, c->nb_frag_indices, id);
+if (!frag_index ||
+frag_index->current < 0 ||
 frag_index->current >= frag_index->nb_items)
 return NULL;
 
-item = &frag_index->item[frag_index->current];
-if (item->current >= 0 && item->current < item->nb_stream_info)
-return &item->stream_info[item->current];
-
-// This shouldn't happen
-return NULL;
+return &frag_index->item[frag_index->current].stream_info;
 }
 
 static int search_frag_moof_offset(MOVFragmentIndex *frag_index, int64_t 
offset)
@@ -1232,9 +1202,9 @@ static int search_frag_moof_offset(MOVFragmentIndex 
*frag_index, int64_t offset)
 return b;
 }
 
-static int64_t get_stream_info_time(MOVFragmentStreamInfo * frag_stream_info)
-{
-av_assert0(frag_stream_info);
+static int64_t get_frag_time(MOVFragmentIndex *frag_index,
+ int index, int track_id) {
+MOVFragmentStreamInfo *frag_stream_info = 
&frag_index->item[index].stream_info;
 if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE)
 return frag_stream_info->sidx_pts;
 if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE)
@@ -1242,31 +1212,9 @@ static int64_t 
get_stream_info_time(MOVFragmentStreamInfo * frag_stream_info)
 return frag_stream_info->tfdt_dts;
 }
 
-static int64_t get_frag_time(MOVFragmentIndex *frag_index,
- int index, int track_id)
-{
-MOVFragmentStreamInfo * frag_stream_info;
-int64_t timestamp;
-int i;
-
-if (track_id >= 0) {
-frag_stream_info = get_frag_stream_inf

Re: [FFmpeg-devel] [PATCH] avformat/mov: fix hang while seek on a kind of fragmented mp4.

2019-03-05 Thread C.H.Liu
Thanks for your reply.
If a track id of the test clip does not appear in its ‘moov’, the do/while
loop cannot exit indeed.

The purpose of this patch is to solve AV_NOPTS_VALUE in the fragment info
structure. Because the original structures is oriented to ‘moof’ boxes in
file. I tried to organize fragment info according to media tracks.

Since the fragment structures has been changed, it fixes two other issues.
One is  #7572, which missed the last ‘sidx’ and ‘moof’.
The other is “mov->fragment.stsd_id == 1” in function cenc_filter().  Mov
muxer read all ‘moof’ while reading header. So the current fragment points
to the last ‘moof’. When we read packets/samples from the beginning, the
sample (belongs to the first ‘moof’) and the current fragment info do not
match.

I don’t mind waiting for other options. And we already have a quick fix
aa25198f1b925a464bdfa83a98476f. Though, I will still update the patch to
resolve the endless loop problem.

BTW, I have’t modified other commit messages. The frag index variable is
changed in isom.h.

Thanks again, and sorry for late response.

Regards,
Charles.

On Wed, Feb 27, 2019 at 9:39 PM Michael Niedermayer 
wrote:

> On Mon, Feb 25, 2019 at 07:07:27PM +0800, C.H.Liu wrote:
> >  Would you mind share your input file? I still can’t reproduce the OOM.
>
> i belive i cannot share this sample, but the patch really needs to be
> fully reviewed not just one bug that was found by chance fixed otherwise
> we might be missing other bugs ...
>
>
> >
> >
> > I have tried several types of mp4.
> >
> > I also tried to create a file like yours. According to the snapshot,
> seems
> > it has no ‘sidx’ box and enable ‘use_mfra_for’.
> >
> > Massif didn’t report update_frag_index() function. I didn’t see an extra
> > heap as big as here, either.
>
> looking at the sample that triggers the OOM the do/while loop you add
> to update_frag_index() is entered and never exits while doing allocations
> in it.
>
> also the patch as is is not ok. You for example have a list of unrelated
> changes in the commit message. Each should be in its own patch
> also changes that are functional should be splited from non functional
> changes. For example here:
>
>  // If moof_offset already exists in frag_index, return index to it
> -index = search_frag_moof_offset(&c->frag_index, offset);
> -if (index < c->frag_index.nb_items &&
> -c->frag_index.item[index].moof_offset == offset)
> +index = search_frag_moof_offset(frag_index, offset);
> +if (index < frag_index->nb_items &&
> +frag_index->item[index].moof_offset == offset) {
> +frag_index->current = index;
>  return index;
> +}
>
> you change frag_index to a local variable this is non functional and
> should not be in a patch that does a functional change ideally.
> Now sure if a functional change is trivial and clear such things are
> sometimes done together but this patch is not clear, at least its not
> clear to me ...
>
> thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> I do not agree with what you have to say, but I'll defend to the death your
> right to say it. -- Voltaire
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mov: fix hang while seek on a kind of fragmented mp4.

2019-03-05 Thread Carl Eugen Hoyos
2019-03-05 17:02 GMT+01:00, Charles Liu :
> 1. organize fragmented information according to the tracks.
> 2. do NOT skip the last boxes of fragmented info.

> ticket #7572

Assuming the ticket is not reproducible for you with current
FFmpeg git head (it wasn't for me two weeks ago), please
reword this so it is clear you saw an issue looking at this
ticket (and its fix) but that this commit does not fix a bug
that is still reproducible with the files and command line(s)
provided there.

Or do I misunderstand?

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


Re: [FFmpeg-devel] [PATCH] avformat/mpegts.c: reduce buffering during initialization

2019-03-05 Thread Marton Balint



On Mon, 4 Mar 2019, andriy.gel...@gmail.com wrote:


From: Andriy Gelman 

Reduces buffering during estimation of mpegts raw_packet_size
parameter. Instead of buffering a fixed 8192 bytes, calculate
probe scores on a smaller buffer. Increase buffer size until
probe score is greater than minimum value.


What is the issue that you are seeing and that this patch fix? Is it only 
matters for low bitrate mpegts? (like 64 kbps streams?) Or does this 
improve high bitrate streams as well somehow?


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


Re: [FFmpeg-devel] [PATCH] avcodec/imm4: add support for mid-stream size changes

2019-03-05 Thread Paul B Mahol
On 3/1/19, Paul B Mahol  wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/imm4.c | 27 +++
>  1 file changed, 15 insertions(+), 12 deletions(-)
>

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


[FFmpeg-devel] [PATCH] libdav1d: Add support for reading hdr10 metadata

2019-03-05 Thread Vittorio Giovara
---
 configure |  2 +-
 libavcodec/libdav1d.c | 30 +-
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index dcead3a300..a5cef4bc09 100755
--- a/configure
+++ b/configure
@@ -6142,7 +6142,7 @@ enabled libcelt   && require libcelt celt/celt.h 
celt_decode -lcelt0 &&
die "ERROR: libcelt must be installed and 
version must be >= 0.11.0."; }
 enabled libcaca   && require_pkg_config libcaca caca caca.h 
caca_create_canvas
 enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create 
-lcodec2
-enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.1.0" 
"dav1d/dav1d.h" dav1d_version
+enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.2.0" 
"dav1d/dav1d.h" dav1d_version
 enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index ed02da4ebf..355dd184f4 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -22,6 +22,7 @@
 #include 
 
 #include "libavutil/avassert.h"
+#include "libavutil/mastering_display_metadata.h"
 #include "libavutil/opt.h"
 
 #include "avcodec.h"
@@ -90,7 +91,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame 
*frame)
 Libdav1dContext *dav1d = c->priv_data;
 Dav1dData *data = &dav1d->data;
 Dav1dPicture *p;
-int res;
+int i, res;
 
 if (!data->sz) {
 AVPacket pkt = { 0 };
@@ -206,6 +207,33 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return AVERROR_INVALIDDATA;
 }
 
+if (p->mastering_display) {
+AVMasteringDisplayMetadata *mastering = 
av_mastering_display_metadata_create_side_data(frame);
+if (!mastering)
+return AVERROR(ENOMEM);
+
+for (i = 0; i < 3; i++) {
+mastering->display_primaries[i][0] = 
av_make_q(p->mastering_display->primaries[i][0], 1 << 16);
+mastering->display_primaries[i][1] = 
av_make_q(p->mastering_display->primaries[i][1], 1 << 16);
+}
+mastering->white_point[0] = 
av_make_q(p->mastering_display->white_point[0], 1 << 16);
+mastering->white_point[1] = 
av_make_q(p->mastering_display->white_point[1], 1 << 16);
+
+mastering->max_luminance = 
av_make_q(p->mastering_display->max_luminance, 1 << 8);
+mastering->min_luminance = 
av_make_q(p->mastering_display->min_luminance, 1 << 14);
+
+mastering->has_primaries = 1;
+mastering->has_luminance = 1;
+}
+if (p->content_light) {
+AVContentLightMetadata *light = 
av_content_light_metadata_create_side_data(frame);
+if (!light)
+return AVERROR(ENOMEM);
+
+light->MaxCLL = p->content_light->max_content_light_level;
+light->MaxFALL = p->content_light->max_frame_average_light_level;
+}
+
 return 0;
 }
 
-- 
2.20.1

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


Re: [FFmpeg-devel] [PATCH v6 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper.

2019-03-05 Thread Vittorio Giovara
On Tue, Mar 5, 2019 at 1:45 AM Jing SUN  wrote:

> From: Jing Sun 
>
> base on patch by Huang, Zhengxu from https://github.com/intel/SVT-HEVC
>
> V4: - Fix the build error with new API in PR#52
> - Fix the encoding hang issue by API change in PR#52
> - Fix the last frame dropping issue
> - Fix the invalid parameter causing segmentation fault issue
> - Add the support to svt hevc and av1 plugins coexistance
> - Add the VMAF optimized mode to "-tune"
> - Add the "-hdr" parameter
>

Is there any way to preserve the color matrix/primary/transfer properties
during encoding?
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/libdav1d: route dav1d internal logs through av_log()

2019-03-05 Thread Vittorio Giovara
On Mon, Mar 4, 2019 at 4:08 PM James Almer  wrote:

> Bump the minimum required version to the first one with the logger API
> callback.
>
> Signed-off-by: James Almer 
> ---
>  configure | 2 +-
>  libavcodec/libdav1d.c | 9 +
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index dcead3a300..a5cef4bc09 100755
> --- a/configure
> +++ b/configure
> @@ -6142,7 +6142,7 @@ enabled libcelt   && require libcelt
> celt/celt.h celt_decode -lcelt0 &&
> die "ERROR: libcelt must be installed and
> version must be >= 0.11.0."; }
>  enabled libcaca   && require_pkg_config libcaca caca caca.h
> caca_create_canvas
>  enabled libcodec2 && require libcodec2 codec2/codec2.h
> codec2_create -lcodec2
> -enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.1.0"
> "dav1d/dav1d.h" dav1d_version
> +enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.2.0"
> "dav1d/dav1d.h" dav1d_version
>  enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0"
> davs2.h davs2_decoder_open
>  enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2
> dc1394/dc1394.h dc1394_new
>  enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h
> drmGetVersion
> diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
> index ed02da4ebf..459bbae687 100644
> --- a/libavcodec/libdav1d.c
> +++ b/libavcodec/libdav1d.c
> @@ -37,6 +37,13 @@ typedef struct Libdav1dContext {
>  int apply_grain;
>  } Libdav1dContext;
>
> +static void libdav1d_log_callback(void *opaque, const char *fmt, va_list
> vl)
> +{
> +AVCodecContext *c = opaque;
> +
> +av_vlog(c, AV_LOG_ERROR, fmt, vl);
> +}
> +
>  static av_cold int libdav1d_init(AVCodecContext *c)
>  {
>  Libdav1dContext *dav1d = c->priv_data;
> @@ -46,6 +53,8 @@ static av_cold int libdav1d_init(AVCodecContext *c)
>  av_log(c, AV_LOG_INFO, "libdav1d %s\n", dav1d_version());
>
>  dav1d_default_settings(&s);
> +s.logger.cookie = c;
> +s.logger.callback = libdav1d_log_callback;
>  s.n_tile_threads = dav1d->tile_threads;
>  s.apply_grain = dav1d->apply_grain;
>  s.n_frame_threads = FFMIN(c->thread_count ? c->thread_count :
> av_cpu_count(), DAV1D_MAX_FRAME_THREADS);
> --
> 2.21.0
>

set seems good to me
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/libdav1d: use a custom picture allocator

2019-03-05 Thread Vittorio Giovara
On Mon, Mar 4, 2019 at 4:08 PM James Almer  wrote:

> Replaces the libdav1d internal allocator. It uses an AVBufferPool to
> reduce the
> amount of allocated buffers.
> About 5% speed up when decoding 720p or higher streams.
>
> Signed-off-by: James Almer 
> ---
> get_buffer2() can't be used for this decoder, as there's no guarantee the
> buffers
> it returns will respect the constrains specified by libdav1d.
>
>  libavcodec/libdav1d.c | 72 ++-
>  1 file changed, 65 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
> index 459bbae687..855c27db7f 100644
> --- a/libavcodec/libdav1d.c
> +++ b/libavcodec/libdav1d.c
> @@ -22,6 +22,7 @@
>  #include 
>
>  #include "libavutil/avassert.h"
> +#include "libavutil/imgutils.h"
>  #include "libavutil/opt.h"
>
>  #include "avcodec.h"
> @@ -31,12 +32,21 @@
>  typedef struct Libdav1dContext {
>  AVClass *class;
>  Dav1dContext *c;
> +AVBufferPool *pool;
> +int pool_size;
>
>  Dav1dData data;
>  int tile_threads;
>  int apply_grain;
>  } Libdav1dContext;
>
> +static const enum AVPixelFormat pix_fmt[][3] = {
> +[DAV1D_PIXEL_LAYOUT_I400] = { AV_PIX_FMT_GRAY8,   AV_PIX_FMT_GRAY10,
>   AV_PIX_FMT_GRAY12 },
> +[DAV1D_PIXEL_LAYOUT_I420] = { AV_PIX_FMT_YUV420P,
> AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV420P12 },
> +[DAV1D_PIXEL_LAYOUT_I422] = { AV_PIX_FMT_YUV422P,
> AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P12 },
> +[DAV1D_PIXEL_LAYOUT_I444] = { AV_PIX_FMT_YUV444P,
> AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV444P12 },
> +};
> +
>  static void libdav1d_log_callback(void *opaque, const char *fmt, va_list
> vl)
>  {
>  AVCodecContext *c = opaque;
> @@ -44,6 +54,57 @@ static void libdav1d_log_callback(void *opaque, const
> char *fmt, va_list vl)
>  av_vlog(c, AV_LOG_ERROR, fmt, vl);
>  }
>
> +static int libdav1d_picture_allocator(Dav1dPicture *p, void *cookie) {
> +Libdav1dContext *dav1d = cookie;
> +enum AVPixelFormat format = pix_fmt[p->p.layout][p->seq_hdr->hbd];
> +int ret, linesize[4], h = FFALIGN(p->p.h, 128);
> +uint8_t *aligned_ptr, *data[4];
> +AVBufferRef *buf;
> +
> +ret = av_image_fill_arrays(data, linesize, NULL, format,
> FFALIGN(p->p.w, 128),
> +   h, DAV1D_PICTURE_ALIGNMENT);
> +if (ret < 0)
> +return ret;
> +
> +if (ret != dav1d->pool_size) {
> +av_buffer_pool_uninit(&dav1d->pool);
> +// Use twice the amount of required padding bytes for aligned_ptr
> below.
> +dav1d->pool = av_buffer_pool_init(ret + DAV1D_PICTURE_ALIGNMENT *
> 2, NULL);
> +if (!dav1d->pool)
> +return -ENOMEM;
>

AVERROR(ENOMEM) ?

+dav1d->pool_size = ret;
> +}
> +buf = av_buffer_pool_get(dav1d->pool);
> +if (!buf)
> +return -ENOMEM;
> +
> +// libdav1d requires DAV1D_PICTURE_ALIGNMENT aligned buffers, which
> av_malloc()
> +// doesn't guarantee for example when AVX is disabled at configure
> time.
> +// Use the extra DAV1D_PICTURE_ALIGNMENT padding bytes in the buffer
> to align it
> +// if required.
> +aligned_ptr = (uint8_t *)FFALIGN((uintptr_t)buf->data,
> DAV1D_PICTURE_ALIGNMENT);
> +ret = av_image_fill_pointers(data, format, h, aligned_ptr, linesize);
> +if (ret < 0) {
> +av_buffer_unref(&buf);
> +return ret;
> +}
> +
> +p->data[0] = data[0];
> +p->data[1] = data[1];
> +p->data[2] = data[2];
> +p->stride[0] = linesize[0];
> +p->stride[1] = linesize[1];
> +p->allocator_data = buf;
> +
> +return 0;
> +}
> +
> +static void libdav1d_picture_release(Dav1dPicture *p, void *cookie) {
> +AVBufferRef *buf = p->allocator_data;
> +
> +av_buffer_unref(&buf);
> +}
>

nit: keep { on a new line for functions

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


Re: [FFmpeg-devel] [PATCH] libdav1d: Add support for reading hdr10 metadata

2019-03-05 Thread James Almer
On 3/5/2019 3:19 PM, Vittorio Giovara wrote:
> ---
>  configure |  2 +-
>  libavcodec/libdav1d.c | 30 +-
>  2 files changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index dcead3a300..a5cef4bc09 100755
> --- a/configure
> +++ b/configure
> @@ -6142,7 +6142,7 @@ enabled libcelt   && require libcelt 
> celt/celt.h celt_decode -lcelt0 &&
> die "ERROR: libcelt must be installed and 
> version must be >= 0.11.0."; }
>  enabled libcaca   && require_pkg_config libcaca caca caca.h 
> caca_create_canvas
>  enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create 
> -lcodec2
> -enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.1.0" 
> "dav1d/dav1d.h" dav1d_version
> +enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.2.0" 
> "dav1d/dav1d.h" dav1d_version
>  enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
> davs2.h davs2_decoder_open
>  enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
> dc1394/dc1394.h dc1394_new
>  enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h 
> drmGetVersion
> diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
> index ed02da4ebf..355dd184f4 100644
> --- a/libavcodec/libdav1d.c
> +++ b/libavcodec/libdav1d.c
> @@ -22,6 +22,7 @@
>  #include 
>  
>  #include "libavutil/avassert.h"
> +#include "libavutil/mastering_display_metadata.h"
>  #include "libavutil/opt.h"
>  
>  #include "avcodec.h"
> @@ -90,7 +91,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, 
> AVFrame *frame)
>  Libdav1dContext *dav1d = c->priv_data;
>  Dav1dData *data = &dav1d->data;
>  Dav1dPicture *p;
> -int res;
> +int i, res;

No need for such a broad scope for i.

>  
>  if (!data->sz) {
>  AVPacket pkt = { 0 };
> @@ -206,6 +207,33 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  return AVERROR_INVALIDDATA;
>  }
>  
> +if (p->mastering_display) {
> +AVMasteringDisplayMetadata *mastering = 
> av_mastering_display_metadata_create_side_data(frame);
> +if (!mastering)
> +return AVERROR(ENOMEM);
> +
> +for (i = 0; i < 3; i++) {

for (int i = 0,...)

> +mastering->display_primaries[i][0] = 
> av_make_q(p->mastering_display->primaries[i][0], 1 << 16);
> +mastering->display_primaries[i][1] = 
> av_make_q(p->mastering_display->primaries[i][1], 1 << 16);
> +}
> +mastering->white_point[0] = 
> av_make_q(p->mastering_display->white_point[0], 1 << 16);
> +mastering->white_point[1] = 
> av_make_q(p->mastering_display->white_point[1], 1 << 16);
> +
> +mastering->max_luminance = 
> av_make_q(p->mastering_display->max_luminance, 1 << 8);
> +mastering->min_luminance = 
> av_make_q(p->mastering_display->min_luminance, 1 << 14);
> +
> +mastering->has_primaries = 1;
> +mastering->has_luminance = 1;
> +}
> +if (p->content_light) {
> +AVContentLightMetadata *light = 
> av_content_light_metadata_create_side_data(frame);
> +if (!light)
> +return AVERROR(ENOMEM);
> +
> +light->MaxCLL = p->content_light->max_content_light_level;
> +light->MaxFALL = p->content_light->max_frame_average_light_level;
> +}
> +
>  return 0;
>  }

LGTM aside from the above nit.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/libdav1d: use a custom picture allocator

2019-03-05 Thread James Almer
On 3/5/2019 3:19 PM, Vittorio Giovara wrote:
> On Mon, Mar 4, 2019 at 4:08 PM James Almer  wrote:
> 
>> Replaces the libdav1d internal allocator. It uses an AVBufferPool to
>> reduce the
>> amount of allocated buffers.
>> About 5% speed up when decoding 720p or higher streams.
>>
>> Signed-off-by: James Almer 
>> ---
>> get_buffer2() can't be used for this decoder, as there's no guarantee the
>> buffers
>> it returns will respect the constrains specified by libdav1d.
>>
>>  libavcodec/libdav1d.c | 72 ++-
>>  1 file changed, 65 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
>> index 459bbae687..855c27db7f 100644
>> --- a/libavcodec/libdav1d.c
>> +++ b/libavcodec/libdav1d.c
>> @@ -22,6 +22,7 @@
>>  #include 
>>
>>  #include "libavutil/avassert.h"
>> +#include "libavutil/imgutils.h"
>>  #include "libavutil/opt.h"
>>
>>  #include "avcodec.h"
>> @@ -31,12 +32,21 @@
>>  typedef struct Libdav1dContext {
>>  AVClass *class;
>>  Dav1dContext *c;
>> +AVBufferPool *pool;
>> +int pool_size;
>>
>>  Dav1dData data;
>>  int tile_threads;
>>  int apply_grain;
>>  } Libdav1dContext;
>>
>> +static const enum AVPixelFormat pix_fmt[][3] = {
>> +[DAV1D_PIXEL_LAYOUT_I400] = { AV_PIX_FMT_GRAY8,   AV_PIX_FMT_GRAY10,
>>   AV_PIX_FMT_GRAY12 },
>> +[DAV1D_PIXEL_LAYOUT_I420] = { AV_PIX_FMT_YUV420P,
>> AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV420P12 },
>> +[DAV1D_PIXEL_LAYOUT_I422] = { AV_PIX_FMT_YUV422P,
>> AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P12 },
>> +[DAV1D_PIXEL_LAYOUT_I444] = { AV_PIX_FMT_YUV444P,
>> AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV444P12 },
>> +};
>> +
>>  static void libdav1d_log_callback(void *opaque, const char *fmt, va_list
>> vl)
>>  {
>>  AVCodecContext *c = opaque;
>> @@ -44,6 +54,57 @@ static void libdav1d_log_callback(void *opaque, const
>> char *fmt, va_list vl)
>>  av_vlog(c, AV_LOG_ERROR, fmt, vl);
>>  }
>>
>> +static int libdav1d_picture_allocator(Dav1dPicture *p, void *cookie) {
>> +Libdav1dContext *dav1d = cookie;
>> +enum AVPixelFormat format = pix_fmt[p->p.layout][p->seq_hdr->hbd];
>> +int ret, linesize[4], h = FFALIGN(p->p.h, 128);
>> +uint8_t *aligned_ptr, *data[4];
>> +AVBufferRef *buf;
>> +
>> +ret = av_image_fill_arrays(data, linesize, NULL, format,
>> FFALIGN(p->p.w, 128),
>> +   h, DAV1D_PICTURE_ALIGNMENT);
>> +if (ret < 0)
>> +return ret;
>> +
>> +if (ret != dav1d->pool_size) {
>> +av_buffer_pool_uninit(&dav1d->pool);
>> +// Use twice the amount of required padding bytes for aligned_ptr
>> below.
>> +dav1d->pool = av_buffer_pool_init(ret + DAV1D_PICTURE_ALIGNMENT *
>> 2, NULL);
>> +if (!dav1d->pool)
>> +return -ENOMEM;
>>
> 
> AVERROR(ENOMEM) ?

AVERROR(x) will expand to -x on every target libdav1d supports, so
there's no difference. And since this is a callback function, i figured
following the doxy to the letter was proper.

I can replace it if you prefer in any case.

> 
> +dav1d->pool_size = ret;
>> +}
>> +buf = av_buffer_pool_get(dav1d->pool);
>> +if (!buf)
>> +return -ENOMEM;
>> +
>> +// libdav1d requires DAV1D_PICTURE_ALIGNMENT aligned buffers, which
>> av_malloc()
>> +// doesn't guarantee for example when AVX is disabled at configure
>> time.
>> +// Use the extra DAV1D_PICTURE_ALIGNMENT padding bytes in the buffer
>> to align it
>> +// if required.
>> +aligned_ptr = (uint8_t *)FFALIGN((uintptr_t)buf->data,
>> DAV1D_PICTURE_ALIGNMENT);
>> +ret = av_image_fill_pointers(data, format, h, aligned_ptr, linesize);
>> +if (ret < 0) {
>> +av_buffer_unref(&buf);
>> +return ret;
>> +}
>> +
>> +p->data[0] = data[0];
>> +p->data[1] = data[1];
>> +p->data[2] = data[2];
>> +p->stride[0] = linesize[0];
>> +p->stride[1] = linesize[1];
>> +p->allocator_data = buf;
>> +
>> +return 0;
>> +}
>> +
>> +static void libdav1d_picture_release(Dav1dPicture *p, void *cookie) {
>> +AVBufferRef *buf = p->allocator_data;
>> +
>> +av_buffer_unref(&buf);
>> +}
>>
> 
> nit: keep { on a new line for functions

Fixed locally. And i see a couple others that also need to be changed in
a separate commit.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mov: fix hang while seek on a kind of fragmented mp4.

2019-03-05 Thread Anthony Recascino
the bug that caused the hang is absolutely still present, the fix that was 
pushed was only fixing the surface level issue of the hang.


> On Mar 5, 2019, at 11:28 AM, Carl Eugen Hoyos  wrote:
> 
> 2019-03-05 17:02 GMT+01:00, Charles Liu :
>> 1. organize fragmented information according to the tracks.
>> 2. do NOT skip the last boxes of fragmented info.
> 
>> ticket #7572
> 
> Assuming the ticket is not reproducible for you with current
> FFmpeg git head (it wasn't for me two weeks ago), please
> reword this so it is clear you saw an issue looking at this
> ticket (and its fix) but that this commit does not fix a bug
> that is still reproducible with the files and command line(s)
> provided there.
> 
> Or do I misunderstand?
> 
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v1] avformat/smoothstreamingenc:add bitrate calculate

2019-03-05 Thread Jun Li
From: jun 

Calculate bitrate based on fragment size, only applied when
bitrate is not set, for example rtsp source.

Signed-off-by: Jun Li 
---
 libavformat/smoothstreamingenc.c | 30 +-
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 094712af27..1d969ab037 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -320,11 +320,12 @@ static int ism_write_header(AVFormatContext *s)
 AVDictionary *opts = NULL;
 
 if (!s->streams[i]->codecpar->bit_rate) {
-av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i);
-ret = AVERROR(EINVAL);
-goto fail;
+av_log(s, AV_LOG_WARNING, "No bit rate set for stream %d\n", i);
+snprintf(os->dirname, sizeof(os->dirname), 
"%s/QualityLevels(Tmp_%"PRId64")", s->url, i);
+} else {
+snprintf(os->dirname, sizeof(os->dirname), 
"%s/QualityLevels(%"PRId64")", s->url, s->streams[i]->codecpar->bit_rate);
 }
-snprintf(os->dirname, sizeof(os->dirname), 
"%s/QualityLevels(%"PRId64")", s->url, s->streams[i]->codecpar->bit_rate);
+
 if (mkdir(os->dirname, 0777) == -1 && errno != EEXIST) {
 ret = AVERROR(errno);
 av_log(s, AV_LOG_ERROR, "mkdir failed\n");
@@ -519,7 +520,7 @@ static int ism_flush(AVFormatContext *s, int final)
 
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = &c->streams[i];
-char filename[1024], target_filename[1024], header_filename[1024];
+char filename[1024], target_filename[1024], header_filename[1024], 
curr_dirname[1024];
 int64_t size;
 int64_t start_ts, duration, moof_size;
 if (!os->packets_written)
@@ -541,6 +542,25 @@ static int ism_flush(AVFormatContext *s, int final)
 size = os->tail_pos - os->cur_start_pos;
 if ((ret = parse_fragment(s, filename, &start_ts, &duration, 
&moof_size, size)) < 0)
 break;
+
+if (!s->streams[i]->codecpar->bit_rate) {
+int64_t bitrate = (int64_t) size * 8 * AV_TIME_BASE / 
av_rescale_q(duration, s->streams[i]->time_base, AV_TIME_BASE_Q);
+if (!bitrate) {
+av_log(s, AV_LOG_ERROR, "calculating bitrate get zero.");
+ret = AVERROR(EINVAL);
+return ret;
+}
+
+av_log(s, AV_LOG_INFO, "calculated bitrate: %ld\n", bitrate);
+s->streams[i]->codecpar->bit_rate = bitrate;
+memcpy(curr_dirname, os->dirname, sizeof(os->dirname));
+snprintf(os->dirname, sizeof(os->dirname), 
"%s/QualityLevels(%"PRId64")", s->url, s->streams[i]->codecpar->bit_rate);
+snprintf(filename, sizeof(filename), "%s/temp", os->dirname);
+
+if ((ret = ff_rename((const char*)curr_dirname,  os->dirname, s)) 
< 0)
+return ret;
+}
+
 snprintf(header_filename, sizeof(header_filename), 
"%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
 snprintf(target_filename, sizeof(target_filename), 
"%s/Fragments(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
 copy_moof(s, filename, header_filename, moof_size);
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 2/2] avcodec/dvbsubdec: Check object position

2019-03-05 Thread Michael Niedermayer
Reference: ETSI EN 300 743 V1.2.1  7.2.2 Region composition segment

Fixes: Timeout
Fixes: 
13325/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVBSUB_fuzzer-5143979392237568

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

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index b59e836657..bc4a17bde0 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1267,6 +1267,13 @@ static int dvbsub_parse_region_segment(AVCodecContext 
*avctx,
 display->y_pos = AV_RB16(buf) & 0xfff;
 buf += 2;
 
+if (display->x_pos >= region->width ||
+display->y_pos >= region->height) {
+av_log(avctx, AV_LOG_ERROR, "Object outside region\n");
+av_free(display);
+return AVERROR_INVALIDDATA;
+}
+
 if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
 display->fgcolor = *buf++;
 display->bgcolor = *buf++;
-- 
2.21.0

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


[FFmpeg-devel] [PATCH 1/2] avcodec/cdgraphics: Use ff_set_dimensions()

2019-03-05 Thread Michael Niedermayer
Fixes: Timeout (17 sec -> 65 milli sec)
Fixes: 
13264/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CDGRAPHICS_fuzzer-5711167941509120

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

diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c
index be85e54288..cf3f01a417 100644
--- a/libavcodec/cdgraphics.c
+++ b/libavcodec/cdgraphics.c
@@ -81,11 +81,8 @@ static av_cold int cdg_decode_init(AVCodecContext *avctx)
 return AVERROR(ENOMEM);
 cc->transparency = -1;
 
-avctx->width   = CDG_FULL_WIDTH;
-avctx->height  = CDG_FULL_HEIGHT;
 avctx->pix_fmt = AV_PIX_FMT_PAL8;
-
-return 0;
+return ff_set_dimensions(avctx, CDG_FULL_WIDTH, CDG_FULL_HEIGHT);
 }
 
 static void cdg_border_preset(CDGraphicsContext *cc, uint8_t *data)
-- 
2.21.0

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


[FFmpeg-devel] [PATCH 2/5] avfilter/af_astats: fix identation

2019-03-05 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavfilter/af_astats.c | 148 
 1 file changed, 74 insertions(+), 74 deletions(-)

diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index 09fbd8c1ae..ddda84cfbb 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -331,79 +331,79 @@ static void set_metadata(AudioStatsContext *s, 
AVDictionary **metadata)
 max_sigma_x = p->sigma_x;
 
 if (s->measure_perchannel & MEASURE_DC_OFFSET)
-set_meta(metadata, c + 1, "DC_offset", "%f", p->sigma_x / 
p->nb_samples);
+set_meta(metadata, c + 1, "DC_offset", "%f", p->sigma_x / 
p->nb_samples);
 if (s->measure_perchannel & MEASURE_MIN_LEVEL)
-set_meta(metadata, c + 1, "Min_level", "%f", p->min);
+set_meta(metadata, c + 1, "Min_level", "%f", p->min);
 if (s->measure_perchannel & MEASURE_MAX_LEVEL)
-set_meta(metadata, c + 1, "Max_level", "%f", p->max);
+set_meta(metadata, c + 1, "Max_level", "%f", p->max);
 if (s->measure_perchannel & MEASURE_MIN_DIFFERENCE)
-set_meta(metadata, c + 1, "Min_difference", "%f", p->min_diff);
+set_meta(metadata, c + 1, "Min_difference", "%f", p->min_diff);
 if (s->measure_perchannel & MEASURE_MAX_DIFFERENCE)
-set_meta(metadata, c + 1, "Max_difference", "%f", p->max_diff);
+set_meta(metadata, c + 1, "Max_difference", "%f", p->max_diff);
 if (s->measure_perchannel & MEASURE_MEAN_DIFFERENCE)
-set_meta(metadata, c + 1, "Mean_difference", "%f", p->diff1_sum / 
(p->nb_samples - 1));
+set_meta(metadata, c + 1, "Mean_difference", "%f", p->diff1_sum / 
(p->nb_samples - 1));
 if (s->measure_perchannel & MEASURE_RMS_DIFFERENCE)
-set_meta(metadata, c + 1, "RMS_difference", "%f", sqrt(p->diff1_sum_x2 
/ (p->nb_samples - 1)));
+set_meta(metadata, c + 1, "RMS_difference", "%f", 
sqrt(p->diff1_sum_x2 / (p->nb_samples - 1)));
 if (s->measure_perchannel & MEASURE_PEAK_LEVEL)
-set_meta(metadata, c + 1, "Peak_level", "%f", 
LINEAR_TO_DB(FFMAX(-p->nmin, p->nmax)));
+set_meta(metadata, c + 1, "Peak_level", "%f", 
LINEAR_TO_DB(FFMAX(-p->nmin, p->nmax)));
 if (s->measure_perchannel & MEASURE_RMS_LEVEL)
-set_meta(metadata, c + 1, "RMS_level", "%f", 
LINEAR_TO_DB(sqrt(p->sigma_x2 / p->nb_samples)));
+set_meta(metadata, c + 1, "RMS_level", "%f", 
LINEAR_TO_DB(sqrt(p->sigma_x2 / p->nb_samples)));
 if (s->measure_perchannel & MEASURE_RMS_PEAK)
-set_meta(metadata, c + 1, "RMS_peak", "%f", 
LINEAR_TO_DB(sqrt(p->max_sigma_x2)));
+set_meta(metadata, c + 1, "RMS_peak", "%f", 
LINEAR_TO_DB(sqrt(p->max_sigma_x2)));
 if (s->measure_perchannel & MEASURE_RMS_TROUGH)
-set_meta(metadata, c + 1, "RMS_trough", "%f", 
LINEAR_TO_DB(sqrt(p->min_sigma_x2)));
+set_meta(metadata, c + 1, "RMS_trough", "%f", 
LINEAR_TO_DB(sqrt(p->min_sigma_x2)));
 if (s->measure_perchannel & MEASURE_CREST_FACTOR)
-set_meta(metadata, c + 1, "Crest_factor", "%f", p->sigma_x2 ? 
FFMAX(-p->min, p->max) / sqrt(p->sigma_x2 / p->nb_samples) : 1);
+set_meta(metadata, c + 1, "Crest_factor", "%f", p->sigma_x2 ? 
FFMAX(-p->min, p->max) / sqrt(p->sigma_x2 / p->nb_samples) : 1);
 if (s->measure_perchannel & MEASURE_FLAT_FACTOR)
-set_meta(metadata, c + 1, "Flat_factor", "%f", 
LINEAR_TO_DB((p->min_runs + p->max_runs) / (p->min_count + p->max_count)));
+set_meta(metadata, c + 1, "Flat_factor", "%f", 
LINEAR_TO_DB((p->min_runs + p->max_runs) / (p->min_count + p->max_count)));
 if (s->measure_perchannel & MEASURE_PEAK_COUNT)
-set_meta(metadata, c + 1, "Peak_count", "%f", (float)(p->min_count + 
p->max_count));
+set_meta(metadata, c + 1, "Peak_count", "%f", (float)(p->min_count 
+ p->max_count));
 if (s->measure_perchannel & MEASURE_BIT_DEPTH) {
-bit_depth(s, p->mask, p->imask, &depth);
-set_meta(metadata, c + 1, "Bit_depth", "%f", depth.num);
-set_meta(metadata, c + 1, "Bit_depth2", "%f", depth.den);
+bit_depth(s, p->mask, p->imask, &depth);
+set_meta(metadata, c + 1, "Bit_depth", "%f", depth.num);
+set_meta(metadata, c + 1, "Bit_depth2", "%f", depth.den);
 }
 if (s->measure_perchannel & MEASURE_DYNAMIC_RANGE)
-set_meta(metadata, c + 1, "Dynamic_range", "%f", LINEAR_TO_DB(2 * 
FFMAX(FFABS(p->min), FFABS(p->max))/ p->min_non_zero));
+set_meta(metadata, c + 1, "Dynamic_range", "%f", LINEAR_TO_DB(2 * 
FFMAX(FFABS(p->min), FFABS(p->max))/ p->min_non_zero));
 if (s->measure_perchannel & MEASURE_ZERO_CROSSINGS)
-set_meta(metadata, c + 1, "Zero_crossings", "%f", p->zero_runs);
+set_meta(metadata, c + 1, "Zero_crossings", "%f", p->zero_runs);
 if (s->measure_perchannel & MEASURE_ZERO_CROSSI

[FFmpeg-devel] [PATCH 1/5] avfilter/af_astats: add support for selecting measured statistics

2019-03-05 Thread Marton Balint
set_metadata with many entries is not very efficient, and with small audio
frames the performance loss is noticable. Also with this very simple
calculations (like peak) can be even further optimized.

Unfoturnately there are some small differences in metadata and av_log info
output, so factorizing calculations and output might not worth the hassle.

Signed-off-by: Marton Balint 
---
 doc/filters.texi|  11 +
 libavfilter/af_astats.c | 118 
 2 files changed, 129 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 4bf96b6d90..4ffb392a7f 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2156,6 +2156,17 @@ For description what each key means read below.
 @item reset
 Set number of frame after which stats are going to be recalculated.
 Default is disabled.
+
+@item measure_perchannel
+Select the entries which need to be measured per channel. The metadata keys can
+be used as flags, default is @option{all} which measures everything.
+@option{none} disables all per channel measurement.
+
+@item measure_overall
+Select the entries which need to be measured overall. The metadata keys can
+be used as flags, default is @option{all} which measures everything.
+@option{none} disables all overall measurement.
+
 @end table
 
 A description of each shown parameter follows:
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index a91cfdc3a7..09fbd8c1ae 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -26,6 +26,29 @@
 #include "avfilter.h"
 #include "internal.h"
 
+#define MEASURE_ALL UINT_MAX
+#define MEASURE_NONE   0
+
+#define MEASURE_DC_OFFSET   (1 <<  0)
+#define MEASURE_MIN_LEVEL   (1 <<  1)
+#define MEASURE_MAX_LEVEL   (1 <<  2)
+#define MEASURE_MIN_DIFFERENCE  (1 <<  3)
+#define MEASURE_MAX_DIFFERENCE  (1 <<  4)
+#define MEASURE_MEAN_DIFFERENCE (1 <<  5)
+#define MEASURE_RMS_DIFFERENCE  (1 <<  6)
+#define MEASURE_PEAK_LEVEL  (1 <<  7)
+#define MEASURE_RMS_LEVEL   (1 <<  8)
+#define MEASURE_RMS_PEAK(1 <<  9)
+#define MEASURE_RMS_TROUGH  (1 << 10)
+#define MEASURE_CREST_FACTOR(1 << 11)
+#define MEASURE_FLAT_FACTOR (1 << 12)
+#define MEASURE_PEAK_COUNT  (1 << 13)
+#define MEASURE_BIT_DEPTH   (1 << 14)
+#define MEASURE_DYNAMIC_RANGE   (1 << 15)
+#define MEASURE_ZERO_CROSSINGS  (1 << 16)
+#define MEASURE_ZERO_CROSSINGS_RATE (1 << 17)
+#define MEASURE_NUMBER_OF_SAMPLES   (1 << 18)
+
 typedef struct ChannelStats {
 double last;
 double last_non_zero;
@@ -56,6 +79,8 @@ typedef struct AudioStatsContext {
 int reset_count;
 int nb_frames;
 int maxbitdepth;
+int measure_perchannel;
+int measure_overall;
 } AudioStatsContext;
 
 #define OFFSET(x) offsetof(AudioStatsContext, x)
@@ -65,6 +90,29 @@ static const AVOption astats_options[] = {
 { "length", "set the window length", OFFSET(time_constant), 
AV_OPT_TYPE_DOUBLE, {.dbl=.05}, .01, 10, FLAGS },
 { "metadata", "inject metadata in the filtergraph", OFFSET(metadata), 
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
 { "reset", "recalculate stats after this many frames", 
OFFSET(reset_count), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
+{ "measure_perchannel", "only measure_perchannel these per-channel 
statistics", OFFSET(measure_perchannel), AV_OPT_TYPE_FLAGS, {.i64=MEASURE_ALL}, 
0, UINT_MAX, FLAGS, "measure" },
+  { "none"  , "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_NONE}, 0, 0, FLAGS, "measure" },
+  { "all"   , "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_ALL }, 0, 0, FLAGS, "measure" },
+  { "DC_offset" , "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_DC_OFFSET   }, 0, 0, FLAGS, "measure" },
+  { "Min_level" , "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_MIN_LEVEL   }, 0, 0, FLAGS, "measure" },
+  { "Max_level" , "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_MAX_LEVEL   }, 0, 0, FLAGS, "measure" },
+  { "Min_difference", "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_MIN_DIFFERENCE  }, 0, 0, FLAGS, "measure" },
+  { "Max_difference", "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_MAX_DIFFERENCE  }, 0, 0, FLAGS, "measure" },
+  { "Mean_difference"   , "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_MEAN_DIFFERENCE }, 0, 0, FLAGS, "measure" },
+  { "RMS_difference", "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_RMS_DIFFERENCE  }, 0, 0, FLAGS, "measure" },
+  { "Peak_level", "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_PEAK_LEVEL  }, 0, 0, FLAGS, "measure" },
+  { "RMS_level" , "", 0, AV_OPT_TYPE_CONST, 
{.i64=MEASURE_RMS_LEVEL   }, 0, 0, FL

[FFmpeg-devel] [PATCH 3/5] avfilter/af_astats: factorize sample loops

2019-03-05 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavfilter/af_astats.c | 108 +---
 1 file changed, 37 insertions(+), 71 deletions(-)

diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index ddda84cfbb..f45558909a 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -406,12 +406,33 @@ static void set_metadata(AudioStatsContext *s, 
AVDictionary **metadata)
 set_meta(metadata, 0, "Overall.Number_of_samples", "%f", nb_samples / 
s->nb_channels);
 }
 
+#define UPDATE_STATS_P(type, double_sample, normalized_sample, int_sample) 
 \
+for (int c = 0; c < channels; c++) {   
 \
+ChannelStats *p = &s->chstats[c];  
 \
+const type *src = (const type *)data[c];   
 \
+for (int i = 0; i < samples; i++, src++)   
 \
+update_stat(s, p, double_sample, normalized_sample, int_sample);   
 \
+}
+
+#define UPDATE_STATS_I(type, double_sample, normalized_sample, int_sample) 
   \
+{  
   \
+const type *src = (const type *)data[0];   
   \
+for (int i = 0; i < samples; i++) {
   \
+for (int c = 0; c < channels; c++, src++)  
   \
+update_stat(s, &s->chstats[c], double_sample, 
normalized_sample, int_sample); \
+}  
   \
+}
+
+#define UPDATE_STATS(planar, type, sample, normalizer_suffix, int_sample) \
+UPDATE_STATS_##planar(type, sample, sample normalizer_suffix, int_sample);
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
 {
 AudioStatsContext *s = inlink->dst->priv;
 AVDictionary **metadata = &buf->metadata;
 const int channels = s->nb_channels;
-int i, c;
+const int samples = buf->nb_samples;
+const uint8_t * const * const data = (const uint8_t * const 
*)buf->extended_data;
 
 if (s->reset_count > 0) {
 if (s->nb_frames >= s->reset_count) {
@@ -423,89 +444,34 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*buf)
 
 switch (inlink->format) {
 case AV_SAMPLE_FMT_DBLP:
-for (c = 0; c < channels; c++) {
-ChannelStats *p = &s->chstats[c];
-const double *src = (const double *)buf->extended_data[c];
-
-for (i = 0; i < buf->nb_samples; i++, src++)
-update_stat(s, p, *src, *src, llrint(*src * (UINT64_C(1) << 
63)));
-}
+UPDATE_STATS(P, double, *src, , llrint(*src * (UINT64_C(1) << 63)));
 break;
-case AV_SAMPLE_FMT_DBL: {
-const double *src = (const double *)buf->extended_data[0];
-
-for (i = 0; i < buf->nb_samples; i++) {
-for (c = 0; c < channels; c++, src++)
-update_stat(s, &s->chstats[c], *src, *src, llrint(*src * 
(UINT64_C(1) << 63)));
-}}
+case AV_SAMPLE_FMT_DBL:
+UPDATE_STATS(I, double, *src, , llrint(*src * (UINT64_C(1) << 63)));
 break;
 case AV_SAMPLE_FMT_FLTP:
-for (c = 0; c < channels; c++) {
-ChannelStats *p = &s->chstats[c];
-const float *src = (const float *)buf->extended_data[c];
-
-for (i = 0; i < buf->nb_samples; i++, src++)
-update_stat(s, p, *src, *src, llrint(*src * (UINT64_C(1) << 
31)));
-}
+UPDATE_STATS(P, float, *src, , llrint(*src * (UINT64_C(1) << 31)));
 break;
-case AV_SAMPLE_FMT_FLT: {
-const float *src = (const float *)buf->extended_data[0];
-
-for (i = 0; i < buf->nb_samples; i++) {
-for (c = 0; c < channels; c++, src++)
-update_stat(s, &s->chstats[c], *src, *src, llrint(*src * 
(UINT64_C(1) << 31)));
-}}
+case AV_SAMPLE_FMT_FLT:
+UPDATE_STATS(I, float, *src, , llrint(*src * (UINT64_C(1) << 31)));
 break;
 case AV_SAMPLE_FMT_S64P:
-for (c = 0; c < channels; c++) {
-ChannelStats *p = &s->chstats[c];
-const int64_t *src = (const int64_t *)buf->extended_data[c];
-
-for (i = 0; i < buf->nb_samples; i++, src++)
-update_stat(s, p, *src, *src / (double)INT64_MAX, *src);
-}
+UPDATE_STATS(P, int64_t, *src, / (double)INT64_MAX, *src);
 break;
-case AV_SAMPLE_FMT_S64: {
-const int64_t *src = (const int64_t *)buf->extended_data[0];
-
-for (i = 0; i < buf->nb_samples; i++) {
-for (c = 0; c < channels; c++, src++)
-update_stat(s, &s->chstats[c], *src, *src / (double)INT64_MAX, 
*src);
-}}
+case AV_SAMPLE_FMT_S64:
+UPDATE_STATS(I, int64_t, *src, / (double)INT64_MAX, *src);
   

[FFmpeg-devel] [PATCH 4/5] avfilter/af_astats: rework sample loops

2019-03-05 Thread Marton Balint
The channel loop is now the outer loop for both planar and interleaved. This is
needed by the next patch, and the speed difference is negligable if any.

Signed-off-by: Marton Balint 
---
 libavfilter/af_astats.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index f45558909a..9915a7965e 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -410,17 +410,18 @@ static void set_metadata(AudioStatsContext *s, 
AVDictionary **metadata)
 for (int c = 0; c < channels; c++) {   
 \
 ChannelStats *p = &s->chstats[c];  
 \
 const type *src = (const type *)data[c];   
 \
-for (int i = 0; i < samples; i++, src++)   
 \
+const type * const srcend = src + samples; 
 \
+for (; src < srcend; src++)
 \
 update_stat(s, p, double_sample, normalized_sample, int_sample);   
 \
 }
 
-#define UPDATE_STATS_I(type, double_sample, normalized_sample, int_sample) 
   \
-{  
   \
-const type *src = (const type *)data[0];   
   \
-for (int i = 0; i < samples; i++) {
   \
-for (int c = 0; c < channels; c++, src++)  
   \
-update_stat(s, &s->chstats[c], double_sample, 
normalized_sample, int_sample); \
-}  
   \
+#define UPDATE_STATS_I(type, double_sample, normalized_sample, int_sample) 
 \
+for (int c = 0; c < channels; c++) {   
 \
+ChannelStats *p = &s->chstats[c];  
 \
+const type *src = (const type *)data[0];   
 \
+const type * const srcend = src + samples * channels;  
 \
+for (src += c; src < srcend; src += channels)  
 \
+update_stat(s, p, double_sample, normalized_sample, int_sample);   
 \
 }
 
 #define UPDATE_STATS(planar, type, sample, normalizer_suffix, int_sample) \
-- 
2.16.4

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


[FFmpeg-devel] [PATCH 5/5] avfilter/af_astats: add support for optimized min/max/peak calculation

2019-03-05 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavfilter/af_astats.c | 26 +-
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index 9915a7965e..92368793c2 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -49,6 +49,8 @@
 #define MEASURE_ZERO_CROSSINGS_RATE (1 << 17)
 #define MEASURE_NUMBER_OF_SAMPLES   (1 << 18)
 
+#define MEASURE_MINMAXPEAK  (MEASURE_MIN_LEVEL | MEASURE_MAX_LEVEL 
| MEASURE_PEAK_LEVEL)
+
 typedef struct ChannelStats {
 double last;
 double last_non_zero;
@@ -216,6 +218,14 @@ static void bit_depth(AudioStatsContext *s, uint64_t mask, 
uint64_t imask, AVRat
 depth->num++;
 }
 
+static inline void update_minmax(AudioStatsContext *s, ChannelStats *p, double 
d)
+{
+if (d < p->min)
+p->min = d;
+if (d > p->max)
+p->max = d;
+}
+
 static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double 
d, double nd, int64_t i)
 {
 if (d < p->min) {
@@ -406,26 +416,32 @@ static void set_metadata(AudioStatsContext *s, 
AVDictionary **metadata)
 set_meta(metadata, 0, "Overall.Number_of_samples", "%f", nb_samples / 
s->nb_channels);
 }
 
-#define UPDATE_STATS_P(type, double_sample, normalized_sample, int_sample) 
 \
+#define UPDATE_STATS_P(type, update_func, channel_func)
 \
 for (int c = 0; c < channels; c++) {   
 \
 ChannelStats *p = &s->chstats[c];  
 \
 const type *src = (const type *)data[c];   
 \
 const type * const srcend = src + samples; 
 \
 for (; src < srcend; src++)
 \
-update_stat(s, p, double_sample, normalized_sample, int_sample);   
 \
+update_func;   
 \
+channel_func;  
 \
 }
 
-#define UPDATE_STATS_I(type, double_sample, normalized_sample, int_sample) 
 \
+#define UPDATE_STATS_I(type, update_func, channel_func)
 \
 for (int c = 0; c < channels; c++) {   
 \
 ChannelStats *p = &s->chstats[c];  
 \
 const type *src = (const type *)data[0];   
 \
 const type * const srcend = src + samples * channels;  
 \
 for (src += c; src < srcend; src += channels)  
 \
-update_stat(s, p, double_sample, normalized_sample, int_sample);   
 \
+update_func;   
 \
+channel_func;  
 \
 }
 
 #define UPDATE_STATS(planar, type, sample, normalizer_suffix, int_sample) \
-UPDATE_STATS_##planar(type, sample, sample normalizer_suffix, int_sample);
+if ((s->measure_overall | s->measure_perchannel) & ~MEASURE_MINMAXPEAK) {  
\
+UPDATE_STATS_##planar(type, update_stat(s, p, sample, sample 
normalizer_suffix, int_sample), );\
+} else {   
\
+UPDATE_STATS_##planar(type, update_minmax(s, p, sample), p->nmin = 
p->min normalizer_suffix; p->nmax = p->max normalizer_suffix;); \
+}
 
 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
 {
-- 
2.16.4

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


Re: [FFmpeg-devel] [PATCH] avformat/mpegts.c: reduce buffering during initialization

2019-03-05 Thread Andriy Gelman
> What is the issue that you are seeing and that this patch fix? Is it only
> matters for low bitrate mpegts? (like 64 kbps streams?) Or does this
> improve high bitrate streams as well somehow?

I'm muxing hevc video + very low bitrate binary messages into mpegts.
If the hevc video is not present, I would have to buffer 8192 bytes of
binary messages to get past mpegts_read_header, which was creating a large
latency.
This patch reduces the startup time. As you mentioned, it does not apply to
high bitrate streams.

Also in git history, I saw that the size of the buffer was changed in
ad-hoc way from 1024 -> 5*1024-> 8 * 1024 because I assume probing failed
in some cases.
I feel that the proposed patch would be a better solution as it follows the
same ideas when probing for unknown parameters in other parts of the code.

Regards,
Andriy


On Tue, 5 Mar 2019 at 11:59, Marton Balint  wrote:

>
>
> On Mon, 4 Mar 2019, andriy.gel...@gmail.com wrote:
>
> > From: Andriy Gelman 
> >
> > Reduces buffering during estimation of mpegts raw_packet_size
> > parameter. Instead of buffering a fixed 8192 bytes, calculate
> > probe scores on a smaller buffer. Increase buffer size until
> > probe score is greater than minimum value.
>
> What is the issue that you are seeing and that this patch fix? Is it only
> matters for low bitrate mpegts? (like 64 kbps streams?) Or does this
> improve high bitrate streams as well somehow?
>
> Thanks,
> Marton
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v6 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper.

2019-03-05 Thread Mark Thompson
On 05/03/2019 07:43, Jing SUN wrote:
> From: Jing Sun 
> 
> base on patch by Huang, Zhengxu from https://github.com/intel/SVT-HEVC
> 
> V4: - Fix the build error with new API in PR#52
> - Fix the encoding hang issue by API change in PR#52
> - Fix the last frame dropping issue
> - Fix the invalid parameter causing segmentation fault issue
> - Add the support to svt hevc and av1 plugins coexistance
> - Add the VMAF optimized mode to "-tune"
> - Add the "-hdr" parameter
> 
> V3: - Fix the build error with new API
> 
> V2: - Change the config options (didn't need to enable-gpl for BSD+Patent,
>   it's can compatible with LGPL2+, thanks Xavier correct this part),
>   now just need to "--enable-libsvthevc" option
> - Add force_idr option
> - Remove default GoP size setting in the wrapper, SVT-HEVC will calc
>   the the GoP size internal
> - Refine the code as the FFmpeg community's comments
>   (https://patchwork.ffmpeg.org/patch/11347/)
> 
> V1: - base on patch by Huang, Zhengxu, then refine some code.
> 
> Change-Id: If0dcc5044ab9effd6847a8f48797b985d02b0816
> Signed-off-by: Huang, Zhengxu 
> Signed-off-by: hassene 
> Signed-off-by: Jun Zhao 
> Signed-off-by: Jing Sun 
> ---
>  configure|   4 +
>  libavcodec/Makefile  |   1 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/libsvt_hevc.c | 546 
> +++
>  4 files changed, 552 insertions(+)
>  create mode 100644 libavcodec/libsvt_hevc.c
> 
> ...
> 
> diff --git a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c
> new file mode 100644
> index 000..97bd204
> --- /dev/null
> +++ b/libavcodec/libsvt_hevc.c
> @@ -0,0 +1,546 @@
> +/*
> +* Scalable Video Technology for HEVC encoder library plugin
> +*
> +* Copyright (c) 2018 Intel Corporation
> +*
> +* 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 this program; if not, write to the Free Software
> +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> +*/
> +
> +#include "svt-hevc/EbErrorCodes.h"
> +#include "svt-hevc/EbTime.h"
> +#include "svt-hevc/EbApi.h"
> +
> +#include "libavutil/common.h"
> +#include "libavutil/frame.h"
> +#include "libavutil/opt.h"
> +
> +#include "internal.h"
> +#include "avcodec.h"
> +
> +typedef enum eos_status {
> +EOS_NOT_REACHED = 0,
> +EOS_REACHED,
> +EOS_TOTRIGGER
> +}EOS_STATUS;
> +
> +typedef struct SvtContext {
> +AVClass *class;
> +
> +EB_H265_ENC_CONFIGURATION  enc_params;
> +EB_COMPONENTTYPE   *svt_handle;
> +
> +EB_BUFFERHEADERTYPE*in_buf;

This structure appears have exactly the same lifetime as the encoder itself - 
can you just put it directly in the SvtContext rather than allocating/freeing 
it separately?

> +int raw_size;

This variable seems to be write-only.

> +
> +EOS_STATUS eos_flag;
> +
> +// User options.
> +int vui_info;
> +int hierarchical_level;
> +int la_depth;
> +int enc_mode;
> +int rc_mode;
> +int scd;
> +int tune;
> +int qp;
> +int hdr;
> +
> +int forced_idr;
> +
> +int aud;
> +
> +int profile;
> +int tier;
> +int level;
> +
> +int base_layer_switch_mode;
> +} SvtContext;
> +
> +static int error_mapping(EB_ERRORTYPE svt_ret)
> +{
> +int err;
> +
> +switch (svt_ret) {
> +case EB_ErrorInsufficientResources:
> +err = AVERROR(ENOMEM);
> +break;
> +
> +case EB_ErrorUndefined:
> +case EB_ErrorInvalidComponent:
> +case EB_ErrorBadParameter:
> +err = AVERROR(EINVAL);
> +break;
> +
> +case EB_ErrorDestroyThreadFailed:
> +case EB_ErrorSemaphoreUnresponsive:
> +case EB_ErrorDestroySemaphoreFailed:
> +case EB_ErrorCreateMutexFailed:
> +case EB_ErrorMutexUnresponsive:
> +case EB_ErrorDestroyMutexFailed:
> +err = AVERROR_EXTERNAL;
> +break;
> +
> +case EB_NoErrorEmptyQueue:
> +err = AVERROR(EAGAIN);
> +
> +case EB_ErrorNone:
> +err = 0;
> +break;
> +
> +default:
> +err = AVERROR_UNKNOWN;
> +}
> +
> +return err;
> +}
> +
> +static void free_buffer(SvtContext *svt_enc)
> +{
> +if (svt_enc->in_buf) {
> +EB_H265_ENC_INPUT *in_data = (EB_H265_ENC_INPUT 
> *)svt_enc->in_buf->pBuffer;
> +av_freep(&in_data);
> +av_f

Re: [FFmpeg-devel] [PATCH v6 2/2] doc: Add libsvt_hevc encoder docs

2019-03-05 Thread Mark Thompson
On 05/03/2019 07:43, Jing SUN wrote:
> Add docs for libsvt_hevc encoder in encoders.texi and general.texi
> 
> Signed-off-by: Jun Zhao 
> Signed-off-by: Huang, Zhengxu 
> Signed-off-by: hassene 
> Signed-off-by: Jing SUN 
> ---
>  doc/encoders.texi | 161 
> ++
>  doc/general.texi  |   8 +++
>  2 files changed, 169 insertions(+)
> 
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 29625ba..64ddb2f 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1569,6 +1569,167 @@ Set maximum NAL size in bytes.
>  Allow skipping frames to hit the target bitrate if set to 1.
>  @end table
>  
> +@section libsvt_hevc
> +
> +Scalable Video Technology for HEVC encoder (SVT-HEVC encoder) wrapper.
> +
> +This encoder requires the presence of the headers and
> +library during configuration. You need to explicitly configure the
> +build with @code{--enable-libsvthevc}. The library is detected using
> +@command{pkg-config}.
> +
> +For more information about the library see
> +@url{https://github.com/intel/SVT-HEVC.git}.
> +
> +@subsection Options
> +
> +The following FFmpeg global options affect the configurations of the
> +libsvt_hevc encoder.
> +
> +@table @option
> +@item b  (@emph{bitrate})
> +Set the bitrate (as a number of bits per second). Default is 7M.
> +
> +@item refs (@emph{ref})
> +Number of reference frames each P-frame can use. The range is from 
> @var{0-16}.
> +Default is 0(disabled).

Wouldn't 0 mean that P frames can't exist, so the whole stream must be 
intra-only?

> +@item g  / @option{gop_size}
> +Set the GOP size. Default is 64.

This doesn't appear to match what is set in the other patch.

> +
> +@item flags +cgop
> +Enable closed GOP.
> +
> +@item qmin (@emph{min-q})
> +Defaults 10
> +
> +@item qmax (@emph{max-q})
> +Defaults 48
> +
> +Set minimum/maximum quantisation values.  Valid range is from 0 to 51
> +(Only used when bit rate control mode @option{rc} is set to 0(cqp) mode.
> +Has to be qmax > = qmin).

In the other patch you only set them in VBR mode, not CQP mode.

> +
> +@item profile (@emph{profile})
> +Set profile restrictions. Can assume one of the following possible values:
> +
> +Default is 2 (main10).
> +
> +@table @samp
> +@item main
> +main profile
> +@item main10
> +main10 profile
> +@end table
> +
> +@item level
> +
> +@option{profile} sets the value of @emph{profile_idc} and the 
> @emph{constraint_set*_flag}s.
> +@option{level} sets the value of @emph{level_idc}.

The syntax elements named here exist only in H.264, not H.265.

> +
> +The encoder also has its own specific options:
> +
> +@table @option
> +@item vui
> +Enables or disables the vui structure in the HEVC elementary
> +bitstream. 0 = Off, 1 = On. Default is 0 (Off).
> +
> +@item aud (@emph{aud})
> +Enable use of access unit delimiters when set to 1. Default is 0 (Off).
> +
> +@item hielevel
> +Set hierarchical levels. Can assume one of the following possible values:
> +
> +Default is 3 (4level).
> +
> +@table @samp
> +@item flat
> +none hierarchy level
> +@item 2level
> +2-level hierarchy
> +@item 3level
> +3-level hierarchy
> +@item 4level
> +4-level hierarchy
> +@end table
> +
> +@item la_depth
> +Set look-ahead depth, depending on bit rate control mode @option{rc}, when
> +bit rate control mode is set to vbr it's best to set this parameter to be
> +equal to the intra period value (such is the default set by the encoder),
> +when cqp is chosen, then a look ahead is recommended. The range is from 
> @var{0-256}.
> +
> +@item intra_ref_type
> +Set intra refesh type. Can assume one of the following possible values:
> +
> +Default is 2 (idr).
> +
> +@table @samp
> +@item cra
> +open group of pictures
> +@item idr
> +closed group of pictures
> +@end table

This option doesn't exist in the other patch.

> +
> +@item preset
> +A preset defining the quality vs density tradeoff point that the
> +encoding is to be performed at.(e.g. 0 is the highest quality mode,
> +12 is the highest density mode). The range is from @var{0-12}. Default is 9.
> +
> +@item tier
> +Set @emph{general_tier_flag}.  This may affect the level chosen for the 
> stream
> +if it is not explicitly specified. Can assume one of the following possible 
> values:
> +
> +Default is 1 (main).
> +
> +@table @samp
> +@item main
> +main tier
> +@item high
> +high tier
> +@end table
> +
> +@item rc
> +Set bit rate control mode. Can assume one of the following possible values:
> +
> +Default is 0 (cqp).
> +
> +@table @samp
> +@item cqp
> +Constant QP (CQP) mode
> +@item vbr
> +Variable Bit Rate (VBR) mode
> +@end table
> +
> +@item qp
> +Initial quantization parameter for the intra pictures used when
> +@option{rc} is cqp mode. The range is from @var{0-51}. Default is 32.
> +
> +@item sc_detection
> +Enables or disables the scene change detection algorithm. Default is 0 
> (disable).
> +
> +@item tune
> +Set quality tuning mode. Can assume one of the following possible values:
> +
> +Default is 

Re: [FFmpeg-devel] avcodec/proresenc_aw : improve speed by replacing PutBitContext for codeword encoding

2019-03-05 Thread Michael Niedermayer
On Tue, Mar 05, 2019 at 11:28:56AM +0100, Martin Vignali wrote:
> Hello,
> 
> do i understand correctly that there is no check that prevents out of array
> > writing ?
> > not even an assert
> > If thats the case, then i think this is unwise.
> >
> >
> Thanks for testing.
> 
> For the buffer check, i can add a test (assert or error), before slice
> plane encoding, in order to check if there is enough space in the dst
> buffer for the "worst" slice plane target size.

Whatever check is added it should be robust and ensure that no out of
array writes can happen. 
For example someone changing what is written should not be able to miss
any checks that he would need to update.

thx

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

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus


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


Re: [FFmpeg-devel] [PATCH] avformat/mpegts.c: reduce buffering during initialization

2019-03-05 Thread Marton Balint



On Mon, 4 Mar 2019, andriy.gel...@gmail.com wrote:


From: Andriy Gelman 

Reduces buffering during estimation of mpegts raw_packet_size
parameter. Instead of buffering a fixed 8192 bytes, calculate
probe scores on a smaller buffer. Increase buffer size until
probe score is greater than minimum value.


Please extend the commit message with the justification for this change,
e.g. "reduces buffering latency with low bitrate streams, where 8192 bytes 
can mean several seconds"



---
libavformat/mpegts.c | 82 +++-
1 file changed, 59 insertions(+), 23 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index b04fd7b4f4..a7b33eae69 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -53,6 +53,10 @@
(prev_dividend) = (dividend);  \
} while (0)

+#define MAX_RAW_PACKET_PROBE 8192
+#define PROBE_PACKET_STEP 512
+#define RAW_PACKET_MIN_SCORE 10
+
enum MpegTSFilterType {
MPEGTS_PES,
MPEGTS_SECTION,
@@ -591,28 +595,64 @@ static int analyze(const uint8_t *buf, int size, int 
packet_size,
return best_score - FFMAX(stat_all - 10*best_score, 0)/10;
}

-/* autodetect fec presence. Must have at least 1024 bytes  */
-static int get_packet_size(const uint8_t *buf, int size)
+/* autodetect fec presence */
+static int get_packet_size(AVIOContext* pb)
{
int score, fec_score, dvhs_score;
+int pd_packet_size = TS_PACKET_SIZE;


The initial value can be 0 or AVERROR_INVALIDDATA, because calling code 
falls back to this anyway and reports the issue.



+int best_score = 0;
+int ret;

-if (size < (TS_FEC_PACKET_SIZE * 5 + 1))
-return AVERROR_INVALIDDATA;
+AVProbeData pd = { 0 };
+while (best_score < RAW_PACKET_MIN_SCORE &&
+pd.buf_size + PROBE_PACKET_STEP <= MAX_RAW_PACKET_PROBE) {
+
+/*create extra space for next packet*/
+uint8_t *new_buf = av_realloc(pd.buf, pd.buf_size + PROBE_PACKET_STEP);
+if (new_buf) {
+pd.buf = new_buf;
+ret = avio_read(pb, pd.buf + pd.buf_size, PROBE_PACKET_STEP);


I can see that you are increasing linearly, maybe doubling the bufsize 
with each step is better, although in this case it probably does not 
matter too much.


On the other hand, the maximum 8K seems small enough to allocate it at the 
start of the function instead of reallocing it with each step.




+if (ret < 0) {
+av_log(pb, AV_LOG_ERROR, "Error reading from input: %s.\n",
+   av_err2str(ret));


This probably should not report an error for AVERROR_EOF, mpegts files 
less than 8192 bytes can be valid.



+break;
+}
+pd.buf_size += ret;
+} else
+goto fail;
+
+/*check score for each fec packet size*/
+score  = analyze(pd.buf, pd.buf_size, TS_PACKET_SIZE,  0);
+if (score > best_score) {
+best_score = score;
+pd_packet_size = TS_PACKET_SIZE;
+}

-score  = analyze(buf, size, TS_PACKET_SIZE,  0);
-dvhs_score = analyze(buf, size, TS_DVHS_PACKET_SIZE, 0);
-fec_score  = analyze(buf, size, TS_FEC_PACKET_SIZE,  0);
-av_log(NULL, AV_LOG_TRACE, "score: %d, dvhs_score: %d, fec_score: %d \n",
-score, dvhs_score, fec_score);
-
-if (score > fec_score && score > dvhs_score)
-return TS_PACKET_SIZE;
-else if (dvhs_score > score && dvhs_score > fec_score)
-return TS_DVHS_PACKET_SIZE;
-else if (score < fec_score && dvhs_score < fec_score)
-return TS_FEC_PACKET_SIZE;
-else
-return AVERROR_INVALIDDATA;
+dvhs_score = analyze(pd.buf, pd.buf_size, TS_DVHS_PACKET_SIZE, 0);
+if (dvhs_score > best_score) {
+best_score = dvhs_score;
+pd_packet_size = TS_DVHS_PACKET_SIZE;
+}
+
+fec_score  = analyze(pd.buf, pd.buf_size, TS_FEC_PACKET_SIZE,  0);
+if (fec_score > best_score) {
+best_score = fec_score;
+pd_packet_size = TS_FEC_PACKET_SIZE;
+}


You seem to be changing the logic:

Old code: report packet size if candidate score is better than other 
scores.
New code: report packet size with first best score no matter if the other 
scores are the same.


Old logic seems less error-prone, so you should determine the winner based 
on that, and stay in the loop if no winner is found.



+
+av_log(NULL, AV_LOG_TRACE, "Probe size: %d, score: %d, dvhs_score: %d, 
fec_score: %d \n",
+pd.buf_size, score, dvhs_score, fec_score);
+}
+
+if (pd.buf)
+av_freep(&pd.buf);
+
+return pd_packet_size;
+
+fail:
+if (pd.buf)
+av_freep(&pd.buf);
+return AVERROR(ENOMEM);
}

typedef struct SectionHeader {
@@ -2841,8 +2881,6 @@ static int mpegts_read_header(AVFormatContext *s)
{
MpegTSContext *ts = s->priv_data;
AVIOContext *pb   = s->pb;
-uint8_t buf[8 * 1024] =

Re: [FFmpeg-devel] [PATCH] avformat/mpegts.c: reduce buffering during initialization

2019-03-05 Thread Michael Niedermayer
On Mon, Mar 04, 2019 at 10:21:01PM -0500, andriy.gel...@gmail.com wrote:
> From: Andriy Gelman 
> 
> Reduces buffering during estimation of mpegts raw_packet_size
> parameter. Instead of buffering a fixed 8192 bytes, calculate
> probe scores on a smaller buffer. Increase buffer size until
> probe score is greater than minimum value.
> ---
>  libavformat/mpegts.c | 82 +++-
>  1 file changed, 59 insertions(+), 23 deletions(-)
> 
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index b04fd7b4f4..a7b33eae69 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -53,6 +53,10 @@
>  (prev_dividend) = (dividend);
>   \
>  } while (0)
>  
> +#define MAX_RAW_PACKET_PROBE 8192
> +#define PROBE_PACKET_STEP 512
> +#define RAW_PACKET_MIN_SCORE 10
> +
>  enum MpegTSFilterType {
>  MPEGTS_PES,
>  MPEGTS_SECTION,
> @@ -591,28 +595,64 @@ static int analyze(const uint8_t *buf, int size, int 
> packet_size,
>  return best_score - FFMAX(stat_all - 10*best_score, 0)/10;
>  }
>  
> -/* autodetect fec presence. Must have at least 1024 bytes  */
> -static int get_packet_size(const uint8_t *buf, int size)
> +/* autodetect fec presence */
> +static int get_packet_size(AVIOContext* pb)
>  {
>  int score, fec_score, dvhs_score;
> +int pd_packet_size = TS_PACKET_SIZE;
> +int best_score = 0;
> +int ret;
>  
> -if (size < (TS_FEC_PACKET_SIZE * 5 + 1))
> -return AVERROR_INVALIDDATA;
> +AVProbeData pd = { 0 };
> +while (best_score < RAW_PACKET_MIN_SCORE &&
> +pd.buf_size + PROBE_PACKET_STEP <= MAX_RAW_PACKET_PROBE) {

the end condition is not robust
if you have scores 100 and 101, 101 is better but the difference is too small
to stop the loop without risk that the other moght be better later

the use of AVProbeData does not seem to help this code in any way


> +
> +/*create extra space for next packet*/
> +uint8_t *new_buf = av_realloc(pd.buf, pd.buf_size + 
> PROBE_PACKET_STEP);

the previous code needed no dynamic allocation. Changing that is not needed
and would e a seperate issue and require an explanation why.

overall this patch looks like it changes alot more than whats needed
to run the code with less data in an initial iteration

thx

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

No snowflake in an avalanche ever feels responsible. -- Voltaire


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


[FFmpeg-devel] [PATCH 1/4] lavfi/zscale: make use of AVFILTER_DEFINE_CLASS

2019-03-05 Thread Jun Zhao
From: Jun Zhao 

use AVFILTER_DEFINE_CLASS for defining the filter classes

Signed-off-by: Jun Zhao 
---
 libavfilter/vf_zscale.c |8 +---
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 6e1d36c..f030927 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -859,13 +859,7 @@ static const AVOption zscale_options[] = {
 { NULL }
 };
 
-static const AVClass zscale_class = {
-.class_name   = "zscale",
-.item_name= av_default_item_name,
-.option   = zscale_options,
-.version  = LIBAVUTIL_VERSION_INT,
-.category = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(zscale);
 
 static const AVFilterPad avfilter_vf_zscale_inputs[] = {
 {
-- 
1.7.1

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


[FFmpeg-devel] [PATCH 4/4] doc/bsfs: h264_metadata: Update docs about display orientation SEI

2019-03-05 Thread Jun Zhao
From: Jun Zhao 

Add docs about display orientation SEI.

Signed-off-by: Jun Zhao 
---
 doc/bitstream_filters.texi |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 076b910..83ef89c 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -267,6 +267,27 @@ insert the string ``hello'' associated with the given UUID.
 @item delete_filler
 Deletes both filler NAL units and filler SEI messages.
 
+@item display_orientation
+Pass, insert, remove or extract display orientation SEI.  Default is pass.
+
+@table @samp
+@item pass
+@item insert
+@item remove
+@item extract
+@end table
+
+@item rotate
+Set rotation in display orientation SEI (anticlockwise angle in degrees) (from 
-360 to 360)
+
+@item flip
+Set flip in display orientation SEI
+
+@table @samp
+@item horizontal
+@item vertical
+@end table
+
 @item level
 Set the level in the SPS.  Refer to H.264 section A.3 and tables A-1
 to A-5.
-- 
1.7.1

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


[FFmpeg-devel] [PATCH 2/4] lavfi/tonemap: make use of AVFILTER_DEFINE_CLASS

2019-03-05 Thread Jun Zhao
From: Jun Zhao 

use AVFILTER_DEFINE_CLASS for defining the filter classes

Signed-off-by: Jun Zhao 
---
 libavfilter/vf_tonemap.c |8 +---
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
index 98a2c4b..efd4af5 100644
--- a/libavfilter/vf_tonemap.c
+++ b/libavfilter/vf_tonemap.c
@@ -287,13 +287,7 @@ static const AVOption tonemap_options[] = {
 { NULL }
 };
 
-static const AVClass tonemap_class = {
-.class_name   = "tonemap",
-.item_name= av_default_item_name,
-.option   = tonemap_options,
-.version  = LIBAVUTIL_VERSION_INT,
-.category = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(tonemap);
 
 static const AVFilterPad tonemap_inputs[] = {
 {
-- 
1.7.1

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


[FFmpeg-devel] [PATCH 3/4] lavfi/nlmeans: Checking number precision when computing integral images

2019-03-05 Thread Jun Zhao
From: Jun Zhao 

accumulation of 8-bits uint_8 (uint8_t *src) into 32-bits (uint32_t *ii)
data type, it will have a risk of an integral value becoming larger than
the 32-bits integer capacity and resulting in an integer overflow. For
this risk, add a checking with warning message.

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

diff --git a/libavfilter/vf_nlmeans.c b/libavfilter/vf_nlmeans.c
index dcb5a03..31c8304 100644
--- a/libavfilter/vf_nlmeans.c
+++ b/libavfilter/vf_nlmeans.c
@@ -236,6 +236,13 @@ static void compute_ssd_integral_image(const 
NLMeansDSPContext *dsp,
 // adjusted end x position of the safe area after width of the safe area 
gets aligned
 const int endx_safe = startx_safe + safe_pw;
 
+// accumulation of 8-bits uint_8 (uint8_t *src) into 32-bits (uint32_t *ii)
+// data type, it will have a risk of an integral value becoming larger than
+// the 32-bits integer capacity and resulting in an integer overflow.
+if ((w * h * UINT8_MAX) > UINT32_MAX)
+av_log(NULL, AV_LOG_WARNING,
+   "image (%d x %d) integral value maybe overflow.\n", w ,h);
+
 // top part where only one of s1 and s2 is still readable, or none at all
 compute_unsafe_ssd_integral_image(ii, ii_linesize_32,
   0, 0,
-- 
1.7.1

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


Re: [FFmpeg-devel] [PATCH 1/1] avformat/dashenc: Added #EXT-X-PROGRAM-DATE-TIME to HLS playlists

2019-03-05 Thread Jeyapal, Karthick

On 3/5/19 8:07 PM, joepadmiraal wrote:
> ---
>  libavformat/dashenc.c | 20 ++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index c5e882f4ae..6bcdc9ba36 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -61,6 +61,7 @@ typedef struct Segment {
>  int64_t start_pos;
>  int range_length, index_length;
>  int64_t time;
> +double prog_date_time;
>  int64_t duration;
>  int n;
>  } Segment;
> @@ -122,6 +123,7 @@ typedef struct DASHContext {
>  int64_t last_duration;
>  int64_t total_duration;
>  char availability_start_time[100];
> +time_t start_time_s;
>  char dirname[1024];
>  const char *single_file_name;  /* file names as specified in options */
>  const char *init_seg_name;
> @@ -433,6 +435,7 @@ static void write_hls_media_playlist(OutputStream *os, 
> AVFormatContext *s,
>  const char *proto = avio_find_protocol_name(c->dirname);
>  int use_rename = proto && !strcmp(proto, "file");
>  int i, start_index, start_number;
> +double prog_date_time = 0;
>  
>  get_start_index_number(os, c, &start_index, &start_number);
>  
> @@ -467,11 +470,20 @@ static void write_hls_media_playlist(OutputStream *os, 
> AVFormatContext *s,
>  
>  for (i = start_index; i < os->nb_segments; i++) {
>  Segment *seg = os->segments[i];
> +
> +if (prog_date_time == 0) {
> +if (os->nb_segments == 1)
> +prog_date_time = c->start_time_s;
> +else
> +prog_date_time = seg->prog_date_time;
> +}
> +seg->prog_date_time = prog_date_time;
> +
>  ret = ff_hls_write_file_entry(c->m3u8_out, 0, c->single_file,
>  (double) seg->duration / timescale, 0,
>  seg->range_length, seg->start_pos, NULL,
>  c->single_file ? os->initfile : seg->file,
> -NULL);
> +&prog_date_time);
>  if (ret < 0) {
>  av_log(os->ctx, AV_LOG_WARNING, "ff_hls_write_file_entry get 
> error\n");
>  }
> @@ -1592,9 +1604,13 @@ static int dash_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  os->first_pts = pkt->pts;
>  os->last_pts = pkt->pts;
>  
> -if (!c->availability_start_time[0])
> +if (!c->availability_start_time[0]) {
> +int64_t start_time_us = av_gettime();
> +int64_t start_time_ms = start_time_us / 1000;
> +c->start_time_s = start_time_ms / 1000;
>  format_date_now(c->availability_start_time,
>  sizeof(c->availability_start_time));
> +}
>  
>  if (!os->availability_time_offset && pkt->duration) {
>  int64_t frame_duration = av_rescale_q(pkt->duration, st->time_base,
Thanks for your contribution. This patch has been pushed (after a minor 
cleanup).

Regards,
Karthick

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


[FFmpeg-devel] [PATCH v2] avformat/mpegts: reduce buffering during initialization

2019-03-05 Thread Andriy Gelman
From: Andriy Gelman 

Reduces buffering latency with low bitrate streams, where
8192 bytes can mean several seconds.
---
 libavformat/mpegts.c | 60 +++-
 1 file changed, 37 insertions(+), 23 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index b04fd7b4f4..fcb5b488d8 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -53,6 +53,10 @@
 (prev_dividend) = (dividend);  
\
 } while (0)
 
+#define PROBE_PACKET_MAX_BUF 8192
+#define PROBE_PACKET_STEP 512
+#define PROBE_PACKET_MARGIN 5
+
 enum MpegTSFilterType {
 MPEGTS_PES,
 MPEGTS_SECTION,
@@ -591,28 +595,42 @@ static int analyze(const uint8_t *buf, int size, int 
packet_size,
 return best_score - FFMAX(stat_all - 10*best_score, 0)/10;
 }
 
-/* autodetect fec presence. Must have at least 1024 bytes  */
-static int get_packet_size(const uint8_t *buf, int size)
+/* autodetect fec presence */
+static int get_packet_size(AVIOContext* pb)
 {
 int score, fec_score, dvhs_score;
+int margin;
+int ret;
 
-if (size < (TS_FEC_PACKET_SIZE * 5 + 1))
-return AVERROR_INVALIDDATA;
+/*init buffer to store stream for probing */
+uint8_t buf[PROBE_PACKET_MAX_BUF] = {0};
+int buf_size = 0;
 
-score  = analyze(buf, size, TS_PACKET_SIZE,  0);
-dvhs_score = analyze(buf, size, TS_DVHS_PACKET_SIZE, 0);
-fec_score  = analyze(buf, size, TS_FEC_PACKET_SIZE,  0);
-av_log(NULL, AV_LOG_TRACE, "score: %d, dvhs_score: %d, fec_score: %d \n",
-score, dvhs_score, fec_score);
-
-if (score > fec_score && score > dvhs_score)
-return TS_PACKET_SIZE;
-else if (dvhs_score > score && dvhs_score > fec_score)
-return TS_DVHS_PACKET_SIZE;
-else if (score < fec_score && dvhs_score < fec_score)
-return TS_FEC_PACKET_SIZE;
-else
-return AVERROR_INVALIDDATA;
+while (buf_size + PROBE_PACKET_STEP <= PROBE_PACKET_MAX_BUF) {
+ret = avio_read(pb, buf + buf_size, PROBE_PACKET_STEP);
+if (ret < 0)
+break;
+buf_size += ret;
+
+score  = analyze(buf, buf_size, TS_PACKET_SIZE,  0);
+dvhs_score = analyze(buf, buf_size, TS_DVHS_PACKET_SIZE, 0);
+fec_score  = analyze(buf, buf_size, TS_FEC_PACKET_SIZE,  0);
+av_log(NULL, AV_LOG_TRACE, "Probe: %d, score: %d, dvhs_score: %d, 
fec_score: %d \n",
+buf_size, score, dvhs_score, fec_score);
+
+if (buf_size < PROBE_PACKET_MAX_BUF && ret == PROBE_PACKET_STEP)
+  margin = PROBE_PACKET_MARGIN; /*if buffer not filled and no eof */
+else
+  margin = 0;
+
+if (score > FFMAX(fec_score, dvhs_score) + margin)
+  return TS_PACKET_SIZE;
+else if (dvhs_score > FFMAX(score, fec_score) + margin)
+  return TS_DVHS_PACKET_SIZE;
+else if (fec_score > FFMAX(score, dvhs_score) + margin)
+  return TS_FEC_PACKET_SIZE;
+}
+return AVERROR_INVALIDDATA;
 }
 
 typedef struct SectionHeader {
@@ -2841,8 +2859,6 @@ static int mpegts_read_header(AVFormatContext *s)
 {
 MpegTSContext *ts = s->priv_data;
 AVIOContext *pb   = s->pb;
-uint8_t buf[8 * 1024] = {0};
-int len;
 int64_t pos, probesize = s->probesize;
 
 s->internal->prefer_codec_framerate = 1;
@@ -2850,10 +2866,8 @@ static int mpegts_read_header(AVFormatContext *s)
 if (ffio_ensure_seekback(pb, probesize) < 0)
 av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n");
 
-/* read the first 8192 bytes to get packet size */
 pos = avio_tell(pb);
-len = avio_read(pb, buf, sizeof(buf));
-ts->raw_packet_size = get_packet_size(buf, len);
+ts->raw_packet_size = get_packet_size(pb);
 if (ts->raw_packet_size <= 0) {
 av_log(s, AV_LOG_WARNING, "Could not detect TS packet size, defaulting 
to non-FEC/DVHS\n");
 ts->raw_packet_size = TS_PACKET_SIZE;
-- 
2.20.1

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


Re: [FFmpeg-devel] [PATCH] libavcodec/vp8dec: fix the multi-thread HWAccel decode error

2019-03-05 Thread Li, Zhong
> > > if (width  != s->avctx->width || ((width+15)/16 != s->mb_width ||
> > > (height+15)/16 != s->mb_height) && s->macroblocks_base ||
> > > height != s->avctx->height) {
> > >...
> > >ff_set_dimensions(...);
> > > }
> > >
> > > The condition for updating dimensions is simple in VP9:
> >
> > Now I didn't test VP9 decoder in this case
> 
> Yes, this patch is for VP8 decoder only. What I mean is that
> ff_set_dimensions()
> is called too when {width, height} are changed without allocated
> macroblocks_base. So dim_reset should be 1 instead of
> (s->macroblocks_base !=
> NULL) in the patch.

Agree dim-reset should be 1, and this comment should be addressed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mov: fix hang while seek on a kind of fragmented mp4.

2019-03-05 Thread C.H.Liu
Yes. Patch aa25198f1b925a464bdfa83a98476f08d26c9209 works to ticket 7572
luckily. To reproduce #7572, need to revert this patch first.
As we talked, #7572 has a deeper reason. Mov demuxer consider that
fragmented index is completed if a ‘sidx’ point to the end of the file. But
there may be other ‘sidx’ for other tracks. If we skip the tail from there,
we will missing the last ‘sidx’ and ‘moof’. Then AV_NOPTS_VALUE occurs.

On Wed, Mar 6, 2019 at 2:35 AM Anthony Recascino 
wrote:

> the bug that caused the hang is absolutely still present, the fix that was
> pushed was only fixing the surface level issue of the hang.
>
>
> > On Mar 5, 2019, at 11:28 AM, Carl Eugen Hoyos 
> wrote:
> >
> > 2019-03-05 17:02 GMT+01:00, Charles Liu :
> >> 1. organize fragmented information according to the tracks.
> >> 2. do NOT skip the last boxes of fragmented info.
> >
> >> ticket #7572
> >
> > Assuming the ticket is not reproducible for you with current
> > FFmpeg git head (it wasn't for me two weeks ago), please
> > reword this so it is clear you saw an issue looking at this
> > ticket (and its fix) but that this commit does not fix a bug
> > that is still reproducible with the files and command line(s)
> > provided there.
> >
> > Or do I misunderstand?
> >
> > Carl Eugen
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mov: fix hang while seek on a kind of fragmented mp4.

2019-03-05 Thread Carl Eugen Hoyos
2019-03-06 8:46 GMT+01:00, C.H.Liu :
> Yes. Patch aa25198f1b925a464bdfa83a98476f08d26c9209 works to ticket 7572
> luckily. To reproduce #7572, need to revert this patch first.
> As we talked, #7572 has a deeper reason.

> Mov demuxer consider that
> fragmented index is completed if a ‘sidx’ point to the end of the file. But
> there may be other ‘sidx’ for other tracks. If we skip the tail from there,
> we will missing the last ‘sidx’ and ‘moof’. Then AV_NOPTS_VALUE occurs.

Please explain this in the commit message and please do not top-post here.

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


Re: [FFmpeg-devel] [PATCH v2] avformat/mpegts: reduce buffering during initialization

2019-03-05 Thread Carl Eugen Hoyos
2019-03-06 7:01 GMT+01:00, Andriy Gelman :
> From: Andriy Gelman 
>
> Reduces buffering latency with low bitrate streams, where
> 8192 bytes can mean several seconds.

Would it be an alternative to add an option that allows to force
the packet size?

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


Re: [FFmpeg-devel] [PATCH 3/4] lavfi/nlmeans: Checking number precision when computing integral images

2019-03-05 Thread Carl Eugen Hoyos
2019-03-06 4:18 GMT+01:00, Jun Zhao :
> From: Jun Zhao 
>
> accumulation of 8-bits uint_8 (uint8_t *src) into 32-bits (uint32_t *ii)
> data type, it will have a risk of an integral value becoming larger than
> the 32-bits integer capacity and resulting in an integer overflow. For
> this risk, add a checking with warning message.
>
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/vf_nlmeans.c |7 +++
>  1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/libavfilter/vf_nlmeans.c b/libavfilter/vf_nlmeans.c
> index dcb5a03..31c8304 100644
> --- a/libavfilter/vf_nlmeans.c
> +++ b/libavfilter/vf_nlmeans.c
> @@ -236,6 +236,13 @@ static void compute_ssd_integral_image(const
> NLMeansDSPContext *dsp,
>  // adjusted end x position of the safe area after width of the safe
> area gets aligned
>  const int endx_safe = startx_safe + safe_pw;
>
> +// accumulation of 8-bits uint_8 (uint8_t *src) into 32-bits (uint32_t
> *ii)
> +// data type, it will have a risk of an integral value becoming larger
> than
> +// the 32-bits integer capacity and resulting in an integer overflow.
> +if ((w * h * UINT8_MAX) > UINT32_MAX)

I don't think UINT8_MAX increases readability and I suspect
this should contain "UINT32_MAX / (w*h)" or similar on
one side.

> +av_log(NULL, AV_LOG_WARNING,
> +   "image (%d x %d) integral value maybe overflow.\n", w ,h);

may overflow?

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


Re: [FFmpeg-devel] [PATCH] libavcodec/vp8dec: fix the multi-thread HWAccel decode error

2019-03-05 Thread Carl Eugen Hoyos
2018-08-09 9:09 GMT+02:00, Jun Zhao :
> the root cause is update_dimentions call get_pixel_format will
> trigger the hwaccel_uninit/hwaccel_init , in current context,
> there are 3 situations in the update_dimentions():
> 1. First time calling. No matter single thread or multithread,
>get_pixel_format() should be called after dimentions were
>set;
> 2. Dimention changed at the runtime. Dimention need to be
>updated when macroblocks_base is already allocated,
>get_pixel_format() should be called to recreate new frames
>according to updated dimention;
> 3. Multithread first time calling. After decoder init, the
>other threads will call update_dimentions() at first time
>to allocate macroblocks_base and set dimentions.
>But get_pixel_format() is shouldn't be called due to low
>level frames and context are already created.
> In this fix, we only call update_dimentions as need.
>
> Signed-off-by: Wang, Shaofei 
> Reviewed-by: Jun, Zhao 
> ---
>  libavcodec/vp8.c |7 +--
>  1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> index 3adfeac..18d1ada 100644
> --- a/libavcodec/vp8.c
> +++ b/libavcodec/vp8.c
> @@ -187,7 +187,7 @@ static av_always_inline
>  int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
>  {
>  AVCodecContext *avctx = s->avctx;
> -int i, ret;
> +int i, ret, dim_reset = 0;
>
>  if (width  != s->avctx->width || ((width+15)/16 != s->mb_width ||
> (height+15)/16 != s->mb_height) && s->macroblocks_base ||
>  height != s->avctx->height) {
> @@ -196,9 +196,12 @@ int update_dimensions(VP8Context *s, int width, int
> height, int is_vp7)
>  ret = ff_set_dimensions(s->avctx, width, height);
>  if (ret < 0)
>  return ret;
> +
> +dim_reset = (s->macroblocks_base != NULL);
>  }
>
> -if (!s->actually_webp && !is_vp7) {
> +if ((s->pix_fmt == AV_PIX_FMT_NONE || dim_reset) &&
> + !s->actually_webp && !is_vp7) {

Why is the new variable dim_reset needed?
Wouldn't the patch be simpler if you used s->macroblocks_base
here?

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


Re: [FFmpeg-devel] avcodec/proresenc_aw : improve speed by replacing PutBitContext for codeword encoding

2019-03-05 Thread Carl Eugen Hoyos
2019-02-27 17:50 GMT+01:00, Martin Vignali :
>>
>> Shouldn’t there be a 64Bit PutBitContext instead so other encoders can
>> also profit?
>
> I only use here a small part of putbitcontext, and in an "unsafe" mode (the
> buffer of the prores aw encoder is big enough to not check it, and write 64
> bits during the flush even if less can be use (to keep code more simple))

Not sure if this justifies not adding the new code to PutBitContext: it doesn't
have to work for all situations, only for the encoder that initially uses it.

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