diff mbox series

[FFmpeg-devel,2/4] avformat/concatdec: Avoid duplicating buffer when adding side-data

Message ID 20200524002554.28064-2-andreas.rheinhardt@gmail.com
State Accepted
Commit be22f97332a530a42f4548aab1258d52fb17bb77
Headers show
Series [FFmpeg-devel,1/4] avformat/flvdec: Avoid duplicating extradata when adding side-data
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 24, 2020, 12:25 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
The resulting side-data in this and the next two patches won't be padded
anymore. But the documentation doesn't require it and
av_packet_unpack_dictionary() doesn't rely on this anyway.

 libavformat/concatdec.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Nicolas George May 26, 2020, 8:02 a.m. UTC | #1
Andreas Rheinhardt (12020-05-24):
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
> The resulting side-data in this and the next two patches won't be padded
> anymore. But the documentation doesn't require it and
> av_packet_unpack_dictionary() doesn't rely on this anyway.
> 
>  libavformat/concatdec.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)

Ok, I suppose.

Regards,
Andreas Rheinhardt May 27, 2020, 4:35 a.m. UTC | #2
Nicolas George:
> Andreas Rheinhardt (12020-05-24):
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
>> ---
>> The resulting side-data in this and the next two patches won't be padded
>> anymore. But the documentation doesn't require it and
>> av_packet_unpack_dictionary() doesn't rely on this anyway.
>>
>>  libavformat/concatdec.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> Ok, I suppose.
> 
> Regards,
> 
Thanks. Will apply the set tomorrow if nobody else objects.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 2173911ce4..4b56b61404 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -626,17 +626,16 @@  static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
            av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base),
            av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
     if (cat->cur_file->metadata) {
-        uint8_t* metadata;
         int metadata_len;
         char* packed_metadata = av_packet_pack_dictionary(cat->cur_file->metadata, &metadata_len);
         if (!packed_metadata)
             return AVERROR(ENOMEM);
-        if (!(metadata = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, metadata_len))) {
+        ret = av_packet_add_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
+                                      packed_metadata, metadata_len);
+        if (ret < 0) {
             av_freep(&packed_metadata);
-            return AVERROR(ENOMEM);
+            return ret;
         }
-        memcpy(metadata, packed_metadata, metadata_len);
-        av_freep(&packed_metadata);
     }
 
     if (cat->cur_file->duration == AV_NOPTS_VALUE && st->cur_dts != AV_NOPTS_VALUE) {
@@ -647,7 +646,7 @@  static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
     }
 
     pkt->stream_index = cs->out_stream_index;
-    return ret;
+    return 0;
 }
 
 static void rescale_interval(AVRational tb_in, AVRational tb_out,