[FFmpeg-cvslog] avfilter/vf_v360: fix hfov/vfov calculation from dfov for sg projection
ffmpeg | branch: master | Paul B Mahol | Wed Mar 25 13:38:01 2020 +0100| [0b4389753035c9a69116ea4a4a8caee213ed7c24] | committer: Paul B Mahol avfilter/vf_v360: fix hfov/vfov calculation from dfov for sg projection > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0b4389753035c9a69116ea4a4a8caee213ed7c24 --- libavfilter/vf_v360.c | 9 + 1 file changed, 9 insertions(+) diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c index ae94354212..fe0c9f3c4d 100644 --- a/libavfilter/vf_v360.c +++ b/libavfilter/vf_v360.c @@ -3542,6 +3542,15 @@ static int allocate_plane(V360Context *s, int sizeof_uv, int sizeof_ker, int siz static void fov_from_dfov(int format, float d_fov, float w, float h, float *h_fov, float *v_fov) { switch (format) { +case STEREOGRAPHIC: +{ +const float d = 0.5f * hypotf(w, h); +const float l = d / (tanf(d_fov * M_PI / 720.f)); + +*h_fov = 2.f * atan2f(w * 0.5f, l) * 360.f / M_PI; +*v_fov = 2.f * atan2f(h * 0.5f, l) * 360.f / M_PI; +} +break; case FISHEYE: { const float d = 0.5f * hypotf(w, h); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/libzvbi-teletextdec: replace data_size with got_sub_ptr for better readability
ffmpeg | branch: master | Limin Wang | Tue Mar 24 19:05:18 2020 +0800| [8ea4efffdb5c14e2fd2c822c9bac2cf62a5e9381] | committer: Michael Niedermayer avcodec/libzvbi-teletextdec: replace data_size with got_sub_ptr for better readability Signed-off-by: Limin Wang Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8ea4efffdb5c14e2fd2c822c9bac2cf62a5e9381 --- libavcodec/libzvbi-teletextdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/libzvbi-teletextdec.c b/libavcodec/libzvbi-teletextdec.c index fe6504ff8a..8031b02286 100644 --- a/libavcodec/libzvbi-teletextdec.c +++ b/libavcodec/libzvbi-teletextdec.c @@ -636,7 +636,7 @@ static int slice_to_vbi_lines(TeletextContext *ctx, uint8_t* buf, int size) return lines; } -static int teletext_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt) +static int teletext_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *pkt) { TeletextContext *ctx = avctx->priv_data; AVSubtitle *sub = data; @@ -724,9 +724,9 @@ FF_ENABLE_DEPRECATION_WARNINGS ctx->nb_pages--; if (ret >= 0) -*data_size = 1; +*got_sub_ptr = 1; } else -*data_size = 0; +*got_sub_ptr = 0; return ret; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/xsubdec: replace data_size with got_sub_ptr for better readability
ffmpeg | branch: master | Limin Wang | Tue Mar 24 19:05:16 2020 +0800| [2d244c9a00025acd1745ce9d89f2c681d8e99fd1] | committer: Michael Niedermayer avcodec/xsubdec: replace data_size with got_sub_ptr for better readability Signed-off-by: Limin Wang Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d244c9a00025acd1745ce9d89f2c681d8e99fd1 --- libavcodec/xsubdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 05c4a64ee5..c1c6e11dc3 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -46,7 +46,7 @@ static int64_t parse_timecode(const uint8_t *buf, int64_t packet_time) { return ms - packet_time; } -static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, +static int decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; @@ -169,7 +169,7 @@ FF_ENABLE_DEPRECATION_WARNINGS bitmap += w; align_get_bits(&gb); } -*data_size = 1; +*got_sub_ptr = 1; return buf_size; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/pgssubdec: replace data_size with got_sub_ptr for better readability
ffmpeg | branch: master | Limin Wang | Tue Mar 24 19:05:17 2020 +0800| [766888e5194d2fd4f6543c9d759cb66133274f83] | committer: Michael Niedermayer avcodec/pgssubdec: replace data_size with got_sub_ptr for better readability Signed-off-by: Limin Wang Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=766888e5194d2fd4f6543c9d759cb66133274f83 --- libavcodec/pgssubdec.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 7fadcb8b4b..9c59a2297f 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -614,7 +614,7 @@ FF_ENABLE_DEPRECATION_WARNINGS return 1; } -static int decode(AVCodecContext *avctx, void *data, int *data_size, +static int decode(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; @@ -636,7 +636,7 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, if (i & 15) ff_dlog(avctx, "\n"); -*data_size = 0; +*got_sub_ptr = 0; /* Ensure that we have received at a least a segment code and segment length */ if (buf_size < 3) @@ -676,14 +676,14 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, */ break; case DISPLAY_SEGMENT: -if (*data_size) { +if (*got_sub_ptr) { av_log(avctx, AV_LOG_ERROR, "Duplicate display segment\n"); ret = AVERROR_INVALIDDATA; break; } ret = display_end_segment(avctx, data, buf, segment_length); if (ret >= 0) -*data_size = ret; +*got_sub_ptr = ret; break; default: av_log(avctx, AV_LOG_ERROR, "Unknown subtitle segment type 0x%x, length %d\n", @@ -693,7 +693,7 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, } if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) { avsubtitle_free(data); -*data_size = 0; +*got_sub_ptr = 0; return ret; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/dvbsubdec: replace data_size with got_sub_ptr for better readability
ffmpeg | branch: master | Limin Wang | Tue Mar 24 19:05:19 2020 +0800| [157873623f0e0278db5bf5164387d8cc4eac90a0] | committer: Michael Niedermayer avcodec/dvbsubdec: replace data_size with got_sub_ptr for better readability Signed-off-by: Limin Wang Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=157873623f0e0278db5bf5164387d8cc4eac90a0 --- libavcodec/dvbsubdec.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 6e7e13b6eb..f63a1f3bf6 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -1610,7 +1610,7 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, } static int dvbsub_decode(AVCodecContext *avctx, - void *data, int *data_size, + void *data, int *got_sub_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; @@ -1668,7 +1668,7 @@ static int dvbsub_decode(AVCodecContext *avctx, int ret = 0; switch (segment_type) { case DVBSUB_PAGE_SEGMENT: -ret = dvbsub_parse_page_segment(avctx, p, segment_length, sub, data_size); +ret = dvbsub_parse_page_segment(avctx, p, segment_length, sub, got_sub_ptr); got_segment |= 1; break; case DVBSUB_REGION_SEGMENT: @@ -1690,7 +1690,7 @@ static int dvbsub_decode(AVCodecContext *avctx, got_dds = 1; break; case DVBSUB_DISPLAY_SEGMENT: -ret = dvbsub_display_end_segment(avctx, p, segment_length, sub, data_size); +ret = dvbsub_display_end_segment(avctx, p, segment_length, sub, got_sub_ptr); if (got_segment == 15 && !got_dds && !avctx->width && !avctx->height) { // Default from ETSI EN 300 743 V1.3.1 (7.2.1) avctx->width = 720; @@ -1713,12 +1713,12 @@ static int dvbsub_decode(AVCodecContext *avctx, // segments then we need no further data. if (got_segment == 15) { av_log(avctx, AV_LOG_DEBUG, "Missing display_end_segment, emulating\n"); -dvbsub_display_end_segment(avctx, p, 0, sub, data_size); +dvbsub_display_end_segment(avctx, p, 0, sub, got_sub_ptr); } end: if(ret < 0) { -*data_size = 0; +*got_sub_ptr = 0; avsubtitle_free(sub); return ret; } else { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroska: add missing Buttons track type
ffmpeg | branch: master | Steve Lhomme | Sun Mar 22 09:59:20 2020 +0100| [a95351ea502296f2ce420dc1e4feeeb2e536a0be] | committer: Andreas Rheinhardt avformat/matroska: add missing Buttons track type Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a95351ea502296f2ce420dc1e4feeeb2e536a0be --- libavformat/matroska.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 86968a8de1..9e33e51c94 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -271,6 +271,7 @@ typedef enum { MATROSKA_TRACK_TYPE_COMPLEX = 0x3, MATROSKA_TRACK_TYPE_LOGO = 0x10, MATROSKA_TRACK_TYPE_SUBTITLE = 0x11, + MATROSKA_TRACK_TYPE_BUTTONS = 0x12, MATROSKA_TRACK_TYPE_CONTROL = 0x20, MATROSKA_TRACK_TYPE_METADATA = 0x21, } MatroskaTrackType; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webmdashenc: Don't use custom option for bitexactness
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 17 23:13:05 2020 +0100| [00d0934fcedad8e6418b066ab89552659271db00] | committer: Andreas Rheinhardt avformat/webmdashenc: Don't use custom option for bitexactness The WebM DASH Manifest muxer can write manifests for live streams and these contain an entry that depends on the time the manifest is written; an AVOption to make the output reproducible has been added for tests. But this is unnecessary, as there already is a method for reproducible output: The AVFMT_FLAG_BITEXACT-flag of the AVFormatContext. Therefore this commit removes the custom option. Given that the description of said option contained "private option - users should never set this" and that it was not documented in muxers.texi, no deprecation period for this option seemed necessary. The commands of the FATE-tests for this muxer have been changed to no longer use this option. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=00d0934fcedad8e6418b066ab89552659271db00 --- libavformat/webmdashenc.c | 4 +--- tests/fate/vpx.mak| 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index d2f0e0ec4d..0e7bfba34c 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -57,7 +57,6 @@ typedef struct WebMDashMuxContext { char *utc_timing_url; double time_shift_buffer_depth; int minimum_update_period; -int debug_mode; } WebMDashMuxContext; static const char *get_codec_name(int codec_id) @@ -114,7 +113,7 @@ static int write_header(AVFormatContext *s) if (!strftime(gmt_iso, 21, "%Y-%m-%dT%H:%M:%SZ", gmt)) { return AVERROR_UNKNOWN; } -if (w->debug_mode) { +if (s->flags & AVFMT_FLAG_BITEXACT) { av_strlcpy(gmt_iso, "", 1); } avio_printf(s->pb, " availabilityStartTime=\"%s\"\n", gmt_iso); @@ -553,7 +552,6 @@ static int webm_dash_manifest_write_packet(AVFormatContext *s, AVPacket *pkt) #define OFFSET(x) offsetof(WebMDashMuxContext, x) static const AVOption options[] = { { "adaptation_sets", "Adaptation sets. Syntax: id=0,streams=0,1,2 id=1,streams=3,4 and so on", OFFSET(adaptation_sets), AV_OPT_TYPE_STRING, { 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, -{ "debug_mode", "[private option - users should never set this]. Create deterministic output", OFFSET(debug_mode), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM }, { "live", "create a live stream manifest", OFFSET(is_live), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM }, { "chunk_start_index", "start index of the chunk", OFFSET(chunk_start_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "chunk_duration_ms", "duration of each chunk (in milliseconds)", OFFSET(chunk_duration), AV_OPT_TYPE_INT, {.i64 = 1000}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, diff --git a/tests/fate/vpx.mak b/tests/fate/vpx.mak index 3b3da18feb..c65959f133 100644 --- a/tests/fate/vpx.mak +++ b/tests/fate/vpx.mak @@ -71,10 +71,10 @@ FATE_VP8-$(CONFIG_WEBM_DASH_MANIFEST_DEMUXER) += fate-webm-dash-manifest-represe fate-webm-dash-manifest-representations: CMD = run $(FFMPEG) -nostdin -f webm_dash_manifest -i $(TARGET_SAMPLES)/vp8/dash_video1.webm -f webm_dash_manifest -i $(TARGET_SAMPLES)/vp8/dash_video4.webm -c copy -map 0 -map 1 -f webm_dash_manifest -adaptation_sets "id=0,streams=0,1" - FATE_VP8-$(CONFIG_WEBM_DASH_MANIFEST_DEMUXER) += fate-webm-dash-manifest-live -fate-webm-dash-manifest-live: CMD = run $(FFMPEG) -nostdin -f webm_dash_manifest -live 1 -i $(TARGET_SAMPLES)/vp8/dash_live_video_360.hdr -f webm_dash_manifest -live 1 -i $(TARGET_SAMPLES)/vp8/dash_live_audio_171.hdr -c copy -map 0 -map 1 -f webm_dash_manifest -live 1 -adaptation_sets "id=0,streams=0 id=1,streams=1" -chunk_start_index 1 -chunk_duration_ms 5000 -time_shift_buffer_depth 7200 -minimum_update_period 60 -debug_mode 1 - +fate-webm-dash-manifest-live: CMD = run $(FFMPEG) -nostdin -f webm_dash_manifest -live 1 -i $(TARGET_SAMPLES)/vp8/dash_live_video_360.hdr -f webm_dash_manifest -live 1 -i $(TARGET_SAMPLES)/vp8/dash_live_audio_171.hdr -c copy -map 0 -map 1 -fflags +bitexact -f webm_dash_manifest -live 1 -adaptation_sets "id=0,streams=0 id=1,streams=1" -chunk_start_index 1 -chunk_duration_ms 5000 -time_shift_buffer_depth 7200 -minimum_update_period 60 - FATE_VP8-$(CONFIG_WEBM_DASH_MANIFEST_DEMUXER) += fate-webm-dash-manifest-live-bandwidth -fate-webm-dash-manifest-live-bandwidth: CMD = run $(FFMPEG) -nostdin -f webm_dash_manifest -live 1 -bandwidth 100 -i $(TARGET_SAMPLES)/vp8/dash_live_video_360.hdr -f webm_dash_manifest -live 1 -bandwidth 200 -i $(TARGET_SAMPLES)/vp8/dash_live_audio_171.hdr -c copy -map 0 -map 1 -f webm_dash_manifest -live 1 -adaptation_sets "id=0,streams=0 id=1,streams=1" -chunk_start_index 1 -chunk_duration_ms 5000 -time
[FFmpeg-cvslog] avformat/webm_chunk: Don't use child AVFormatContext for logging
ffmpeg | branch: master | Andreas Rheinhardt | Sat Feb 29 20:01:33 2020 +0100| [0b1af9d3306583af0ac8016f99017460c1d56aad] | committer: Andreas Rheinhardt avformat/webm_chunk: Don't use child AVFormatContext for logging Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0b1af9d3306583af0ac8016f99017460c1d56aad --- libavformat/webm_chunk.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 4e2ce21a79..d75fd5e6a3 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -87,25 +87,24 @@ static int chunk_mux_init(AVFormatContext *s) static int get_chunk_filename(AVFormatContext *s, int is_header, char filename[MAX_FILENAME_SIZE]) { WebMChunkContext *wc = s->priv_data; -AVFormatContext *oc = wc->avf; if (!filename) { return AVERROR(EINVAL); } if (is_header) { int len; if (!wc->header_filename) { -av_log(oc, AV_LOG_ERROR, "No header filename provided\n"); +av_log(s, AV_LOG_ERROR, "No header filename provided\n"); return AVERROR(EINVAL); } len = av_strlcpy(filename, wc->header_filename, MAX_FILENAME_SIZE); if (len >= MAX_FILENAME_SIZE) { -av_log(oc, AV_LOG_ERROR, "Header filename too long\n"); +av_log(s, AV_LOG_ERROR, "Header filename too long\n"); return AVERROR(EINVAL); } } else { if (av_get_frame_filename(filename, MAX_FILENAME_SIZE, s->url, wc->chunk_index - 1) < 0) { -av_log(oc, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url); +av_log(s, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url); return AVERROR(EINVAL); } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Close IO if writing header fails
ffmpeg | branch: master | Andreas Rheinhardt | Sat Feb 29 21:00:17 2020 +0100| [2a789688498b0715e4804ae2b7e36bee0cd65a63] | committer: Andreas Rheinhardt avformat/webm_chunk: Close IO if writing header fails Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2a789688498b0715e4804ae2b7e36bee0cd65a63 --- libavformat/webm_chunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index d75fd5e6a3..6daa6a0102 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -150,9 +150,9 @@ static int webm_chunk_write_header(AVFormatContext *s) oc->pb->seekable = 0; ret = oc->oformat->write_header(oc); +ff_format_io_close(s, &oc->pb); if (ret < 0) return ret; -ff_format_io_close(s, &oc->pb); for (i = 0; i < s->nb_streams; i++) { // ms precision is the de-facto standard timescale for mkv files. avpriv_set_pts_info(s->streams[i], 64, 1, 1000); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Copy more information to the child AVFormatContext
ffmpeg | branch: master | Andreas Rheinhardt | Sat Feb 29 21:09:29 2020 +0100| [b1b847ba56faa3aedad771b8e5916e0773552536] | committer: Andreas Rheinhardt avformat/webm_chunk: Copy more information to the child AVFormatContext In particular the flags are important so that AVFMT_FLAG_BITEXACT can be honoured by the child muxer. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b1b847ba56faa3aedad771b8e5916e0773552536 --- libavformat/webm_chunk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 6daa6a0102..24cabe942e 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -70,6 +70,9 @@ static int chunk_mux_init(AVFormatContext *s) oc->interrupt_callback = s->interrupt_callback; oc->max_delay = s->max_delay; +oc->flags = s->flags; +oc->strict_std_compliance = s->strict_std_compliance; + av_dict_copy(&oc->metadata, s->metadata, 0); *(const AVClass**)oc->priv_data = oc->oformat->priv_class; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Use appropriate initializer for AV_OPT_TYPE_STRING
ffmpeg | branch: master | Andreas Rheinhardt | Sat Feb 29 21:52:08 2020 +0100| [a9004ffe0f46617ab2a4725f329758a05b3ed185] | committer: Andreas Rheinhardt avformat/webm_chunk: Use appropriate initializer for AV_OPT_TYPE_STRING Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a9004ffe0f46617ab2a4725f329758a05b3ed185 --- libavformat/webm_chunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 24cabe942e..74aead4f5c 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -267,7 +267,7 @@ fail: #define OFFSET(x) offsetof(WebMChunkContext, x) static const AVOption options[] = { { "chunk_start_index", "start index of the chunk", OFFSET(chunk_start_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, -{ "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, { 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, +{ "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "audio_chunk_duration", "duration of each chunk in milliseconds", OFFSET(chunk_duration), AV_OPT_TYPE_INT, {.i64 = 5000}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "method", "set the HTTP method", OFFSET(http_method), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Use API functions for child muxer
ffmpeg | branch: master | Andreas Rheinhardt | Sat Feb 29 22:47:26 2020 +0100| [e70c2d02fc5c12b82628c6f6eda4dfd357685e8c] | committer: Andreas Rheinhardt avformat/webm_chunk: Use API functions for child muxer instead of calling the write_header/packet/trailer functions directly via the function pointers. Also, use distinct AVStreams for the child AVFormatContext (up until now the two AVFormatContexts shared their AVStreams because allocating their own was deemed too onerous). Using the function pointers directly meant that the Matroska muxer's init-function was never called, because init-functions were only introduced a few months after webm_chunk has been added and no one thought of/bothered to adapt webm_chunk for this (when the init-function was added in b287d7ea, the code setting the timebase was moved to it, so that the timebases were no longer set to ms-precision when using the webm_chunk muxer; this has been fixed after some time in 42a635dd by setting the timebases direcly (instead of calling the init-function)). And when 982a98a0 added a deinit-function for the Matroska muxer, it introduced memleaks in webm_chunk, because the child muxer's internal structures were no longer freed when calling write_trailer directly. (Given that the init function has never ever been called, the child muxer has never ever been properly initialized, so that the deinit-function was not called when freeing the child context.) This commit stops calling the function pointers directly and instead uses the standard API functions for muxers. This fixes the above mentioned memleaks. (Memleaks are still possible on error. This will be fixed in a future commit that adds a deinit-function to webm_chunk itself.) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e70c2d02fc5c12b82628c6f6eda4dfd357685e8c --- libavformat/webm_chunk.c | 59 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 74aead4f5c..9e4c375c3f 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -61,6 +61,8 @@ static int chunk_mux_init(AVFormatContext *s) { WebMChunkContext *wc = s->priv_data; AVFormatContext *oc; +AVStream *st, *ost = s->streams[0]; +AVDictionary *dict = NULL; int ret; ret = avformat_alloc_output_context2(&wc->avf, wc->oformat, NULL, NULL); @@ -72,17 +74,42 @@ static int chunk_mux_init(AVFormatContext *s) oc->max_delay = s->max_delay; oc->flags = s->flags; oc->strict_std_compliance = s->strict_std_compliance; +oc->avoid_negative_ts = s->avoid_negative_ts; av_dict_copy(&oc->metadata, s->metadata, 0); -*(const AVClass**)oc->priv_data = oc->oformat->priv_class; -av_opt_set_defaults(oc->priv_data); -av_opt_set_int(oc->priv_data, "dash", 1, 0); -av_opt_set_int(oc->priv_data, "cluster_time_limit", wc->chunk_duration, 0); -av_opt_set_int(oc->priv_data, "live", 1, 0); +if (!(st = avformat_new_stream(oc, NULL))) +return AVERROR(ENOMEM); + +if ((ret = avcodec_parameters_copy(st->codecpar, ost->codecpar)) < 0 || +(ret = av_dict_copy(&st->metadata, ost->metadata, 0))< 0) +return ret; + +st->sample_aspect_ratio = ost->sample_aspect_ratio; +st->disposition = ost->disposition; +avpriv_set_pts_info(st, ost->pts_wrap_bits, ost->time_base.num, +ost->time_base.den); + +av_dict_set_int(&dict, "dash", 1, 0); +av_dict_set_int(&dict, "cluster_time_limit", wc->chunk_duration, 0); +av_dict_set_int(&dict, "live", 1, 0); + +ret = avformat_init_output(oc, &dict); +av_dict_free(&dict); +if (ret < 0) +return ret; + +// Copy the timing info back to the original stream +// so that the timestamps of the packets are directly usable +avpriv_set_pts_info(ost, st->pts_wrap_bits, st->time_base.num, +st->time_base.den); -oc->streams = s->streams; -oc->nb_streams = s->nb_streams; +// This ensures that the timestamps will already be properly shifted +// when the packets arrive here, so we don't need to shift again. +s->avoid_negative_ts = oc->avoid_negative_ts; +s->internal->avoid_negative_ts_use_pts = +oc->internal->avoid_negative_ts_use_pts; +oc->avoid_negative_ts = 0; return 0; } @@ -119,7 +146,6 @@ static int webm_chunk_write_header(AVFormatContext *s) WebMChunkContext *wc = s->priv_data; AVFormatContext *oc = NULL; int ret; -int i; AVDictionary *options = NULL; char oc_filename[MAX_FILENAME_SIZE]; char *oc_url; @@ -152,14 +178,10 @@ static int webm_chunk_write_header(AVFormatContext *s) return ret; oc->pb->seekable = 0; -ret = oc->oformat->write_header(oc); +ret = avformat_write_heade
[FFmpeg-cvslog] avformat/webm_chunk: Avoid unnecessary flushes
ffmpeg | branch: master | Andreas Rheinhardt | Sun Mar 1 04:56:07 2020 +0100| [3d4dd9195f6892b3e9d04dc543d6211095248d22] | committer: Andreas Rheinhardt avformat/webm_chunk: Avoid unnecessary flushes The webm_chunk muxer caches its output to a dynamic buffer and when it outputs anything, it explicitly flushes it. So set the flags indicating that flushing after each packet should not be done automatically (basically avoiding avio_write_marker() to be called by flush_if_needed() in libavformat/mux.c). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3d4dd9195f6892b3e9d04dc543d6211095248d22 --- libavformat/webm_chunk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 9e4c375c3f..d4b2eb6dff 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -72,10 +72,12 @@ static int chunk_mux_init(AVFormatContext *s) oc->interrupt_callback = s->interrupt_callback; oc->max_delay = s->max_delay; -oc->flags = s->flags; +oc->flags = s->flags & ~AVFMT_FLAG_FLUSH_PACKETS; oc->strict_std_compliance = s->strict_std_compliance; oc->avoid_negative_ts = s->avoid_negative_ts; +oc->flush_packets = 0; + av_dict_copy(&oc->metadata, s->metadata, 0); if (!(st = avformat_new_stream(oc, NULL))) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Don't keep pointer to AVOutputFormat
ffmpeg | branch: master | Andreas Rheinhardt | Sat Feb 29 23:49:19 2020 +0100| [f397dc33788547799d88a639bc74b68e832fc9a3] | committer: Andreas Rheinhardt avformat/webm_chunk: Don't keep pointer to AVOutputFormat It is no longer needed given that the function pointers of the child muxer's AVOutputFormat are no longer called directly. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f397dc33788547799d88a639bc74b68e832fc9a3 --- libavformat/webm_chunk.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index d4b2eb6dff..30ba30e929 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -53,19 +53,23 @@ typedef struct WebMChunkContext { char *http_method; uint64_t duration_written; int64_t prev_pts; -ff_const59 AVOutputFormat *oformat; AVFormatContext *avf; } WebMChunkContext; static int chunk_mux_init(AVFormatContext *s) { WebMChunkContext *wc = s->priv_data; +ff_const59 AVOutputFormat *oformat; AVFormatContext *oc; AVStream *st, *ost = s->streams[0]; AVDictionary *dict = NULL; int ret; -ret = avformat_alloc_output_context2(&wc->avf, wc->oformat, NULL, NULL); +oformat = av_guess_format("webm", s->url, "video/webm"); +if (!oformat) +return AVERROR_MUXER_NOT_FOUND; + +ret = avformat_alloc_output_context2(&wc->avf, oformat, NULL, NULL); if (ret < 0) return ret; oc = wc->avf; @@ -156,9 +160,6 @@ static int webm_chunk_write_header(AVFormatContext *s) if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; } wc->chunk_index = wc->chunk_start_index; -wc->oformat = av_guess_format("webm", s->url, "video/webm"); -if (!wc->oformat) -return AVERROR_MUXER_NOT_FOUND; wc->prev_pts = AV_NOPTS_VALUE; ret = chunk_mux_init(s); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Don't copy header filename
ffmpeg | branch: master | Andreas Rheinhardt | Sun Mar 1 00:13:07 2020 +0100| [8a632b3e2e06258e3a9053f82f777dcd3d04ed26] | committer: Andreas Rheinhardt avformat/webm_chunk: Don't copy header filename Instead just reuse the filename string that is given via an option for the child muxer's url field. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a632b3e2e06258e3a9053f82f777dcd3d04ed26 --- libavformat/webm_chunk.c | 34 ++ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 30ba30e929..7b1f1a8b48 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -65,6 +65,11 @@ static int chunk_mux_init(AVFormatContext *s) AVDictionary *dict = NULL; int ret; +if (!wc->header_filename) { +av_log(s, AV_LOG_ERROR, "No header filename provided\n"); +return AVERROR(EINVAL); +} + oformat = av_guess_format("webm", s->url, "video/webm"); if (!oformat) return AVERROR_MUXER_NOT_FOUND; @@ -74,6 +79,9 @@ static int chunk_mux_init(AVFormatContext *s) return ret; oc = wc->avf; +ff_format_set_url(oc, wc->header_filename); +wc->header_filename = NULL; + oc->interrupt_callback = s->interrupt_callback; oc->max_delay = s->max_delay; oc->flags = s->flags & ~AVFMT_FLAG_FLUSH_PACKETS; @@ -120,30 +128,17 @@ static int chunk_mux_init(AVFormatContext *s) return 0; } -static int get_chunk_filename(AVFormatContext *s, int is_header, char filename[MAX_FILENAME_SIZE]) +static int get_chunk_filename(AVFormatContext *s, char filename[MAX_FILENAME_SIZE]) { WebMChunkContext *wc = s->priv_data; if (!filename) { return AVERROR(EINVAL); } -if (is_header) { -int len; -if (!wc->header_filename) { -av_log(s, AV_LOG_ERROR, "No header filename provided\n"); -return AVERROR(EINVAL); -} -len = av_strlcpy(filename, wc->header_filename, MAX_FILENAME_SIZE); -if (len >= MAX_FILENAME_SIZE) { -av_log(s, AV_LOG_ERROR, "Header filename too long\n"); -return AVERROR(EINVAL); -} -} else { if (av_get_frame_filename(filename, MAX_FILENAME_SIZE, s->url, wc->chunk_index - 1) < 0) { av_log(s, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url); return AVERROR(EINVAL); } -} return 0; } @@ -153,8 +148,6 @@ static int webm_chunk_write_header(AVFormatContext *s) AVFormatContext *oc = NULL; int ret; AVDictionary *options = NULL; -char oc_filename[MAX_FILENAME_SIZE]; -char *oc_url; // DASH Streams can only have either one track per file. if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; } @@ -166,13 +159,6 @@ static int webm_chunk_write_header(AVFormatContext *s) if (ret < 0) return ret; oc = wc->avf; -ret = get_chunk_filename(s, 1, oc_filename); -if (ret < 0) -return ret; -oc_url = av_strdup(oc_filename); -if (!oc_url) -return AVERROR(ENOMEM); -ff_format_set_url(oc, oc_url); if (wc->http_method) av_dict_set(&options, "method", wc->http_method, 0); ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &options); @@ -220,7 +206,7 @@ static int chunk_end(AVFormatContext *s, int flush) av_write_frame(oc, NULL); buffer_size = avio_close_dyn_buf(oc->pb, &buffer); oc->pb = NULL; -ret = get_chunk_filename(s, 0, filename); +ret = get_chunk_filename(s, filename); if (ret < 0) goto fail; if (wc->http_method) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Remove unnecessary variable
ffmpeg | branch: master | Andreas Rheinhardt | Sun Mar 1 00:23:38 2020 +0100| [73a595b8e8366e1cc01d318db31d5c800a32bef8] | committer: Andreas Rheinhardt avformat/webm_chunk: Remove unnecessary variable chunk_start_index (which was set via an option) was only used to initialize chunk_index and otherwise unused. So initialize chunk_index directly via the option and remove chunk_start_index. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=73a595b8e8366e1cc01d318db31d5c800a32bef8 --- libavformat/webm_chunk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 7b1f1a8b48..af0d6b9d76 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -46,7 +46,6 @@ typedef struct WebMChunkContext { const AVClass *class; -int chunk_start_index; char *header_filename; int chunk_duration; int chunk_index; @@ -152,7 +151,6 @@ static int webm_chunk_write_header(AVFormatContext *s) // DASH Streams can only have either one track per file. if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; } -wc->chunk_index = wc->chunk_start_index; wc->prev_pts = AV_NOPTS_VALUE; ret = chunk_mux_init(s); @@ -274,7 +272,7 @@ fail: #define OFFSET(x) offsetof(WebMChunkContext, x) static const AVOption options[] = { -{ "chunk_start_index", "start index of the chunk", OFFSET(chunk_start_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, +{ "chunk_start_index", "start index of the chunk", OFFSET(chunk_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "audio_chunk_duration", "duration of each chunk in milliseconds", OFFSET(chunk_duration), AV_OPT_TYPE_INT, {.i64 = 5000}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "method", "set the HTTP method", OFFSET(http_method), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Add init function
ffmpeg | branch: master | Andreas Rheinhardt | Sun Mar 1 00:33:18 2020 +0100| [42b000427dfa8d49807e8a756091d7662ba3bf65] | committer: Andreas Rheinhardt avformat/webm_chunk: Add init function Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42b000427dfa8d49807e8a756091d7662ba3bf65 --- libavformat/webm_chunk.c | 20 +--- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index af0d6b9d76..4188c5c0a5 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -55,7 +55,7 @@ typedef struct WebMChunkContext { AVFormatContext *avf; } WebMChunkContext; -static int chunk_mux_init(AVFormatContext *s) +static int webm_chunk_init(AVFormatContext *s) { WebMChunkContext *wc = s->priv_data; ff_const59 AVOutputFormat *oformat; @@ -64,11 +64,17 @@ static int chunk_mux_init(AVFormatContext *s) AVDictionary *dict = NULL; int ret; +// DASH Streams can only have one track per file. +if (s->nb_streams != 1) +return AVERROR(EINVAL); + if (!wc->header_filename) { av_log(s, AV_LOG_ERROR, "No header filename provided\n"); return AVERROR(EINVAL); } +wc->prev_pts = AV_NOPTS_VALUE; + oformat = av_guess_format("webm", s->url, "video/webm"); if (!oformat) return AVERROR_MUXER_NOT_FOUND; @@ -144,19 +150,10 @@ static int get_chunk_filename(AVFormatContext *s, char filename[MAX_FILENAME_SIZ static int webm_chunk_write_header(AVFormatContext *s) { WebMChunkContext *wc = s->priv_data; -AVFormatContext *oc = NULL; +AVFormatContext *oc = wc->avf; int ret; AVDictionary *options = NULL; -// DASH Streams can only have either one track per file. -if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; } - -wc->prev_pts = AV_NOPTS_VALUE; - -ret = chunk_mux_init(s); -if (ret < 0) -return ret; -oc = wc->avf; if (wc->http_method) av_dict_set(&options, "method", wc->http_method, 0); ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &options); @@ -295,6 +292,7 @@ AVOutputFormat ff_webm_chunk_muxer = { .flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER | AVFMT_NEEDNUMBER | AVFMT_TS_NONSTRICT, .priv_data_size = sizeof(WebMChunkContext), +.init = webm_chunk_init, .write_header = webm_chunk_write_header, .write_packet = webm_chunk_write_packet, .write_trailer = webm_chunk_write_trailer, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Add deinit function
ffmpeg | branch: master | Andreas Rheinhardt | Sun Mar 1 00:50:15 2020 +0100| [d624fb5dada1622f3057b2b35877111a701b3abb] | committer: Andreas Rheinhardt avformat/webm_chunk: Add deinit function This fixes memleaks if an error happens after one of the allocations in init; or if the trailer isn't written (e.g. because there was an error when writing a packet). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d624fb5dada1622f3057b2b35877111a701b3abb --- libavformat/webm_chunk.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 4188c5c0a5..b27e8c4927 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -258,13 +258,22 @@ static int webm_chunk_write_trailer(AVFormatContext *s) if (!oc->pb) { ret = chunk_start(s); if (ret < 0) -goto fail; +return ret; } av_write_trailer(oc); -ret = chunk_end(s, 0); -fail: -avformat_free_context(oc); -return ret; +return chunk_end(s, 0); +} + +static void webm_chunk_deinit(AVFormatContext *s) +{ +WebMChunkContext *wc = s->priv_data; + +if (!wc->avf) +return; + +ffio_free_dyn_buf(&wc->avf->pb); +avformat_free_context(wc->avf); +wc->avf = NULL; } #define OFFSET(x) offsetof(WebMChunkContext, x) @@ -296,6 +305,7 @@ AVOutputFormat ff_webm_chunk_muxer = { .write_header = webm_chunk_write_header, .write_packet = webm_chunk_write_packet, .write_trailer = webm_chunk_write_trailer, +.deinit = webm_chunk_deinit, .priv_class = &webm_chunk_class, }; #endif ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Check unchecked functions for errors
ffmpeg | branch: master | Andreas Rheinhardt | Sun Mar 1 01:29:57 2020 +0100| [f289a6b721a9a1df1ef68d4b78c1307468b9a3e1] | committer: Andreas Rheinhardt avformat/webm_chunk: Check unchecked functions for errors Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f289a6b721a9a1df1ef68d4b78c1307468b9a3e1 --- libavformat/webm_chunk.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index b27e8c4927..85d78a991f 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -95,7 +95,8 @@ static int webm_chunk_init(AVFormatContext *s) oc->flush_packets = 0; -av_dict_copy(&oc->metadata, s->metadata, 0); +if ((ret = av_dict_copy(&oc->metadata, s->metadata, 0)) < 0) +return ret; if (!(st = avformat_new_stream(oc, NULL))) return AVERROR(ENOMEM); @@ -109,11 +110,14 @@ static int webm_chunk_init(AVFormatContext *s) avpriv_set_pts_info(st, ost->pts_wrap_bits, ost->time_base.num, ost->time_base.den); -av_dict_set_int(&dict, "dash", 1, 0); -av_dict_set_int(&dict, "cluster_time_limit", wc->chunk_duration, 0); -av_dict_set_int(&dict, "live", 1, 0); +if ((ret = av_dict_set_int(&dict, "dash", 1, 0)) < 0 || +(ret = av_dict_set_int(&dict, "cluster_time_limit", + wc->chunk_duration, 0)) < 0 || +(ret = av_dict_set_int(&dict, "live", 1, 0)) < 0) +goto fail; ret = avformat_init_output(oc, &dict); +fail: av_dict_free(&dict); if (ret < 0) return ret; @@ -155,7 +159,8 @@ static int webm_chunk_write_header(AVFormatContext *s) AVDictionary *options = NULL; if (wc->http_method) -av_dict_set(&options, "method", wc->http_method, 0); +if ((ret = av_dict_set(&options, "method", wc->http_method, 0)) < 0) +return ret; ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &options); av_dict_free(&options); if (ret < 0) @@ -205,14 +210,15 @@ static int chunk_end(AVFormatContext *s, int flush) if (ret < 0) goto fail; if (wc->http_method) -av_dict_set(&options, "method", wc->http_method, 0); +if ((ret = av_dict_set(&options, "method", wc->http_method, 0)) < 0) +goto fail; ret = s->io_open(s, &pb, filename, AVIO_FLAG_WRITE, &options); +av_dict_free(&options); if (ret < 0) goto fail; avio_write(pb, buffer, buffer_size); ff_format_io_close(s, &pb); fail: -av_dict_free(&options); av_free(buffer); return (ret < 0) ? ret : 0; } @@ -260,7 +266,9 @@ static int webm_chunk_write_trailer(AVFormatContext *s) if (ret < 0) return ret; } -av_write_trailer(oc); +ret = av_write_trailer(oc); +if (ret < 0) +return ret; return chunk_end(s, 0); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webm_chunk: Cosmetics
ffmpeg | branch: master | Andreas Rheinhardt | Sun Mar 1 05:32:42 2020 +0100| [107783006ca84781ac027f7f5c9023fbd6cde422] | committer: Andreas Rheinhardt avformat/webm_chunk: Cosmetics Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=107783006ca84781ac027f7f5c9023fbd6cde422 --- libavformat/webm_chunk.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 85d78a991f..6e48a36b24 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -87,8 +87,8 @@ static int webm_chunk_init(AVFormatContext *s) ff_format_set_url(oc, wc->header_filename); wc->header_filename = NULL; -oc->interrupt_callback = s->interrupt_callback; -oc->max_delay = s->max_delay; +oc->interrupt_callback= s->interrupt_callback; +oc->max_delay = s->max_delay; oc->flags = s->flags & ~AVFMT_FLAG_FLUSH_PACKETS; oc->strict_std_compliance = s->strict_std_compliance; oc->avoid_negative_ts = s->avoid_negative_ts; @@ -143,11 +143,11 @@ static int get_chunk_filename(AVFormatContext *s, char filename[MAX_FILENAME_SIZ if (!filename) { return AVERROR(EINVAL); } -if (av_get_frame_filename(filename, MAX_FILENAME_SIZE, - s->url, wc->chunk_index - 1) < 0) { -av_log(s, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url); -return AVERROR(EINVAL); -} +if (av_get_frame_filename(filename, MAX_FILENAME_SIZE, + s->url, wc->chunk_index - 1) < 0) { +av_log(s, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url); +return AVERROR(EINVAL); +} return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskaenc: Avoid allocations for SeekHead
ffmpeg | branch: master | Andreas Rheinhardt | Sun Dec 29 09:38:44 2019 +0100| [dc2f6b54ac85189185938c10a168a647f1da1f62] | committer: Andreas Rheinhardt avformat/matroskaenc: Avoid allocations for SeekHead Up until e7ddafd5, the Matroska muxer wrote two SeekHeads: One at the beginning referencing the main level 1 elements (i.e. not the Clusters) and one at the end, referencing the Clusters. This second SeekHead was useless and has therefore been removed. Yet the SeekHead-related functions and structures are still geared towards this usecase: They are built around an allocated array of variable size that gets reallocated every time an element is added to it although the maximum number of Seek entries is a small compile-time constant, so that one should rather include the array in the SeekHead structure itself; and said structure should be contained in the MatroskaMuxContext instead of being allocated separately. The earlier code reserved space for a SeekHead with 10 entries, although we currently write at most 6. Reducing said number implied that every Matroska/Webm file will be 84 bytes smaller and required to adapt several FATE tests; furthermore, the reserved amount overestimated the amount needed for for the SeekHead's length field and how many bytes need to be reserved to write a EBML Void element, bringing the total reduction to 89 bytes. This also fixes a potential segfault: If !mkv->is_live and if the AVIOContext is initially unseekable when writing the header, the SeekHead is already written when writing the header and this used to free the SeekHead-related structures that have been allocated. But if the AVIOContext happens to be seekable when writing the trailer, it will be attempted to write the SeekHead again which will lead to segfaults because the corresponding structures have already been freed. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc2f6b54ac85189185938c10a168a647f1da1f62 --- libavformat/matroskaenc.c| 119 +++ tests/fate/matroska.mak | 2 +- tests/fate/wavpack.mak | 4 +- tests/ref/fate/aac-autobsf-adtstoasc | 4 +- tests/ref/fate/binsub-mksenc | 2 +- tests/ref/fate/rgb24-mkv | 4 +- tests/ref/lavf-fate/av1.mkv | 4 +- tests/ref/lavf/mka | 4 +- tests/ref/lavf/mkv | 4 +- tests/ref/lavf/mkv_attachment| 4 +- tests/ref/seek/lavf-mkv | 44 ++--- 11 files changed, 73 insertions(+), 122 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 9be086237a..f9e69c6c89 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -57,6 +57,10 @@ #include "libavcodec/mpeg4audio.h" #include "libavcodec/internal.h" +/* Level 1 elements we create a SeekHead entry for: + * Info, Tracks, Chapters, Attachments, Tags and Cues */ +#define MAX_SEEKHEAD_ENTRIES 6 + typedef struct ebml_master { int64_t pos;///< absolute offset in the containing AVIOContext where the master's elements start int sizebytes; ///< how many bytes were reserved for the size @@ -69,11 +73,9 @@ typedef struct mkv_seekhead_entry { typedef struct mkv_seekhead { int64_t filepos; -int64_t segment_offset; ///< the file offset to the beginning of the segment -int reserved_size; ///< -1 if appending to file -int max_entries; -mkv_seekhead_entry *entries; +mkv_seekhead_entry entries[MAX_SEEKHEAD_ENTRIES]; int num_entries; +int reserved_size; } mkv_seekhead; typedef struct mkv_cuepoint { @@ -136,7 +138,7 @@ typedef struct MatroskaMuxContext { int64_t cluster_pts; int64_t duration_offset; int64_t duration; -mkv_seekhead*seekhead; +mkv_seekheadseekhead; mkv_cues*cues; mkv_track *tracks; mkv_attachments *attachments; @@ -396,10 +398,6 @@ static void mkv_deinit(AVFormatContext *s) ffio_free_dyn_buf(&mkv->tracks_bc); ffio_free_dyn_buf(&mkv->tags_bc); -if (mkv->seekhead) { -av_freep(&mkv->seekhead->entries); -av_freep(&mkv->seekhead); -} if (mkv->cues) { av_freep(&mkv->cues->entries); av_freep(&mkv->cues); @@ -412,61 +410,33 @@ static void mkv_deinit(AVFormatContext *s) } /** - * Initialize a mkv_seekhead element to be ready to index level 1 Matroska - * elements. If a maximum number of elements is specified, enough space - * will be reserved at the current file location to write a seek head of - * that size. - * - * @param segment_offset The absolute offset to the position in the file - * where the segment begins. - * @param numelements The maximum number of elem
[FFmpeg-cvslog] avformat/matroskadec: fix the type of the TrackLanguage
ffmpeg | branch: master | Steve Lhomme | Sun Mar 22 09:59:26 2020 +0100| [b5dd964cdca090aed0fc6068c8967c92c594d9aa] | committer: Andreas Rheinhardt avformat/matroskadec: fix the type of the TrackLanguage It's an ASCII string, not a UTF-8 string. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b5dd964cdca090aed0fc6068c8967c92c594d9aa --- libavformat/matroskadec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 4d7fdab99f..383869bced 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -554,7 +554,7 @@ static EbmlSyntax matroska_track[] = { { MATROSKA_ID_CODECID, EBML_STR, 0, offsetof(MatroskaTrack, codec_id) }, { MATROSKA_ID_CODECPRIVATE, EBML_BIN, 0, offsetof(MatroskaTrack, codec_priv) }, { MATROSKA_ID_CODECDELAY,EBML_UINT, 0, offsetof(MatroskaTrack, codec_delay) }, -{ MATROSKA_ID_TRACKLANGUAGE, EBML_UTF8, 0, offsetof(MatroskaTrack, language), { .s = "eng" } }, +{ MATROSKA_ID_TRACKLANGUAGE, EBML_STR, 0, offsetof(MatroskaTrack, language), { .s = "eng" } }, { MATROSKA_ID_TRACKDEFAULTDURATION, EBML_UINT, 0, offsetof(MatroskaTrack, default_duration) }, { MATROSKA_ID_TRACKTIMECODESCALE,EBML_FLOAT, 0, offsetof(MatroskaTrack, time_scale), { .f = 1.0 } }, { MATROSKA_ID_TRACKFLAGDEFAULT, EBML_UINT, 0, offsetof(MatroskaTrack, flag_default), { .u = 1 } }, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".