diff mbox

[FFmpeg-devel,2/3] avformat/mov: use av_stream_add_side_data() for displaymatrix side data

Message ID 20161117054115.3732-2-jamrial@gmail.com
State Accepted
Headers show

Commit Message

James Almer Nov. 17, 2016, 5:41 a.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/mov.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

Michael Niedermayer Nov. 19, 2016, 1:02 a.m. UTC | #1
On Thu, Nov 17, 2016 at 02:41:14AM -0300, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavformat/mov.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 8d6cc12..5ba9965 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -5647,20 +5647,13 @@ static int mov_read_header(AVFormatContext *s)
>              break;
>          case AVMEDIA_TYPE_VIDEO:
>              if (sc->display_matrix) {
> -                AVPacketSideData *sd, *tmp;
> +                int ret;
>  
> -                tmp = av_realloc_array(st->side_data,
> -                                       st->nb_side_data + 1, sizeof(*tmp));
> -                if (!tmp)
> +                ret = av_stream_add_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, (uint8_t*)sc->display_matrix,
> +                                              sizeof(int32_t) * 9);
> +                if (ret < 0)

>                      return AVERROR(ENOMEM);

is this intended not to be return ret ?

should be ok otherwise

[...]
James Almer Nov. 19, 2016, 1:23 a.m. UTC | #2
On 11/18/2016 10:02 PM, Michael Niedermayer wrote:
> On Thu, Nov 17, 2016 at 02:41:14AM -0300, James Almer wrote:
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>  libavformat/mov.c | 15 ++++-----------
>>  1 file changed, 4 insertions(+), 11 deletions(-)
>>
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index 8d6cc12..5ba9965 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -5647,20 +5647,13 @@ static int mov_read_header(AVFormatContext *s)
>>              break;
>>          case AVMEDIA_TYPE_VIDEO:
>>              if (sc->display_matrix) {
>> -                AVPacketSideData *sd, *tmp;
>> +                int ret;
>>  
>> -                tmp = av_realloc_array(st->side_data,
>> -                                       st->nb_side_data + 1, sizeof(*tmp));
>> -                if (!tmp)
>> +                ret = av_stream_add_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, (uint8_t*)sc->display_matrix,
>> +                                              sizeof(int32_t) * 9);
>> +                if (ret < 0)
> 
>>                      return AVERROR(ENOMEM);
> 
> is this intended not to be return ret ?

No, it is supposed to return ret. Guess i was so overzealous trying
to get a diff as small as possible that this slipped by :P

> 
> should be ok otherwise

Fixed and pushed, thanks.
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8d6cc12..5ba9965 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5647,20 +5647,13 @@  static int mov_read_header(AVFormatContext *s)
             break;
         case AVMEDIA_TYPE_VIDEO:
             if (sc->display_matrix) {
-                AVPacketSideData *sd, *tmp;
+                int ret;
 
-                tmp = av_realloc_array(st->side_data,
-                                       st->nb_side_data + 1, sizeof(*tmp));
-                if (!tmp)
+                ret = av_stream_add_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, (uint8_t*)sc->display_matrix,
+                                              sizeof(int32_t) * 9);
+                if (ret < 0)
                     return AVERROR(ENOMEM);
 
-                st->side_data = tmp;
-                st->nb_side_data++;
-
-                sd = &st->side_data[st->nb_side_data - 1];
-                sd->type = AV_PKT_DATA_DISPLAYMATRIX;
-                sd->size = sizeof(int32_t) * 9;
-                sd->data = (uint8_t*)sc->display_matrix;
                 sc->display_matrix = NULL;
             }
             break;