[FFmpeg-cvslog] avcodec/libdav1d: reset pool size on allocation failure
ffmpeg | branch: master | James Almer | Fri Mar 15 23:55:45 2019 -0300| [5cd60b6f2ed8a30341e8f98a38858c18505f6f75] | committer: James Almer avcodec/libdav1d: reset pool size on allocation failure Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5cd60b6f2ed8a30341e8f98a38858c18505f6f75 --- libavcodec/libdav1d.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 8c8584f4e8..d9079cbbef 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -72,8 +72,10 @@ static int libdav1d_picture_allocator(Dav1dPicture *p, void *cookie) 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) +if (!dav1d->pool) { +dav1d->pool_size = 0; return AVERROR(ENOMEM); +} dav1d->pool_size = ret; } buf = av_buffer_pool_get(dav1d->pool); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/libdav1d: use a reference to the allocated buffer instead of wrapping the Dav1dPicture
ffmpeg | branch: master | James Almer | Mon Mar 18 10:38:31 2019 -0300| [9e62e1a1104bb0d64e604051ffc25004ad748eaf] | committer: James Almer avcodec/libdav1d: use a reference to the allocated buffer instead of wrapping the Dav1dPicture Removes an av_malloc() per frame. Reviewed-by: BBB Reviewed-by: nevcairiel Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e62e1a1104bb0d64e604051ffc25004ad748eaf --- libavcodec/libdav1d.c | 20 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index d9079cbbef..30c6eccfef 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -149,18 +149,11 @@ static void libdav1d_data_free(const uint8_t *data, void *opaque) { av_buffer_unref(&buf); } -static void libdav1d_frame_free(void *opaque, uint8_t *data) { -Dav1dPicture *p = opaque; - -dav1d_picture_unref(p); -av_free(p); -} - static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) { Libdav1dContext *dav1d = c->priv_data; Dav1dData *data = &dav1d->data; -Dav1dPicture *p; +Dav1dPicture pic = { 0 }, *p = &pic; int res; if (!data->sz) { @@ -194,10 +187,6 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) return res; } -p = av_mallocz(sizeof(*p)); -if (!p) -return AVERROR(ENOMEM); - res = dav1d_get_picture(dav1d->c, p); if (res < 0) { if (res == AVERROR(EINVAL)) @@ -205,17 +194,15 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) else if (res == AVERROR(EAGAIN) && c->internal->draining) res = AVERROR_EOF; -av_free(p); return res; } av_assert0(p->data[0] != NULL); -frame->buf[0] = av_buffer_create(NULL, 0, libdav1d_frame_free, - p, AV_BUFFER_FLAG_READONLY); +// This requires the custom allocator above +frame->buf[0] = av_buffer_ref(p->allocator_data); if (!frame->buf[0]) { dav1d_picture_unref(p); -av_free(p); return AVERROR(ENOMEM); } @@ -310,6 +297,7 @@ FF_ENABLE_DEPRECATION_WARNINGS res = 0; fail: +dav1d_picture_unref(p); if (res < 0) av_frame_unref(frame); return res; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] h2645_parse: Fix loglevel for NAL header parsing
ffmpeg | branch: master | Derek Buitenhuis | Mon Mar 18 19:18:11 2019 +| [90b85ab21fcb2895d4cf25527179ea0fa5f08ec0] | committer: Derek Buitenhuis h2645_parse: Fix loglevel for NAL header parsing We don't treat this as an error. Signed-off-by: Derek Buitenhuis > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=90b85ab21fcb2895d4cf25527179ea0fa5f08ec0 --- libavcodec/h2645_parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c index 942f2c5d71..24658b3dfa 100644 --- a/libavcodec/h2645_parse.c +++ b/libavcodec/h2645_parse.c @@ -499,7 +499,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, ret = h264_parse_nal_header(nal, logctx); if (ret <= 0 || nal->size <= 0 || nal->size_bits <= 0) { if (ret < 0) { -av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n", +av_log(logctx, AV_LOG_WARNING, "Invalid NAL unit %d, skipping.\n", nal->type); } pkt->nb_nals--; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] doc/ffmpeg: remove entry for -loop_output
ffmpeg | branch: master | Gyan Doshi | Wed Mar 20 02:34:17 2019 +0530| [41ef6dd67d48f13a18ba0fa3e2dc1bc448a0ecbb] | committer: Gyan Doshi doc/ffmpeg: remove entry for -loop_output Option doesn't exist .. hasn't for a few years now. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=41ef6dd67d48f13a18ba0fa3e2dc1bc448a0ecbb --- doc/ffmpeg.texi | 4 1 file changed, 4 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index ce051d1fed..0650dd9b3f 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1396,10 +1396,6 @@ loss). By default @command{ffmpeg} attempts to read the input(s) as fast as possible. This option will slow down the reading of the input(s) to the native frame rate of the input(s). It is useful for real-time output (e.g. live streaming). -@item -loop_output @var{number_of_times} -Repeatedly loop output for formats that support looping such as animated GIF -(0 will loop the output infinitely). -This option is deprecated, use -loop. @item -vsync @var{parameter} Video sync method. For compatibility reasons old values can be specified as numbers. ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/vt_hevc: fix crash if vps_list[0] or sps_list[0] are null
ffmpeg | branch: master | Rodger Combs | Wed Jan 9 21:26:41 2019 -0500| [ce6301a46fae4858218c7435f9e7fc94d9dd39b2] | committer: Aman Gupta avcodec/vt_hevc: fix crash if vps_list[0] or sps_list[0] are null Instead of assuming id 0 is used, use the same logic as used for PPS, where all available entries in the list are emitted. Signed-off-by: Aman Gupta > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ce6301a46fae4858218c7435f9e7fc94d9dd39b2 --- libavcodec/videotoolbox.c | 86 ++- 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index da7236f100..fb3501f413 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -176,26 +176,31 @@ CFDataRef ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx) CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx) { HEVCContext *h = avctx->priv_data; -const HEVCVPS *vps = (const HEVCVPS *)h->ps.vps_list[0]->data; -const HEVCSPS *sps = (const HEVCSPS *)h->ps.sps_list[0]->data; -int i, num_pps = 0; +int i, num_vps = 0, num_sps = 0, num_pps = 0; +const HEVCVPS *vps = h->ps.vps; +const HEVCSPS *sps = h->ps.sps; const HEVCPPS *pps = h->ps.pps; PTLCommon ptlc = vps->ptl.general_ptl; VUI vui = sps->vui; uint8_t parallelismType; CFDataRef data = NULL; uint8_t *p; -int vt_extradata_size = 23 + 5 + vps->data_size + 5 + sps->data_size + 3; +int vt_extradata_size = 23 + 3 + 3 + 3; uint8_t *vt_extradata; -for (i = 0; i < HEVC_MAX_PPS_COUNT; i++) { -if (h->ps.pps_list[i]) { -const HEVCPPS *pps = (const HEVCPPS *)h->ps.pps_list[i]->data; -vt_extradata_size += 2 + pps->data_size; -num_pps++; -} +#define COUNT_SIZE_PS(T, t) \ +for (i = 0; i < HEVC_MAX_##T##PS_COUNT; i++) { \ +if (h->ps.t##ps_list[i]) { \ +const HEVC##T##PS *lps = (const HEVC##T##PS *)h->ps.t##ps_list[i]->data; \ +vt_extradata_size += 2 + lps->data_size; \ +num_##t##ps++; \ +} \ } +COUNT_SIZE_PS(V, v) +COUNT_SIZE_PS(S, s) +COUNT_SIZE_PS(P, p) + vt_extradata = av_malloc(vt_extradata_size); if (!vt_extradata) return NULL; @@ -286,44 +291,33 @@ CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx) AV_W8(p + 22, 3); p += 23; -/* vps */ -/* - * bit(1) array_completeness; - * unsigned int(1) reserved = 0; - * unsigned int(6) NAL_unit_type; - */ -AV_W8(p, 1 << 7 | - HEVC_NAL_VPS & 0x3f); -/* unsigned int(16) numNalus; */ -AV_WB16(p + 1, 1); -/* unsigned int(16) nalUnitLength; */ -AV_WB16(p + 3, vps->data_size); -/* bit(8*nalUnitLength) nalUnit; */ -memcpy(p + 5, vps->data, vps->data_size); -p += 5 + vps->data_size; - -/* sps */ -AV_W8(p, 1 << 7 | - HEVC_NAL_SPS & 0x3f); -AV_WB16(p + 1, 1); -AV_WB16(p + 3, sps->data_size); -memcpy(p + 5, sps->data, sps->data_size); -p += 5 + sps->data_size; - -/* pps */ -AV_W8(p, 1 << 7 | - HEVC_NAL_PPS & 0x3f); -AV_WB16(p + 1, num_pps); -p += 3; -for (i = 0; i < HEVC_MAX_PPS_COUNT; i++) { -if (h->ps.pps_list[i]) { -const HEVCPPS *pps = (const HEVCPPS *)h->ps.pps_list[i]->data; -AV_WB16(p, pps->data_size); -memcpy(p + 2, pps->data, pps->data_size); -p += 2 + pps->data_size; -} + +#define APPEND_PS(T, t) \ +/* \ + * bit(1) array_completeness; \ + * unsigned int(1) reserved = 0; \ + * unsigned int(6) NAL_unit_type; \ + */ \ +AV_W8(p, 1 << 7 | \ + HEVC_NAL_##T##PS & 0x3f); \ +/* unsigned int(16) numNalus; */ \ +AV_WB16(p + 1, num_##t##ps); \ +p += 3; \ +for (i = 0; i < HEVC_MAX_##T##PS_COUNT; i++) { \ +if (h->ps.t##ps_list[i]) { \ +const HEVC##T##PS *lps = (const HEVC##T##PS *)h->ps.t##ps_list[i]->data; \ +/* unsigned int(16) nalUnitLength; */ \ +AV_WB16(p, lps->data_size); \ +/* bit(8*nalUnitLength) nalUnit; */ \ +memcpy(p + 2, lps->data, lps->data_size); \ +p += 2 + lps->data_size; \ +} \ } +APPEND_PS(V, v) +APPEND_PS(S, s) +APPEND_PS(P, p) + av_assert0(p - vt_extradata == vt_extradata_size); data = CFDataCreate(kCFAllocatorDefault, vt_extradata, vt_extradata_size); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/smoothstreamingenc:add bitrate calculate
ffmpeg | branch: master | Jun Li | Wed Mar 20 13:49:02 2019 +0800| [0739d5cd5c925a157ab210e4424f82d98349528d] | committer: Steven Liu avformat/smoothstreamingenc:add bitrate calculate Calculate bitrate based on fragment size, only applied when bitrate is not set, for example rtsp source. Reviewed-by: Steven Liu Signed-off-by: Jun Li > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0739d5cd5c925a157ab210e4424f82d98349528d --- libavformat/smoothstreamingenc.c | 32 +++- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index 094712af27..bd7f841dc7 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -320,11 +320,13 @@ 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); +// create a tmp name for the directory of fragments +snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(Tmp_%d)", 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 +521,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 +543,26 @@ 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 got zero.\n"); +ret = AVERROR(EINVAL); +return ret; +} + +av_log(s, AV_LOG_DEBUG, "calculated bitrate: %"PRId64"\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); + +// rename the tmp folder back to the correct name since we now have the bitrate +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); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog