diff mbox

[FFmpeg-devel] lavc/internal: Constify AVPacket* in AVCodecInternal.

Message ID 201702261238.14979.cehoyos@ag.or.at
State Accepted
Commit 5dd7ea9f569b92c1e3de10eff46b80f3dfa63a1d
Headers show

Commit Message

Carl Eugen Hoyos Feb. 26, 2017, 11:38 a.m. UTC
Hi!

Attached patch fixes another warning when compiling libavcodec/utils.o.

Please comment, Carl Eugen
From 1a77bc829eb2a906e175f296821ee7f91f19724a Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos@ag.or.at>
Date: Sun, 26 Feb 2017 12:34:41 +0100
Subject: [PATCH] lavc/internal: Constify AVPacket* in AVCodecInternal.

Fixes a gcc warning:
libavcodec/utils.c:2244:26: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
---
 libavcodec/internal.h |    2 +-
 libavcodec/utils.c    |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer March 1, 2017, 12:04 p.m. UTC | #1
On Sun, Feb 26, 2017 at 12:38:14PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes another warning when compiling libavcodec/utils.o.
> 
> Please comment, Carl Eugen

if it doesnt produce any new warnings elsewere then its probably ok

[...]
Carl Eugen Hoyos March 1, 2017, 9:08 p.m. UTC | #2
2017-03-01 13:04 GMT+01:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Sun, Feb 26, 2017 at 12:38:14PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch fixes another warning when compiling libavcodec/utils.o.
>>
>> Please comment, Carl Eugen
>
> if it doesnt produce any new warnings elsewere then its probably ok

It produces additional warnings without one of the two patches attached
to "lavc/avpacket: Make pkt parameter of av_packet_get_side_data() const."
With both patches applied, all warnings disappear.

Carl Eugen
Carl Eugen Hoyos March 16, 2017, 8:16 p.m. UTC | #3
2017-03-01 13:04 GMT+01:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Sun, Feb 26, 2017 at 12:38:14PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch fixes another warning when compiling libavcodec/utils.o.
>>
>> Please comment, Carl Eugen
>
> if it doesnt produce any new warnings elsewere then its probably ok

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index c92dba4..cbbbb6c 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -141,7 +141,7 @@  typedef struct AVCodecInternal {
      * Current packet as passed into the decoder, to avoid having to pass the
      * packet into every function.
      */
-    AVPacket *pkt;
+    const AVPacket *pkt;
 
     /**
      * temporary buffer used for encoders to store their bitstream
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 1156e43..e0d4b04 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -745,7 +745,7 @@  int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags
     }
 }
 
-static int add_metadata_from_side_data(AVPacket *avpkt, AVFrame *frame)
+static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame)
 {
     int size;
     const uint8_t *side_metadata;
@@ -759,7 +759,7 @@  static int add_metadata_from_side_data(AVPacket *avpkt, AVFrame *frame)
 
 int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
 {
-    AVPacket *pkt = avctx->internal->pkt;
+    const AVPacket *pkt = avctx->internal->pkt;
     int i;
     static const struct {
         enum AVPacketSideDataType packet;