[PATCH 1/2] opus/matroska: Adding support for DiscardPadding in muxer
Support for end trimming Opus in Matroska is implemented by using the DiscardPadding container element in the Block data. The last chunk is stored as a Block instead of SimpleBlock and the trimming information is stored and used to discard samples that were padded by the Opus codec. This patch adds support for muxing DiscardPadding element into the container with appropriate value. Matroska spec for the DiscardPadding element can be found here: http://matroska.org/technical/specs/index.html#DiscardPadding Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/avpacket.c | 2 -- libavcodec/libopusenc.c | 12 ++++++++++++ libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 24 ++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 7196c31..ac761f1 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -225,8 +225,6 @@ int av_copy_packet_side_data(AVPacket *pkt, AVPacket *src) int i; DUP_DATA(pkt->side_data, src->side_data, src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC); - memset(pkt->side_data, 0, - src->side_data_elems * sizeof(*src->side_data)); for (i = 0; i < src->side_data_elems; i++) { DUP_DATA(pkt->side_data[i].data, src->side_data[i].data, src->side_data[i].size, 1, ALLOC_MALLOC); diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index 59caac7..775b2ef 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -354,6 +354,18 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, ff_af_queue_remove(&opus->afq, opus->opts.packet_size, &avpkt->pts, &avpkt->duration); + if (opus->opts.packet_size - avpkt->duration > 0) { + uint8_t* side_data = av_packet_new_side_data(avpkt, + AV_PKT_DATA_SKIP_SAMPLES, + 10); + if(side_data == NULL) { + av_free_packet(avpkt); + av_free(avpkt); + return AVERROR(ENOMEM); + } + AV_WL32(side_data + 4, opus->opts.packet_size - avpkt->duration); + } + *got_packet_ptr = 1; return 0; diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 7cf423c..002fc4c 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -198,6 +198,7 @@ #define MATROSKA_ID_BLOCKDURATION 0x9B #define MATROSKA_ID_BLOCKREFERENCE 0xFB #define MATROSKA_ID_CODECSTATE 0xA4 +#define MATROSKA_ID_DISCARDPADDING 0x75A2 /* IDs in the attachments master */ #define MATROSKA_ID_ATTACHEDFILE 0x61A7 diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 92df6cb..7ad35b5 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -43,6 +43,7 @@ #include "libavcodec/xiph.h" #include "libavcodec/mpeg4audio.h" +#include "libavcodec/internal.h" typedef struct ebml_master { int64_t pos; ///< absolute offset in the file where the master's elements start @@ -1283,7 +1284,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, uint8_t *data = NULL, *side_data = NULL; int offset = 0, size = pkt->size, side_data_size = 0; int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts; - uint64_t additional_id = 0; + uint64_t additional_id = 0, discard_padding = 0; ebml_master block_group, block_additions, block_more; av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, " @@ -1309,6 +1310,16 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, } side_data = av_packet_get_side_data(pkt, + AV_PKT_DATA_SKIP_SAMPLES, + &side_data_size); + + if (side_data && side_data_size >= 10) { + discard_padding = av_rescale_q(AV_RL32(side_data + 4), + (AVRational){1, codec->sample_rate}, + (AVRational){1, 1000000000}); + } + + side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size); if (side_data) { @@ -1317,7 +1328,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, side_data_size -= 8; } - if (side_data_size && additional_id == 1) { + if ((side_data_size && additional_id == 1) || discard_padding) { block_group = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, 0); blockid = MATROSKA_ID_BLOCK; } @@ -1331,6 +1342,10 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, if (data != pkt->data) av_free(data); + if (discard_padding) { + put_ebml_uint(pb, MATROSKA_ID_DISCARDPADDING, discard_padding); + } + if (side_data_size && additional_id == 1) { block_additions = start_ebml_master(pb, MATROSKA_ID_BLOCKADDITIONS, 0); block_more = start_ebml_master(pb, MATROSKA_ID_BLOCKMORE, 0); @@ -1340,6 +1355,8 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, avio_write(pb, side_data, side_data_size); end_ebml_master(pb, block_more); end_ebml_master(pb, block_additions); + } + if ((side_data_size && additional_id == 1) || discard_padding) { end_ebml_master(pb, block_group); } } @@ -1556,6 +1573,9 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) ret = mkv->cur_audio_pkt.buf ? 0 : AVERROR(ENOMEM); } else ret = av_dup_packet(&mkv->cur_audio_pkt); + if (mkv->cur_audio_pkt.side_data_elems > 0) { + ret = av_copy_packet_side_data(&mkv->cur_audio_pkt, &mkv->cur_audio_pkt); + } } else ret = mkv_write_packet_internal(s, pkt); return ret; -- 1.8.3
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska. Note, this patch depends on the muxer patch being applied first. Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/utils.c | 21 +++++++++++++++++++++ libavformat/matroskadec.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 3ae4af6..b99aa8c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2111,6 +2111,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { uint8_t *side; int side_size; + uint32_t discard_padding = 0; // copy to ensure we do not change avpkt AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp); @@ -2145,6 +2146,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, avctx->internal->skip_samples = AV_RL32(side); av_log(avctx, AV_LOG_DEBUG, "skip %d samples due to side data\n", avctx->internal->skip_samples); + discard_padding = AV_RL32(side + 4); } if (avctx->internal->skip_samples && *got_frame_ptr) { if(frame->nb_samples <= avctx->internal->skip_samples){ @@ -2175,6 +2177,25 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, } } + if (discard_padding && *got_frame_ptr) { + if (discard_padding == frame->nb_samples) { + *got_frame_ptr = 0; + } else { + if(avctx->pkt_timebase.num && avctx->sample_rate) { + int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding, + (AVRational){1, avctx->sample_rate}, + avctx->pkt_timebase); + if (av_frame_get_pkt_duration(frame) >= diff_ts) + av_frame_set_pkt_duration(frame, av_frame_get_pkt_duration(frame) - diff_ts); + } else { + av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n"); + } + av_log(avctx, AV_LOG_DEBUG, "discard %d/%d samples\n", + discard_padding, frame->nb_samples); + frame->nb_samples -= discard_padding; + } + } + avctx->pkt = NULL; if (did_split) { av_packet_free_side_data(&tmp); diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 60f7a5a..7f32eef 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -290,6 +290,7 @@ typedef struct { EbmlBin bin; uint64_t additional_id; EbmlBin additional; + uint64_t discard_padding; } MatroskaBlock; static EbmlSyntax ebml_header[] = { @@ -563,6 +564,7 @@ static EbmlSyntax matroska_blockgroup[] = { { MATROSKA_ID_BLOCKADDITIONS, EBML_NEST, 0, 0, {.n=matroska_blockadditions} }, { MATROSKA_ID_SIMPLEBLOCK, EBML_BIN, 0, offsetof(MatroskaBlock,bin) }, { MATROSKA_ID_BLOCKDURATION, EBML_UINT, 0, offsetof(MatroskaBlock,duration) }, + { MATROSKA_ID_DISCARDPADDING, EBML_UINT, 0, offsetof(MatroskaBlock,discard_padding) }, { MATROSKA_ID_BLOCKREFERENCE, EBML_UINT, 0, offsetof(MatroskaBlock,reference) }, { MATROSKA_ID_CODECSTATE, EBML_NONE }, { 1, EBML_UINT, 0, offsetof(MatroskaBlock,non_simple), {.u=1} }, @@ -2359,7 +2361,8 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, uint8_t *data, int pkt_size, uint64_t timecode, uint64_t lace_duration, int64_t pos, int is_keyframe, - uint8_t *additional, uint64_t additional_id, int additional_size) + uint8_t *additional, uint64_t additional_id, int additional_size, + uint64_t discard_padding) { MatroskaTrackEncoding *encodings = track->encodings.elem; uint8_t *pkt_data = data; @@ -2422,6 +2425,21 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, memcpy(side_data + 8, additional, additional_size); } + if (discard_padding) { + uint8_t *side_data = av_packet_new_side_data(pkt, + AV_PKT_DATA_SKIP_SAMPLES, + 10); + if(side_data == NULL) { + av_free_packet(pkt); + av_free(pkt); + return AVERROR(ENOMEM); + } + AV_WL32(side_data, 0); + AV_WL32(side_data + 4, av_rescale_q(discard_padding, + (AVRational){1, 1000000000}, + (AVRational){1, st->codec->sample_rate})); + } + if (track->ms_compat) pkt->dts = timecode; else @@ -2481,7 +2499,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t block_duration, int is_keyframe, uint8_t *additional, uint64_t additional_id, int additional_size, - int64_t cluster_pos) + int64_t cluster_pos, uint64_t discard_padding) { uint64_t timecode = AV_NOPTS_VALUE; MatroskaTrack *track; @@ -2593,7 +2611,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, res = matroska_parse_frame(matroska, track, st, data, lace_size[n], timecode, lace_duration, pos, !n? is_keyframe : 0, - additional, additional_id, additional_size); + additional, additional_id, additional_size, + discard_padding); if (res) goto end; } @@ -2660,7 +2679,8 @@ static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska) blocks[i].duration, is_keyframe, additional, blocks[i].additional_id, blocks[i].additional.size, - matroska->current_cluster_pos); + matroska->current_cluster_pos, + blocks[i].discard_padding); } } @@ -2690,7 +2710,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) blocks[i].bin.data, blocks[i].bin.size, blocks[i].bin.pos, cluster.timecode, blocks[i].duration, is_keyframe, NULL, 0, 0, - pos); + pos, blocks[i].discard_padding); } ebml_free(matroska_cluster, &cluster); return res; @@ -2813,3 +2833,4 @@ AVInputFormat ff_matroska_demuxer = { .read_close = matroska_read_close, .read_seek = matroska_read_seek, }; + -- 1.8.3
On Tue, Aug 20, 2013 at 03:13:37PM -0700, Vignesh Venkatasubramanian wrote:
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Note, this patch depends on the muxer patch being applied first.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/utils.c | 21 +++++++++++++++++++++ libavformat/matroskadec.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 3ae4af6..b99aa8c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2111,6 +2111,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { uint8_t *side; int side_size; + uint32_t discard_padding = 0; // copy to ensure we do not change avpkt AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp); @@ -2145,6 +2146,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, avctx->internal->skip_samples = AV_RL32(side); av_log(avctx, AV_LOG_DEBUG, "skip %d samples due to side data\n", avctx->internal->skip_samples); + discard_padding = AV_RL32(side + 4); } if (avctx->internal->skip_samples && *got_frame_ptr) { if(frame->nb_samples <= avctx->internal->skip_samples){ @@ -2175,6 +2177,25 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, } }
+ if (discard_padding && *got_frame_ptr) { + if (discard_padding == frame->nb_samples) { + *got_frame_ptr = 0; + } else { + if(avctx->pkt_timebase.num && avctx->sample_rate) { + int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding, + (AVRational){1, avctx->sample_rate}, + avctx->pkt_timebase); + if (av_frame_get_pkt_duration(frame) >= diff_ts) + av_frame_set_pkt_duration(frame, av_frame_get_pkt_duration(frame) - diff_ts); + } else { + av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n"); + } + av_log(avctx, AV_LOG_DEBUG, "discard %d/%d samples\n", + discard_padding, frame->nb_samples); + frame->nb_samples -= discard_padding;
discard_padding is a untrusted value read from the bitstream It should be checked before use [...]
@@ -2813,3 +2833,4 @@ AVInputFormat ff_matroska_demuxer = { .read_close = matroska_read_close, .read_seek = matroska_read_seek, }; + --
unintended change i assume [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska. Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/utils.c | 21 +++++++++++++++++++++ libavformat/matroskadec.c | 30 +++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 0be9340..477a1a1 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2111,6 +2111,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { uint8_t *side; int side_size; + uint32_t discard_padding = 0; // copy to ensure we do not change avpkt AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp); @@ -2145,6 +2146,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, avctx->internal->skip_samples = AV_RL32(side); av_log(avctx, AV_LOG_DEBUG, "skip %d samples due to side data\n", avctx->internal->skip_samples); + discard_padding = AV_RL32(side + 4); } if (avctx->internal->skip_samples && *got_frame_ptr) { if(frame->nb_samples <= avctx->internal->skip_samples){ @@ -2175,6 +2177,25 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, } } + if (discard_padding > 0 && *got_frame_ptr) { + if (discard_padding == frame->nb_samples) { + *got_frame_ptr = 0; + } else { + if(avctx->pkt_timebase.num && avctx->sample_rate) { + int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding, + (AVRational){1, avctx->sample_rate}, + avctx->pkt_timebase); + if (av_frame_get_pkt_duration(frame) >= diff_ts) + av_frame_set_pkt_duration(frame, av_frame_get_pkt_duration(frame) - diff_ts); + } else { + av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n"); + } + av_log(avctx, AV_LOG_DEBUG, "discard %d/%d samples\n", + discard_padding, frame->nb_samples); + frame->nb_samples -= discard_padding; + } + } + avctx->pkt = NULL; if (did_split) { av_packet_free_side_data(&tmp); diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 60f7a5a..e504871 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -290,6 +290,7 @@ typedef struct { EbmlBin bin; uint64_t additional_id; EbmlBin additional; + uint64_t discard_padding; } MatroskaBlock; static EbmlSyntax ebml_header[] = { @@ -563,6 +564,7 @@ static EbmlSyntax matroska_blockgroup[] = { { MATROSKA_ID_BLOCKADDITIONS, EBML_NEST, 0, 0, {.n=matroska_blockadditions} }, { MATROSKA_ID_SIMPLEBLOCK, EBML_BIN, 0, offsetof(MatroskaBlock,bin) }, { MATROSKA_ID_BLOCKDURATION, EBML_UINT, 0, offsetof(MatroskaBlock,duration) }, + { MATROSKA_ID_DISCARDPADDING, EBML_UINT, 0, offsetof(MatroskaBlock,discard_padding) }, { MATROSKA_ID_BLOCKREFERENCE, EBML_UINT, 0, offsetof(MatroskaBlock,reference) }, { MATROSKA_ID_CODECSTATE, EBML_NONE }, { 1, EBML_UINT, 0, offsetof(MatroskaBlock,non_simple), {.u=1} }, @@ -2359,7 +2361,8 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, uint8_t *data, int pkt_size, uint64_t timecode, uint64_t lace_duration, int64_t pos, int is_keyframe, - uint8_t *additional, uint64_t additional_id, int additional_size) + uint8_t *additional, uint64_t additional_id, int additional_size, + uint64_t discard_padding) { MatroskaTrackEncoding *encodings = track->encodings.elem; uint8_t *pkt_data = data; @@ -2422,6 +2425,21 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, memcpy(side_data + 8, additional, additional_size); } + if (discard_padding) { + uint8_t *side_data = av_packet_new_side_data(pkt, + AV_PKT_DATA_SKIP_SAMPLES, + 10); + if(side_data == NULL) { + av_free_packet(pkt); + av_free(pkt); + return AVERROR(ENOMEM); + } + AV_WL32(side_data, 0); + AV_WL32(side_data + 4, av_rescale_q(discard_padding, + (AVRational){1, 1000000000}, + (AVRational){1, st->codec->sample_rate})); + } + if (track->ms_compat) pkt->dts = timecode; else @@ -2481,7 +2499,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t block_duration, int is_keyframe, uint8_t *additional, uint64_t additional_id, int additional_size, - int64_t cluster_pos) + int64_t cluster_pos, uint64_t discard_padding) { uint64_t timecode = AV_NOPTS_VALUE; MatroskaTrack *track; @@ -2593,7 +2611,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, res = matroska_parse_frame(matroska, track, st, data, lace_size[n], timecode, lace_duration, pos, !n? is_keyframe : 0, - additional, additional_id, additional_size); + additional, additional_id, additional_size, + discard_padding); if (res) goto end; } @@ -2660,7 +2679,8 @@ static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska) blocks[i].duration, is_keyframe, additional, blocks[i].additional_id, blocks[i].additional.size, - matroska->current_cluster_pos); + matroska->current_cluster_pos, + blocks[i].discard_padding); } } @@ -2690,7 +2710,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) blocks[i].bin.data, blocks[i].bin.size, blocks[i].bin.pos, cluster.timecode, blocks[i].duration, is_keyframe, NULL, 0, 0, - pos); + pos, blocks[i].discard_padding); } ebml_free(matroska_cluster, &cluster); return res; -- 1.8.4
On Fri, Aug 30, 2013 at 11:25:12AM -0700, Vignesh Venkatasubramanian wrote:
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/utils.c | 21 +++++++++++++++++++++ libavformat/matroskadec.c | 30 +++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 5 deletions(-)
this (with the other patched) causes fate to fail --- ./tests/ref/fate/exif-image-embedded 2013-09-02 12:10:30.045471774 +0200 +++ tests/data/fate/exif-image-embedded 2013-09-03 01:29:07.774481269 +0200 @@ -34,7 +34,7 @@ pkt_pos=16292 pkt_size=417 sample_fmt=s16p -nb_samples=47 +nb_samples=-11006 channels=2 channel_layout=stereo [/FRAME] [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam"
On Mon, Sep 2, 2013 at 4:30 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
On Fri, Aug 30, 2013 at 11:25:12AM -0700, Vignesh Venkatasubramanian wrote:
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/utils.c | 21 +++++++++++++++++++++ libavformat/matroskadec.c | 30 +++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 5 deletions(-)
this (with the other patched) causes fate to fail
when you say other patched, do you mean the muxer and encoder patches? or the memset patch? because i applied all the 4 patches and fate passes for me. just to be clear, by 4 patches i mean the patches with following titles: * avpacket: Fixing side data copy when src == dst * opus/matroska: Adding support for DiscardPadding in muxer * lavcodec: Adding support for End Trimming in Opus encoder * opus/matroska: Adding support for End Trimming in demuxer/decoder could you please check once again? thanks.
--- ./tests/ref/fate/exif-image-embedded 2013-09-02 12:10:30.045471774 +0200 +++ tests/data/fate/exif-image-embedded 2013-09-03 01:29:07.774481269 +0200 @@ -34,7 +34,7 @@ pkt_pos=16292 pkt_size=417 sample_fmt=s16p -nb_samples=47 +nb_samples=-11006 channels=2 channel_layout=stereo [/FRAME]
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam"
-- Vignesh Venkat | Software Engineer | vigneshv@google.com | 650-861-1330
On Tue, Sep 03, 2013 at 10:46:34AM -0700, Vignesh Venkatasubramanian wrote:
On Mon, Sep 2, 2013 at 4:30 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
On Fri, Aug 30, 2013 at 11:25:12AM -0700, Vignesh Venkatasubramanian wrote:
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/utils.c | 21 +++++++++++++++++++++ libavformat/matroskadec.c | 30 +++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 5 deletions(-)
this (with the other patched) causes fate to fail
when you say other patched, do you mean the muxer and encoder patches? or the memset patch? because i applied all the 4 patches and fate passes for me.
just to be clear, by 4 patches i mean the patches with following titles: * avpacket: Fixing side data copy when src == dst * opus/matroska: Adding support for DiscardPadding in muxer * lavcodec: Adding support for End Trimming in Opus encoder * opus/matroska: Adding support for End Trimming in demuxer/decoder
could you please check once again? thanks.
the following 2 patches are sufficient to make it break fate: btw, it would be easier if you had a git repo with the patches so i could test exactly the code you test the avpacket patch also has been applied already commit d2ccbc879b69be7ead2061863e0ae84d9da07b32 Author: Vignesh Venkatasubramanian <vigneshv@google.com> Date: Fri Aug 30 11:26:37 2013 -0700 opus/matroska: Adding support for DiscardPadding in muxer Support for end trimming Opus in Matroska is implemented by using the DiscardPadding container element in the Block data. The last chunk is stored as a Block instead of SimpleBlock and the trimming information is stored and used to discard samples that were padded by the Opus codec. This patch adds support for muxing DiscardPadding element into the container with appropriate value. Matroska spec for the DiscardPadding element can be found here: http://matroska.org/technical/specs/index.html#DiscardPadding Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at> commit 75c84127c36972b1d0d65188ff90e07a51a8a11d Author: Vignesh Venkatasubramanian <vigneshv@google.com> Date: Fri Aug 30 11:25:12 2013 -0700 opus/matroska: Adding support for End Trimming in demuxer/decoder Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska. Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
--- ./tests/ref/fate/exif-image-embedded 2013-09-02 12:10:30.045471774 +0200 +++ tests/data/fate/exif-image-embedded 2013-09-03 01:29:07.774481269 +0200 @@ -34,7 +34,7 @@ pkt_pos=16292 pkt_size=417 sample_fmt=s16p -nb_samples=47 +nb_samples=-11006 channels=2 channel_layout=stereo [/FRAME]
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam"
-- Vignesh Venkat | Software Engineer | vigneshv@google.com | 650-861-1330
-- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle
On Tue, Sep 3, 2013 at 12:12 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
On Tue, Sep 03, 2013 at 10:46:34AM -0700, Vignesh Venkatasubramanian wrote:
On Mon, Sep 2, 2013 at 4:30 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
On Fri, Aug 30, 2013 at 11:25:12AM -0700, Vignesh Venkatasubramanian wrote:
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/utils.c | 21 +++++++++++++++++++++ libavformat/matroskadec.c | 30 +++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 5 deletions(-)
this (with the other patched) causes fate to fail
when you say other patched, do you mean the muxer and encoder patches? or the memset patch? because i applied all the 4 patches and fate passes for me.
just to be clear, by 4 patches i mean the patches with following titles: * avpacket: Fixing side data copy when src == dst * opus/matroska: Adding support for DiscardPadding in muxer * lavcodec: Adding support for End Trimming in Opus encoder * opus/matroska: Adding support for End Trimming in demuxer/decoder
could you please check once again? thanks.
the following 2 patches are sufficient to make it break fate:
btw, it would be easier if you had a git repo with the patches so i could test exactly the code you test the avpacket patch also has been applied already
commit d2ccbc879b69be7ead2061863e0ae84d9da07b32 Author: Vignesh Venkatasubramanian <vigneshv@google.com> Date: Fri Aug 30 11:26:37 2013 -0700
opus/matroska: Adding support for DiscardPadding in muxer
Support for end trimming Opus in Matroska is implemented by using the DiscardPadding container element in the Block data. The last chunk is stored as a Block instead of SimpleBlock and the trimming information is stored and used to discard samples that were padded by the Opus codec. This patch adds support for muxing DiscardPadding element into the container with appropriate value. Matroska spec for the DiscardPadding element can be found here: http://matroska.org/technical/specs/index.html#DiscardPadding
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
commit 75c84127c36972b1d0d65188ff90e07a51a8a11d Author: Vignesh Venkatasubramanian <vigneshv@google.com> Date: Fri Aug 30 11:25:12 2013 -0700
opus/matroska: Adding support for End Trimming in demuxer/decoder
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
i am able to reproduce the fate failure now. the fate passes if i do configure in a non trivial way (including a bunch of libraries, etc). but it fails if i merely run configure without any option. i will look into it.
--- ./tests/ref/fate/exif-image-embedded 2013-09-02 12:10:30.045471774 +0200 +++ tests/data/fate/exif-image-embedded 2013-09-03 01:29:07.774481269 +0200 @@ -34,7 +34,7 @@ pkt_pos=16292 pkt_size=417 sample_fmt=s16p -nb_samples=47 +nb_samples=-11006 channels=2 channel_layout=stereo [/FRAME]
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam"
-- Vignesh Venkat | Software Engineer | vigneshv@google.com | 650-861-1330
-- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle
On Tue, Sep 3, 2013 at 2:03 PM, Vignesh Venkatasubramanian <vigneshv@google.com> wrote:
On Tue, Sep 3, 2013 at 12:12 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
On Tue, Sep 03, 2013 at 10:46:34AM -0700, Vignesh Venkatasubramanian wrote:
On Mon, Sep 2, 2013 at 4:30 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
On Fri, Aug 30, 2013 at 11:25:12AM -0700, Vignesh Venkatasubramanian wrote:
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/utils.c | 21 +++++++++++++++++++++ libavformat/matroskadec.c | 30 +++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 5 deletions(-)
this (with the other patched) causes fate to fail
when you say other patched, do you mean the muxer and encoder patches? or the memset patch? because i applied all the 4 patches and fate passes for me.
just to be clear, by 4 patches i mean the patches with following titles: * avpacket: Fixing side data copy when src == dst * opus/matroska: Adding support for DiscardPadding in muxer * lavcodec: Adding support for End Trimming in Opus encoder * opus/matroska: Adding support for End Trimming in demuxer/decoder
could you please check once again? thanks.
the following 2 patches are sufficient to make it break fate:
btw, it would be easier if you had a git repo with the patches so i could test exactly the code you test the avpacket patch also has been applied already
commit d2ccbc879b69be7ead2061863e0ae84d9da07b32 Author: Vignesh Venkatasubramanian <vigneshv@google.com> Date: Fri Aug 30 11:26:37 2013 -0700
opus/matroska: Adding support for DiscardPadding in muxer
Support for end trimming Opus in Matroska is implemented by using the DiscardPadding container element in the Block data. The last chunk is stored as a Block instead of SimpleBlock and the trimming information is stored and used to discard samples that were padded by the Opus codec. This patch adds support for muxing DiscardPadding element into the container with appropriate value. Matroska spec for the DiscardPadding element can be found here: http://matroska.org/technical/specs/index.html#DiscardPadding
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
commit 75c84127c36972b1d0d65188ff90e07a51a8a11d Author: Vignesh Venkatasubramanian <vigneshv@google.com> Date: Fri Aug 30 11:25:12 2013 -0700
opus/matroska: Adding support for End Trimming in demuxer/decoder
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
i am able to reproduce the fate failure now. the fate passes if i do configure in a non trivial way (including a bunch of libraries, etc). but it fails if i merely run configure without any option. i will look into it.
I sent a patch just now which fixes the fate failure on this (and related) patches. Can you please check now ? thanks! FYI the new patch i am talking about is titled: lavf/utils: Fixing skip samples to adhere to side data format
--- ./tests/ref/fate/exif-image-embedded 2013-09-02 12:10:30.045471774 +0200 +++ tests/data/fate/exif-image-embedded 2013-09-03 01:29:07.774481269 +0200 @@ -34,7 +34,7 @@ pkt_pos=16292 pkt_size=417 sample_fmt=s16p -nb_samples=47 +nb_samples=-11006 channels=2 channel_layout=stereo [/FRAME]
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam"
-- Vignesh Venkat | Software Engineer | vigneshv@google.com | 650-861-1330
-- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle
On Wed, Sep 04, 2013 at 10:48:29AM -0700, Vignesh Venkatasubramanian wrote:
On Tue, Sep 3, 2013 at 2:03 PM, Vignesh Venkatasubramanian <vigneshv@google.com> wrote:
On Tue, Sep 3, 2013 at 12:12 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
On Tue, Sep 03, 2013 at 10:46:34AM -0700, Vignesh Venkatasubramanian wrote:
On Mon, Sep 2, 2013 at 4:30 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
On Fri, Aug 30, 2013 at 11:25:12AM -0700, Vignesh Venkatasubramanian wrote:
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/utils.c | 21 +++++++++++++++++++++ libavformat/matroskadec.c | 30 +++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 5 deletions(-)
this (with the other patched) causes fate to fail
when you say other patched, do you mean the muxer and encoder patches? or the memset patch? because i applied all the 4 patches and fate passes for me.
just to be clear, by 4 patches i mean the patches with following titles: * avpacket: Fixing side data copy when src == dst * opus/matroska: Adding support for DiscardPadding in muxer * lavcodec: Adding support for End Trimming in Opus encoder * opus/matroska: Adding support for End Trimming in demuxer/decoder
could you please check once again? thanks.
the following 2 patches are sufficient to make it break fate:
btw, it would be easier if you had a git repo with the patches so i could test exactly the code you test the avpacket patch also has been applied already
commit d2ccbc879b69be7ead2061863e0ae84d9da07b32 Author: Vignesh Venkatasubramanian <vigneshv@google.com> Date: Fri Aug 30 11:26:37 2013 -0700
opus/matroska: Adding support for DiscardPadding in muxer
Support for end trimming Opus in Matroska is implemented by using the DiscardPadding container element in the Block data. The last chunk is stored as a Block instead of SimpleBlock and the trimming information is stored and used to discard samples that were padded by the Opus codec. This patch adds support for muxing DiscardPadding element into the container with appropriate value. Matroska spec for the DiscardPadding element can be found here: http://matroska.org/technical/specs/index.html#DiscardPadding
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
commit 75c84127c36972b1d0d65188ff90e07a51a8a11d Author: Vignesh Venkatasubramanian <vigneshv@google.com> Date: Fri Aug 30 11:25:12 2013 -0700
opus/matroska: Adding support for End Trimming in demuxer/decoder
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
i am able to reproduce the fate failure now. the fate passes if i do configure in a non trivial way (including a bunch of libraries, etc). but it fails if i merely run configure without any option. i will look into it.
I sent a patch just now which fixes the fate failure on this (and related) patches. Can you please check now ? thanks!
FYI the new patch i am talking about is titled: lavf/utils: Fixing skip samples to adhere to side data format
i confirm this fixes the issues anyone else has any comments about the patchset ? nicolas ? you worked with (lib)opus IIRC [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf
L'octidi 18 fructidor, an CCXXI, Michael Niedermayer a écrit :
i confirm this fixes the issues
anyone else has any comments about the patchset ? nicolas ? you worked with (lib)opus IIRC
I worked on the decoder, not the encoder. Assuming I understand correctly what ff_af_queue does, the libopusenc part looks fine (except style: "uint8_t* side_data" -> "uint8_t *side_data" and "side_data == NULL" -> "!side_data"). I can not comment usefully on the Matroska part, though. It looks fine at first glance, but I would not spot a subtle mistake. The "(side_data_size && additional_id == 1)" and "(side_data_size && additional_id == 1) || discard_padding" tests look a bit fragile, and may become a maintenance burden. Maybe checking block_group to see if it was opened or setting a flag at the same time would be cleaner. But that does not change the logic of the code. Regards, -- Nicolas George
On Thu, Sep 5, 2013 at 12:33 PM, Nicolas George <nicolas.george@normalesup.org> wrote:
L'octidi 18 fructidor, an CCXXI, Michael Niedermayer a écrit :
i confirm this fixes the issues
anyone else has any comments about the patchset ? nicolas ? you worked with (lib)opus IIRC
I worked on the decoder, not the encoder. Assuming I understand correctly what ff_af_queue does, the libopusenc part looks fine (except style: "uint8_t* side_data" -> "uint8_t *side_data" and "side_data == NULL" -> "!side_data").
I can not comment usefully on the Matroska part, though. It looks fine at first glance, but I would not spot a subtle mistake.
The "(side_data_size && additional_id == 1)" and "(side_data_size && additional_id == 1) || discard_padding" tests look a bit fragile, and may become a maintenance burden. Maybe checking block_group to see if it was opened
Not sure what you mean by this. But we are opening block_group based on the condition which you want to eliminate.
or setting a flag at the same time would be cleaner.
Setting a flag will mean a lot more refactoring. BlockGroup can arise only in 2 cases now which are covered by the checks currently. If we need to use flags, then we might need more than one flag (one each for different types of case that could trigger opening a BlockGroup) to make the refactor worth it. If you think it will be cleaner that way, please let me know. I can make the change.
But that does not change the logic of the code.
Regards,
-- Nicolas George
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
On Thu, Sep 5, 2013 at 4:09 PM, Vignesh Venkatasubramanian <vigneshv@google.com> wrote:
On Thu, Sep 5, 2013 at 12:33 PM, Nicolas George <nicolas.george@normalesup.org> wrote:
L'octidi 18 fructidor, an CCXXI, Michael Niedermayer a écrit :
i confirm this fixes the issues
anyone else has any comments about the patchset ? nicolas ? you worked with (lib)opus IIRC
I worked on the decoder, not the encoder. Assuming I understand correctly what ff_af_queue does, the libopusenc part looks fine (except style: "uint8_t* side_data" -> "uint8_t *side_data" and "side_data == NULL" -> "!side_data").
I can not comment usefully on the Matroska part, though. It looks fine at first glance, but I would not spot a subtle mistake.
The "(side_data_size && additional_id == 1)" and "(side_data_size && additional_id == 1) || discard_padding" tests look a bit fragile, and may become a maintenance burden. Maybe checking block_group to see if it was opened
Not sure what you mean by this. But we are opening block_group based on the condition which you want to eliminate.
or setting a flag at the same time would be cleaner.
Setting a flag will mean a lot more refactoring. BlockGroup can arise only in 2 cases now which are covered by the checks currently. If we need to use flags, then we might need more than one flag (one each for different types of case that could trigger opening a BlockGroup) to make the refactor worth it. If you think it will be cleaner that way, please let me know. I can make the change.
Michael/Nicolas, any thoughts on this?
But that does not change the logic of the code.
Regards,
-- Nicolas George
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
On Mon, Sep 09, 2013 at 10:22:58AM -0700, Vignesh Venkatasubramanian wrote:
On Thu, Sep 5, 2013 at 4:09 PM, Vignesh Venkatasubramanian <vigneshv@google.com> wrote:
On Thu, Sep 5, 2013 at 12:33 PM, Nicolas George <nicolas.george@normalesup.org> wrote:
L'octidi 18 fructidor, an CCXXI, Michael Niedermayer a écrit :
i confirm this fixes the issues
anyone else has any comments about the patchset ? nicolas ? you worked with (lib)opus IIRC
I worked on the decoder, not the encoder. Assuming I understand correctly what ff_af_queue does, the libopusenc part looks fine (except style: "uint8_t* side_data" -> "uint8_t *side_data" and "side_data == NULL" -> "!side_data").
I can not comment usefully on the Matroska part, though. It looks fine at first glance, but I would not spot a subtle mistake.
The "(side_data_size && additional_id == 1)" and "(side_data_size && additional_id == 1) || discard_padding" tests look a bit fragile, and may become a maintenance burden. Maybe checking block_group to see if it was opened
Not sure what you mean by this. But we are opening block_group based on the condition which you want to eliminate.
or setting a flag at the same time would be cleaner.
Setting a flag will mean a lot more refactoring. BlockGroup can arise only in 2 cases now which are covered by the checks currently. If we need to use flags, then we might need more than one flag (one each for different types of case that could trigger opening a BlockGroup) to make the refactor worth it. If you think it will be cleaner that way, please let me know. I can make the change.
Michael/Nicolas, any thoughts on this?
i thought too it can be made cleaner but my try didnt end up looking any simpler/cleaner so ill apply that patch as is. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB During times of universal deceit, telling the truth becomes a revolutionary act. -- George Orwell
Le quartidi 24 fructidor, an CCXXI, Michael Niedermayer a écrit :
i thought too it can be made cleaner but my try didnt end up looking any simpler/cleaner so ill apply that patch as is.
I could not reply earlier, but no objection from me, it was just a minor remark. Regards, -- Nicolas George
On Fri, Aug 30, 2013 at 11:25:12AM -0700, Vignesh Venkatasubramanian wrote:
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. With this patch and its companion muxer patch, we can ensure number of samples in == number of samples out for Opus in Matroska.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> ---
libavcodec/utils.c | 21 +++++++++++++++++++++ libavformat/matroskadec.c | 30 +++++++++++++++++++++++++-----
these 2 belong in seperate patches, the utils changes make sense on their own without the matroska changes
2 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 0be9340..477a1a1 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2111,6 +2111,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { uint8_t *side; int side_size; + uint32_t discard_padding = 0; // copy to ensure we do not change avpkt AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp); @@ -2145,6 +2146,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, avctx->internal->skip_samples = AV_RL32(side); av_log(avctx, AV_LOG_DEBUG, "skip %d samples due to side data\n", avctx->internal->skip_samples); + discard_padding = AV_RL32(side + 4); } if (avctx->internal->skip_samples && *got_frame_ptr) { if(frame->nb_samples <= avctx->internal->skip_samples){ @@ -2175,6 +2177,25 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, } }
+ if (discard_padding > 0 && *got_frame_ptr) { + if (discard_padding == frame->nb_samples) { + *got_frame_ptr = 0; + } else { + if(avctx->pkt_timebase.num && avctx->sample_rate) { + int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding, + (AVRational){1, avctx->sample_rate}, + avctx->pkt_timebase); + if (av_frame_get_pkt_duration(frame) >= diff_ts) + av_frame_set_pkt_duration(frame, av_frame_get_pkt_duration(frame) - diff_ts); + } else { + av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n"); + } + av_log(avctx, AV_LOG_DEBUG, "discard %d/%d samples\n", + discard_padding, frame->nb_samples); + frame->nb_samples -= discard_padding;
use of untrusted and unchecked values for changing array dimensions [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly. Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/matroskadec.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index f1e466d..50cb51b 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -290,6 +290,7 @@ typedef struct { EbmlBin bin; uint64_t additional_id; EbmlBin additional; + uint64_t discard_padding; } MatroskaBlock; static EbmlSyntax ebml_header[] = { @@ -563,6 +564,7 @@ static EbmlSyntax matroska_blockgroup[] = { { MATROSKA_ID_BLOCKADDITIONS, EBML_NEST, 0, 0, {.n=matroska_blockadditions} }, { MATROSKA_ID_SIMPLEBLOCK, EBML_BIN, 0, offsetof(MatroskaBlock,bin) }, { MATROSKA_ID_BLOCKDURATION, EBML_UINT, 0, offsetof(MatroskaBlock,duration) }, + { MATROSKA_ID_DISCARDPADDING, EBML_UINT, 0, offsetof(MatroskaBlock,discard_padding) }, { MATROSKA_ID_BLOCKREFERENCE, EBML_UINT, 0, offsetof(MatroskaBlock,reference) }, { MATROSKA_ID_CODECSTATE, EBML_NONE }, { 1, EBML_UINT, 0, offsetof(MatroskaBlock,non_simple), {.u=1} }, @@ -2360,7 +2362,8 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, uint8_t *data, int pkt_size, uint64_t timecode, uint64_t lace_duration, int64_t pos, int is_keyframe, - uint8_t *additional, uint64_t additional_id, int additional_size) + uint8_t *additional, uint64_t additional_id, int additional_size, + uint64_t discard_padding) { MatroskaTrackEncoding *encodings = track->encodings.elem; uint8_t *pkt_data = data; @@ -2423,6 +2426,21 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, memcpy(side_data + 8, additional, additional_size); } + if (discard_padding) { + uint8_t *side_data = av_packet_new_side_data(pkt, + AV_PKT_DATA_SKIP_SAMPLES, + 10); + if(side_data == NULL) { + av_free_packet(pkt); + av_free(pkt); + return AVERROR(ENOMEM); + } + AV_WL32(side_data, 0); + AV_WL32(side_data + 4, av_rescale_q(discard_padding, + (AVRational){1, 1000000000}, + (AVRational){1, st->codec->sample_rate})); + } + if (track->ms_compat) pkt->dts = timecode; else @@ -2482,7 +2500,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t block_duration, int is_keyframe, uint8_t *additional, uint64_t additional_id, int additional_size, - int64_t cluster_pos) + int64_t cluster_pos, uint64_t discard_padding) { uint64_t timecode = AV_NOPTS_VALUE; MatroskaTrack *track; @@ -2594,7 +2612,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, res = matroska_parse_frame(matroska, track, st, data, lace_size[n], timecode, lace_duration, pos, !n? is_keyframe : 0, - additional, additional_id, additional_size); + additional, additional_id, additional_size, + discard_padding); if (res) goto end; } @@ -2661,7 +2680,8 @@ static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska) blocks[i].duration, is_keyframe, additional, blocks[i].additional_id, blocks[i].additional.size, - matroska->current_cluster_pos); + matroska->current_cluster_pos, + blocks[i].discard_padding); } } @@ -2691,7 +2711,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) blocks[i].bin.data, blocks[i].bin.size, blocks[i].bin.pos, cluster.timecode, blocks[i].duration, is_keyframe, NULL, 0, 0, - pos); + pos, blocks[i].discard_padding); } ebml_free(matroska_cluster, &cluster); return res; -- 1.8.4
On Tue, Sep 10, 2013 at 11:12:21AM -0700, Vignesh Venkatasubramanian wrote:
Implementing support for end trimming Opus in Matroska by making use of the DiscardPadding value from the container and discarding the samples accordingly.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/matroskadec.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf
On Tue, Aug 20, 2013 at 3:13 PM, Vignesh Venkatasubramanian <vigneshv@google.com> wrote:
Support for end trimming Opus in Matroska is implemented by using the DiscardPadding container element in the Block data. The last chunk is stored as a Block instead of SimpleBlock and the trimming information is stored and used to discard samples that were padded by the Opus codec. This patch adds support for muxing DiscardPadding element into the container with appropriate value. Matroska spec for the DiscardPadding element can be found here: http://matroska.org/technical/specs/index.html#DiscardPadding
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/avpacket.c | 2 -- libavcodec/libopusenc.c | 12 ++++++++++++ libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 24 ++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 7196c31..ac761f1 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -225,8 +225,6 @@ int av_copy_packet_side_data(AVPacket *pkt, AVPacket *src) int i; DUP_DATA(pkt->side_data, src->side_data, src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC); - memset(pkt->side_data, 0, - src->side_data_elems * sizeof(*src->side_data)); for (i = 0; i < src->side_data_elems; i++) { DUP_DATA(pkt->side_data[i].data, src->side_data[i].data, src->side_data[i].size, 1, ALLOC_MALLOC); diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index 59caac7..775b2ef 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -354,6 +354,18 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, ff_af_queue_remove(&opus->afq, opus->opts.packet_size, &avpkt->pts, &avpkt->duration);
+ if (opus->opts.packet_size - avpkt->duration > 0) { + uint8_t* side_data = av_packet_new_side_data(avpkt, + AV_PKT_DATA_SKIP_SAMPLES, + 10); + if(side_data == NULL) { + av_free_packet(avpkt); + av_free(avpkt); + return AVERROR(ENOMEM); + } + AV_WL32(side_data + 4, opus->opts.packet_size - avpkt->duration); + } + *got_packet_ptr = 1;
return 0; diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 7cf423c..002fc4c 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -198,6 +198,7 @@ #define MATROSKA_ID_BLOCKDURATION 0x9B #define MATROSKA_ID_BLOCKREFERENCE 0xFB #define MATROSKA_ID_CODECSTATE 0xA4 +#define MATROSKA_ID_DISCARDPADDING 0x75A2
/* IDs in the attachments master */ #define MATROSKA_ID_ATTACHEDFILE 0x61A7 diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 92df6cb..7ad35b5 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -43,6 +43,7 @@
#include "libavcodec/xiph.h" #include "libavcodec/mpeg4audio.h" +#include "libavcodec/internal.h"
typedef struct ebml_master { int64_t pos; ///< absolute offset in the file where the master's elements start @@ -1283,7 +1284,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, uint8_t *data = NULL, *side_data = NULL; int offset = 0, size = pkt->size, side_data_size = 0; int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts; - uint64_t additional_id = 0; + uint64_t additional_id = 0, discard_padding = 0; ebml_master block_group, block_additions, block_more;
av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, " @@ -1309,6 +1310,16 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, }
side_data = av_packet_get_side_data(pkt, + AV_PKT_DATA_SKIP_SAMPLES, + &side_data_size); + + if (side_data && side_data_size >= 10) { + discard_padding = av_rescale_q(AV_RL32(side_data + 4), + (AVRational){1, codec->sample_rate}, + (AVRational){1, 1000000000}); + } + + side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size); if (side_data) { @@ -1317,7 +1328,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, side_data_size -= 8; }
- if (side_data_size && additional_id == 1) { + if ((side_data_size && additional_id == 1) || discard_padding) { block_group = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, 0); blockid = MATROSKA_ID_BLOCK; } @@ -1331,6 +1342,10 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, if (data != pkt->data) av_free(data);
+ if (discard_padding) { + put_ebml_uint(pb, MATROSKA_ID_DISCARDPADDING, discard_padding); + } + if (side_data_size && additional_id == 1) { block_additions = start_ebml_master(pb, MATROSKA_ID_BLOCKADDITIONS, 0); block_more = start_ebml_master(pb, MATROSKA_ID_BLOCKMORE, 0); @@ -1340,6 +1355,8 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, avio_write(pb, side_data, side_data_size); end_ebml_master(pb, block_more); end_ebml_master(pb, block_additions); + } + if ((side_data_size && additional_id == 1) || discard_padding) { end_ebml_master(pb, block_group); } } @@ -1556,6 +1573,9 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) ret = mkv->cur_audio_pkt.buf ? 0 : AVERROR(ENOMEM); } else ret = av_dup_packet(&mkv->cur_audio_pkt); + if (mkv->cur_audio_pkt.side_data_elems > 0) { + ret = av_copy_packet_side_data(&mkv->cur_audio_pkt, &mkv->cur_audio_pkt); + } } else ret = mkv_write_packet_internal(s, pkt); return ret; -- 1.8.3
Could someone please look into this? Thanks!
On Tue, Aug 20, 2013 at 03:13:36PM -0700, Vignesh Venkatasubramanian wrote:
Support for end trimming Opus in Matroska is implemented by using the DiscardPadding container element in the Block data. The last chunk is stored as a Block instead of SimpleBlock and the trimming information is stored and used to discard samples that were padded by the Opus codec. This patch adds support for muxing DiscardPadding element into the container with appropriate value. Matroska spec for the DiscardPadding element can be found here: http://matroska.org/technical/specs/index.html#DiscardPadding
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/avpacket.c | 2 -- libavcodec/libopusenc.c | 12 ++++++++++++ libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 24 ++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 7196c31..ac761f1 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -225,8 +225,6 @@ int av_copy_packet_side_data(AVPacket *pkt, AVPacket *src) int i; DUP_DATA(pkt->side_data, src->side_data, src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC); - memset(pkt->side_data, 0, - src->side_data_elems * sizeof(*src->side_data)); for (i = 0; i < src->side_data_elems; i++) { DUP_DATA(pkt->side_data[i].data, src->side_data[i].data, src->side_data[i].size, 1, ALLOC_MALLOC);
i see why you need this but simply removing the memset could leave the packets in a invalid state on error conditions. From a quick look this looks like it could then lead to double frees Also this belongs in a seperate patch
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index 59caac7..775b2ef 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -354,6 +354,18 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, ff_af_queue_remove(&opus->afq, opus->opts.packet_size, &avpkt->pts, &avpkt->duration);
+ if (opus->opts.packet_size - avpkt->duration > 0) {
could the subtraction overflow ?
+ uint8_t* side_data = av_packet_new_side_data(avpkt, + AV_PKT_DATA_SKIP_SAMPLES, + 10); + if(side_data == NULL) { + av_free_packet(avpkt); + av_free(avpkt); + return AVERROR(ENOMEM); + } + AV_WL32(side_data + 4, opus->opts.packet_size - avpkt->duration); + } + *got_packet_ptr = 1;
return 0;
this too belongs in a seperate patch [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
On Thu, Aug 29, 2013 at 5:29 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
On Tue, Aug 20, 2013 at 03:13:36PM -0700, Vignesh Venkatasubramanian wrote:
Support for end trimming Opus in Matroska is implemented by using the DiscardPadding container element in the Block data. The last chunk is stored as a Block instead of SimpleBlock and the trimming information is stored and used to discard samples that were padded by the Opus codec. This patch adds support for muxing DiscardPadding element into the container with appropriate value. Matroska spec for the DiscardPadding element can be found here: http://matroska.org/technical/specs/index.html#DiscardPadding
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavcodec/avpacket.c | 2 -- libavcodec/libopusenc.c | 12 ++++++++++++ libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 24 ++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 7196c31..ac761f1 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -225,8 +225,6 @@ int av_copy_packet_side_data(AVPacket *pkt, AVPacket *src) int i; DUP_DATA(pkt->side_data, src->side_data, src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC); - memset(pkt->side_data, 0, - src->side_data_elems * sizeof(*src->side_data)); for (i = 0; i < src->side_data_elems; i++) { DUP_DATA(pkt->side_data[i].data, src->side_data[i].data, src->side_data[i].size, 1, ALLOC_MALLOC);
i see why you need this but simply removing the memset could leave the packets in a invalid state on error conditions. From a quick look this looks like it could then lead to double frees
Also this belongs in a seperate patch
Sorry about that, will refactor into a seperate patch.
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index 59caac7..775b2ef 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -354,6 +354,18 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, ff_af_queue_remove(&opus->afq, opus->opts.packet_size, &avpkt->pts, &avpkt->duration);
+ if (opus->opts.packet_size - avpkt->duration > 0) {
could the subtraction overflow ?
possibly. adding a check for it.
+ uint8_t* side_data = av_packet_new_side_data(avpkt, + AV_PKT_DATA_SKIP_SAMPLES, + 10); + if(side_data == NULL) { + av_free_packet(avpkt); + av_free(avpkt); + return AVERROR(ENOMEM); + } + AV_WL32(side_data + 4, opus->opts.packet_size - avpkt->duration); + } + *got_packet_ptr = 1;
return 0;
this too belongs in a seperate patch
Sorry again, will refactor.
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-- Vignesh Venkat | Software Engineer | vigneshv@google.com | 650-861-1330
Support for end trimming Opus in Matroska is implemented by using the DiscardPadding container element in the Block data. The last chunk is stored as a Block instead of SimpleBlock and the trimming information is stored and used to discard samples that were padded by the Opus codec. This patch adds support for muxing DiscardPadding element into the container with appropriate value. Matroska spec for the DiscardPadding element can be found here: http://matroska.org/technical/specs/index.html#DiscardPadding Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 7cf423c..002fc4c 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -198,6 +198,7 @@ #define MATROSKA_ID_BLOCKDURATION 0x9B #define MATROSKA_ID_BLOCKREFERENCE 0xFB #define MATROSKA_ID_CODECSTATE 0xA4 +#define MATROSKA_ID_DISCARDPADDING 0x75A2 /* IDs in the attachments master */ #define MATROSKA_ID_ATTACHEDFILE 0x61A7 diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index aa979ea..57460ff 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -43,6 +43,7 @@ #include "libavcodec/xiph.h" #include "libavcodec/mpeg4audio.h" +#include "libavcodec/internal.h" typedef struct ebml_master { int64_t pos; ///< absolute offset in the file where the master's elements start @@ -1285,7 +1286,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, uint8_t *data = NULL, *side_data = NULL; int offset = 0, size = pkt->size, side_data_size = 0; int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts; - uint64_t additional_id = 0; + uint64_t additional_id = 0, discard_padding = 0; ebml_master block_group, block_additions, block_more; av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, " @@ -1311,6 +1312,16 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, } side_data = av_packet_get_side_data(pkt, + AV_PKT_DATA_SKIP_SAMPLES, + &side_data_size); + + if (side_data && side_data_size >= 10) { + discard_padding = av_rescale_q(AV_RL32(side_data + 4), + (AVRational){1, codec->sample_rate}, + (AVRational){1, 1000000000}); + } + + side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size); if (side_data) { @@ -1319,7 +1330,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, side_data_size -= 8; } - if (side_data_size && additional_id == 1) { + if ((side_data_size && additional_id == 1) || discard_padding) { block_group = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, 0); blockid = MATROSKA_ID_BLOCK; } @@ -1333,6 +1344,10 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, if (data != pkt->data) av_free(data); + if (discard_padding) { + put_ebml_uint(pb, MATROSKA_ID_DISCARDPADDING, discard_padding); + } + if (side_data_size && additional_id == 1) { block_additions = start_ebml_master(pb, MATROSKA_ID_BLOCKADDITIONS, 0); block_more = start_ebml_master(pb, MATROSKA_ID_BLOCKMORE, 0); @@ -1342,6 +1357,8 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, avio_write(pb, side_data, side_data_size); end_ebml_master(pb, block_more); end_ebml_master(pb, block_additions); + } + if ((side_data_size && additional_id == 1) || discard_padding) { end_ebml_master(pb, block_group); } } @@ -1558,6 +1575,9 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) ret = mkv->cur_audio_pkt.buf ? 0 : AVERROR(ENOMEM); } else ret = av_dup_packet(&mkv->cur_audio_pkt); + if (mkv->cur_audio_pkt.side_data_elems > 0) { + ret = av_copy_packet_side_data(&mkv->cur_audio_pkt, &mkv->cur_audio_pkt); + } } else ret = mkv_write_packet_internal(s, pkt); return ret; -- 1.8.4
On Fri, Aug 30, 2013 at 11:26:37AM -0700, Vignesh Venkatasubramanian wrote:
Support for end trimming Opus in Matroska is implemented by using the DiscardPadding container element in the Block data. The last chunk is stored as a Block instead of SimpleBlock and the trimming information is stored and used to discard samples that were padded by the Opus codec. This patch adds support for muxing DiscardPadding element into the container with appropriate value. Matroska spec for the DiscardPadding element can be found here: http://matroska.org/technical/specs/index.html#DiscardPadding
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-)
applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope
participants (3)
-
Michael Niedermayer -
Nicolas George -
Vignesh Venkatasubramanian