diff mbox

[FFmpeg-devel,08/10] lavf/matroskaenc: don't rewrite extradata if we already have some

Message ID 20180314062445.89909-8-rodger.combs@gmail.com
State Withdrawn, archived
Headers show

Commit Message

Rodger Combs March 14, 2018, 6:24 a.m. UTC
matroska doesn't support mid-stream extradata changes, and rewriting
the same extradata already written in write_header would cause errors
since we previously didn't write a filler void.
---
 libavformat/matroskaenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

James Almer March 15, 2018, 10:36 p.m. UTC | #1
On 3/14/2018 3:24 AM, Rodger Combs wrote:
> matroska doesn't support mid-stream extradata changes

How so? We update flac extradata as sent by the encoder in the last
packet as side data.

> , and rewriting
> the same extradata already written in write_header would cause errors
> since we previously didn't write a filler void.

When would this happen? What sets both extradata in codecpar then sends
new one as packet side data for AAC audio?

> ---
>  libavformat/matroskaenc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 5950b4de44..e4db5a9a1c 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -2266,7 +2266,8 @@ static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt)
>  
>      switch (par->codec_id) {
>      case AV_CODEC_ID_AAC:
> -        if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) {
> +        if (side_data_size && !par->extradata_size &&
> +            (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) {
>              int filler, output_sample_rate = 0;
>              int64_t curpos;
>              ret = get_aac_sample_rates(s, side_data, side_data_size, &track->sample_rate,
>
Rodger Combs March 15, 2018, 10:41 p.m. UTC | #2
> On Mar 15, 2018, at 17:36, James Almer <jamrial@gmail.com> wrote:
> 
> On 3/14/2018 3:24 AM, Rodger Combs wrote:
>> matroska doesn't support mid-stream extradata changes
> 
> How so? We update flac extradata as sent by the encoder in the last
> packet as side data.

Right, but the format itself doesn't support changing mid-stream; we handle that case by rewriting the header.

> 
>> , and rewriting
>> the same extradata already written in write_header would cause errors
>> since we previously didn't write a filler void.
> 
> When would this happen? What sets both extradata in codecpar then sends
> new one as packet side data for AAC audio?

Happens after the subsequent patch ("lavf/mux: propagate extradata changes before we call write_header to codecpar").

> 
>> ---
>> libavformat/matroskaenc.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
>> index 5950b4de44..e4db5a9a1c 100644
>> --- a/libavformat/matroskaenc.c
>> +++ b/libavformat/matroskaenc.c
>> @@ -2266,7 +2266,8 @@ static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt)
>> 
>>     switch (par->codec_id) {
>>     case AV_CODEC_ID_AAC:
>> -        if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) {
>> +        if (side_data_size && !par->extradata_size &&
>> +            (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) {
>>             int filler, output_sample_rate = 0;
>>             int64_t curpos;
>>             ret = get_aac_sample_rates(s, side_data, side_data_size, &track->sample_rate,
>> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
diff mbox

Patch

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 5950b4de44..e4db5a9a1c 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2266,7 +2266,8 @@  static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt)
 
     switch (par->codec_id) {
     case AV_CODEC_ID_AAC:
-        if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) {
+        if (side_data_size && !par->extradata_size &&
+            (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) {
             int filler, output_sample_rate = 0;
             int64_t curpos;
             ret = get_aac_sample_rates(s, side_data, side_data_size, &track->sample_rate,