diff mbox

[FFmpeg-devel] lavc/mediacodecdec_h2645: fix nalu data_size type

Message ID 20160930163411.6743-1-matthieu.bouron@gmail.com
State Accepted
Commit 68822da8ff7dd33480c0bfdb2e769bcbe445b018
Headers show

Commit Message

Matthieu Bouron Sept. 30, 2016, 4:34 p.m. UTC
From: Matthieu Bouron <matthieu.bouron@stupeflix.com>

---
 libavcodec/mediacodecdec_h2645.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Josh Dekker Sept. 30, 2016, 4:51 p.m. UTC | #1
On 30/09/2016 17:34, Matthieu Bouron wrote:
> From: Matthieu Bouron <matthieu.bouron@stupeflix.com>
>
> ---
>  libavcodec/mediacodecdec_h2645.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/mediacodecdec_h2645.c b/libavcodec/mediacodecdec_h2645.c
> index 122be88..9f8110c 100644
> --- a/libavcodec/mediacodecdec_h2645.c
> +++ b/libavcodec/mediacodecdec_h2645.c
> @@ -154,7 +154,7 @@ static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
>
>      if (pps && sps) {
>          uint8_t *data = NULL;
> -        size_t data_size = 0;
> +        int data_size = 0;
>
>          if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
>              goto done;
>

Shouldn't you change h2645_ps_to_nalu()'s size arguments to size_t as well?

--
Josh
wm4 Sept. 30, 2016, 5:01 p.m. UTC | #2
On Fri, 30 Sep 2016 17:51:42 +0100
Josh de Kock <josh@itanimul.li> wrote:

> On 30/09/2016 17:34, Matthieu Bouron wrote:
> > From: Matthieu Bouron <matthieu.bouron@stupeflix.com>
> >
> > ---
> >  libavcodec/mediacodecdec_h2645.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/mediacodecdec_h2645.c b/libavcodec/mediacodecdec_h2645.c
> > index 122be88..9f8110c 100644
> > --- a/libavcodec/mediacodecdec_h2645.c
> > +++ b/libavcodec/mediacodecdec_h2645.c
> > @@ -154,7 +154,7 @@ static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
> >
> >      if (pps && sps) {
> >          uint8_t *data = NULL;
> > -        size_t data_size = 0;
> > +        int data_size = 0;
> >
> >          if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
> >              goto done;
> >  
> 
> Shouldn't you change h2645_ps_to_nalu()'s size arguments to size_t as well?

FFmpeg uses int instead of size_t in a LOT of places (including API).
Might be a little bit too late to fix this convention.
Matthieu Bouron Oct. 1, 2016, 10:52 a.m. UTC | #3
On Fri, Sep 30, 2016 at 07:01:09PM +0200, wm4 wrote:
> On Fri, 30 Sep 2016 17:51:42 +0100
> Josh de Kock <josh@itanimul.li> wrote:
> 
> > On 30/09/2016 17:34, Matthieu Bouron wrote:
> > > From: Matthieu Bouron <matthieu.bouron@stupeflix.com>
> > >
> > > ---
> > >  libavcodec/mediacodecdec_h2645.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/libavcodec/mediacodecdec_h2645.c b/libavcodec/mediacodecdec_h2645.c
> > > index 122be88..9f8110c 100644
> > > --- a/libavcodec/mediacodecdec_h2645.c
> > > +++ b/libavcodec/mediacodecdec_h2645.c
> > > @@ -154,7 +154,7 @@ static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
> > >
> > >      if (pps && sps) {
> > >          uint8_t *data = NULL;
> > > -        size_t data_size = 0;
> > > +        int data_size = 0;
> > >
> > >          if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
> > >              goto done;
> > >  
> > 
> > Shouldn't you change h2645_ps_to_nalu()'s size arguments to size_t as well?
> 
> FFmpeg uses int instead of size_t in a LOT of places (including API).
> Might be a little bit too late to fix this convention.

Yes. On the other hand:
  * PPS.data_size type is size_t and PPS.data is uint8_t[4096].
  * ff_AMediaFormat_SetBuffer takes a size_t for the data_size argument.

IMHO, I don't think switching to size_t is a real improvement here but if
you think it is I can update the patch (otherwise I'll wait another day
and push it as is).

Matthieu
Matthieu Bouron Oct. 3, 2016, 12:18 p.m. UTC | #4
On Sat, Oct 01, 2016 at 12:52:53PM +0200, Matthieu Bouron wrote:
> On Fri, Sep 30, 2016 at 07:01:09PM +0200, wm4 wrote:
> > On Fri, 30 Sep 2016 17:51:42 +0100
> > Josh de Kock <josh@itanimul.li> wrote:
> > 
> > > On 30/09/2016 17:34, Matthieu Bouron wrote:
> > > > From: Matthieu Bouron <matthieu.bouron@stupeflix.com>
> > > >
> > > > ---
> > > >  libavcodec/mediacodecdec_h2645.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/libavcodec/mediacodecdec_h2645.c b/libavcodec/mediacodecdec_h2645.c
> > > > index 122be88..9f8110c 100644
> > > > --- a/libavcodec/mediacodecdec_h2645.c
> > > > +++ b/libavcodec/mediacodecdec_h2645.c
> > > > @@ -154,7 +154,7 @@ static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
> > > >
> > > >      if (pps && sps) {
> > > >          uint8_t *data = NULL;
> > > > -        size_t data_size = 0;
> > > > +        int data_size = 0;
> > > >
> > > >          if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
> > > >              goto done;
> > > >  
> > > 
> > > Shouldn't you change h2645_ps_to_nalu()'s size arguments to size_t as well?
> > 
> > FFmpeg uses int instead of size_t in a LOT of places (including API).
> > Might be a little bit too late to fix this convention.
> 
> Yes. On the other hand:
>   * PPS.data_size type is size_t and PPS.data is uint8_t[4096].
>   * ff_AMediaFormat_SetBuffer takes a size_t for the data_size argument.
> 
> IMHO, I don't think switching to size_t is a real improvement here but if
> you think it is I can update the patch (otherwise I'll wait another day
> and push it as is).

Pushed.

Matthieu
diff mbox

Patch

diff --git a/libavcodec/mediacodecdec_h2645.c b/libavcodec/mediacodecdec_h2645.c
index 122be88..9f8110c 100644
--- a/libavcodec/mediacodecdec_h2645.c
+++ b/libavcodec/mediacodecdec_h2645.c
@@ -154,7 +154,7 @@  static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
 
     if (pps && sps) {
         uint8_t *data = NULL;
-        size_t data_size = 0;
+        int data_size = 0;
 
         if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
             goto done;