[libav-devel] [PATCH] h263: K&R formatting cosmetics

2013-10-22 Thread Luca Barbato
Signed-off-by: Vittorio Giovara 
Signed-off-by: Luca Barbato 
---

Now matching exactly the ternary operator.

 libavcodec/h263dec.c | 655 ---
 1 file changed, 364 insertions(+), 291 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 8a021d1..547b295 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -42,59 +42,59 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 {
 MpegEncContext *s = avctx->priv_data;

-s->avctx = avctx;
+s->avctx  = avctx;
 s->out_format = FMT_H263;

-s->width  = avctx->coded_width;
-s->height = avctx->coded_height;
-s->workaround_bugs= avctx->workaround_bugs;
+s->width   = avctx->coded_width;
+s->height  = avctx->coded_height;
+s->workaround_bugs = avctx->workaround_bugs;

 // set defaults
 ff_MPV_decode_defaults(s);
-s->quant_precision=5;
-s->decode_mb= ff_h263_decode_mb;
-s->low_delay= 1;
+s->quant_precision = 5;
+s->decode_mb   = ff_h263_decode_mb;
+s->low_delay   = 1;
 if (avctx->codec->id == AV_CODEC_ID_MSS2)
 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 else
 avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
-s->unrestricted_mv= 1;
+s->unrestricted_mv = 1;

 /* select sub codec */
-switch(avctx->codec->id) {
+switch (avctx->codec->id) {
 case AV_CODEC_ID_H263:
-s->unrestricted_mv= 0;
+s->unrestricted_mv= 0;
 avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
 break;
 case AV_CODEC_ID_MPEG4:
 break;
 case AV_CODEC_ID_MSMPEG4V1:
-s->h263_pred = 1;
-s->msmpeg4_version=1;
+s->h263_pred   = 1;
+s->msmpeg4_version = 1;
 break;
 case AV_CODEC_ID_MSMPEG4V2:
-s->h263_pred = 1;
-s->msmpeg4_version=2;
+s->h263_pred   = 1;
+s->msmpeg4_version = 2;
 break;
 case AV_CODEC_ID_MSMPEG4V3:
-s->h263_pred = 1;
-s->msmpeg4_version=3;
+s->h263_pred   = 1;
+s->msmpeg4_version = 3;
 break;
 case AV_CODEC_ID_WMV1:
-s->h263_pred = 1;
-s->msmpeg4_version=4;
+s->h263_pred   = 1;
+s->msmpeg4_version = 4;
 break;
 case AV_CODEC_ID_WMV2:
-s->h263_pred = 1;
-s->msmpeg4_version=5;
+s->h263_pred   = 1;
+s->msmpeg4_version = 5;
 break;
 case AV_CODEC_ID_VC1:
 case AV_CODEC_ID_WMV3:
 case AV_CODEC_ID_VC1IMAGE:
 case AV_CODEC_ID_WMV3IMAGE:
 case AV_CODEC_ID_MSS2:
-s->h263_pred = 1;
-s->msmpeg4_version=6;
+s->h263_pred  = 1;
+s->msmpeg4_version= 6;
 avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
 break;
 case AV_CODEC_ID_H263I:
@@ -105,15 +105,16 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 default:
 return -1;
 }
-s->codec_id= avctx->codec->id;
-avctx->hwaccel= ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
+s->codec_id= avctx->codec->id;
+avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);

 /* for h263, we allocate the images after having read the header */
-if (avctx->codec->id != AV_CODEC_ID_H263 && avctx->codec->id != 
AV_CODEC_ID_MPEG4)
+if (avctx->codec->id != AV_CODEC_ID_H263 &&
+avctx->codec->id != AV_CODEC_ID_MPEG4)
 if (ff_MPV_common_init(s) < 0)
 return -1;

-ff_h263_decode_init_vlc();
+ff_h263_decode_init_vlc();

 return 0;
 }
@@ -129,232 +130,267 @@ av_cold int ff_h263_decode_end(AVCodecContext *avctx)
 /**
  * Return the number of bytes consumed for building the current frame.
  */
-static int get_consumed_bytes(MpegEncContext *s, int buf_size){
-int pos= (get_bits_count(&s->gb)+7)>>3;
+static int get_consumed_bytes(MpegEncContext *s, int buf_size)
+{
+int pos = (get_bits_count(&s->gb) + 7) >> 3;

-if(s->divx_packed || s->avctx->hwaccel){
-//we would have to scan through the whole buf to handle the weird 
reordering ...
+if (s->divx_packed || s->avctx->hwaccel) {
+/* We would have to scan through the whole buf to handle the weird
+ * reordering ... */
 return buf_size;
-}else if(s->flags&CODEC_FLAG_TRUNCATED){
+} else if (s->flags & CODEC_FLAG_TRUNCATED) {
 pos -= s->parse_context.last_index;
-if(pos<0) pos=0; // padding is not really read so this might be -1
+if (pos < 0)
+pos = 0;// padding is not really read so this might be -1
 return pos;
-}else{
-if(pos==0) pos=1; //avoid infinite loops (i doubt that is needed but 
...)
-if(pos+10>buf_size) pos=buf_size; // oops ;)
+} else {
+if (pos == 0)
+pos = 1;// avoid infinite loops (maybe not needed...)
+if (pos + 10 > buf_

[libav-devel] [PATCH] mpegvideo: Drop a faulty assert

2013-10-22 Thread Luca Barbato
That check is easily reachable by faulty input.

CC:libav-sta...@libav.org
Reported-by: Torsten Sadowski 
---

Could you check libav master and this patch and report back please?

 libavcodec/mpegvideo.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 192e27f..718f946 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1633,8 +1633,12 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext 
*avctx)
 return ret;
 }

-assert(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr &&
- 
s->last_picture_ptr->f.data[0]));
+if (s->pict_type != AV_PICTURE_TYPE_I &&
+!(s->last_picture_ptr && s->last_picture_ptr->f.data[0])) {
+av_log(s, AV_LOG_ERROR,
+   "Non-reference picture received and no reference available\n");
+return AVERROR_INVALIDDATA;
+}

 if (s->picture_structure!= PICT_FRAME) {
 int i;
--
1.8.3.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h263: K&R formatting cosmetics

2013-10-22 Thread Clément Bœsch
On Tue, Oct 22, 2013 at 06:28:09PM +0200, Luca Barbato wrote:
> On 22/10/13 17:33, Vittorio Giovara wrote:
> > From: Luca Barbato 
> > 
> > Signed-off-by: Vittorio Giovara 
> > ---
> > I just added more line breaks in if checks and aligned the \ in a define 
> > clause.
> > Ok for the rest, here's the complete patch.
> > Cheers,
> > Vittorio
> > 
> 
> Fate isn't happy let's see why.
> 

Would that be because you tried to hide a functional change in that patch?

-- 
Clément B.


pgptQIFZ5nMtN.pgp
Description: PGP signature
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH] h263: K&R formatting cosmetics

2013-10-22 Thread Luca Barbato
Signed-off-by: Vittorio Giovara 
Signed-off-by: Luca Barbato 
---

Now w/out typos =P

 libavcodec/h263dec.c | 655 ---
 1 file changed, 364 insertions(+), 291 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 8a021d1..559c233 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -42,59 +42,59 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 {
 MpegEncContext *s = avctx->priv_data;

-s->avctx = avctx;
+s->avctx  = avctx;
 s->out_format = FMT_H263;

-s->width  = avctx->coded_width;
-s->height = avctx->coded_height;
-s->workaround_bugs= avctx->workaround_bugs;
+s->width   = avctx->coded_width;
+s->height  = avctx->coded_height;
+s->workaround_bugs = avctx->workaround_bugs;

 // set defaults
 ff_MPV_decode_defaults(s);
-s->quant_precision=5;
-s->decode_mb= ff_h263_decode_mb;
-s->low_delay= 1;
+s->quant_precision = 5;
+s->decode_mb   = ff_h263_decode_mb;
+s->low_delay   = 1;
 if (avctx->codec->id == AV_CODEC_ID_MSS2)
 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 else
 avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
-s->unrestricted_mv= 1;
+s->unrestricted_mv = 1;

 /* select sub codec */
-switch(avctx->codec->id) {
+switch (avctx->codec->id) {
 case AV_CODEC_ID_H263:
-s->unrestricted_mv= 0;
+s->unrestricted_mv= 0;
 avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
 break;
 case AV_CODEC_ID_MPEG4:
 break;
 case AV_CODEC_ID_MSMPEG4V1:
-s->h263_pred = 1;
-s->msmpeg4_version=1;
+s->h263_pred   = 1;
+s->msmpeg4_version = 1;
 break;
 case AV_CODEC_ID_MSMPEG4V2:
-s->h263_pred = 1;
-s->msmpeg4_version=2;
+s->h263_pred   = 1;
+s->msmpeg4_version = 2;
 break;
 case AV_CODEC_ID_MSMPEG4V3:
-s->h263_pred = 1;
-s->msmpeg4_version=3;
+s->h263_pred   = 1;
+s->msmpeg4_version = 3;
 break;
 case AV_CODEC_ID_WMV1:
-s->h263_pred = 1;
-s->msmpeg4_version=4;
+s->h263_pred   = 1;
+s->msmpeg4_version = 4;
 break;
 case AV_CODEC_ID_WMV2:
-s->h263_pred = 1;
-s->msmpeg4_version=5;
+s->h263_pred   = 1;
+s->msmpeg4_version = 5;
 break;
 case AV_CODEC_ID_VC1:
 case AV_CODEC_ID_WMV3:
 case AV_CODEC_ID_VC1IMAGE:
 case AV_CODEC_ID_WMV3IMAGE:
 case AV_CODEC_ID_MSS2:
-s->h263_pred = 1;
-s->msmpeg4_version=6;
+s->h263_pred  = 1;
+s->msmpeg4_version= 6;
 avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
 break;
 case AV_CODEC_ID_H263I:
@@ -105,15 +105,16 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 default:
 return -1;
 }
-s->codec_id= avctx->codec->id;
-avctx->hwaccel= ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
+s->codec_id= avctx->codec->id;
+avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);

 /* for h263, we allocate the images after having read the header */
-if (avctx->codec->id != AV_CODEC_ID_H263 && avctx->codec->id != 
AV_CODEC_ID_MPEG4)
+if (avctx->codec->id != AV_CODEC_ID_H263 &&
+avctx->codec->id != AV_CODEC_ID_MPEG4)
 if (ff_MPV_common_init(s) < 0)
 return -1;

-ff_h263_decode_init_vlc();
+ff_h263_decode_init_vlc();

 return 0;
 }
@@ -129,232 +130,267 @@ av_cold int ff_h263_decode_end(AVCodecContext *avctx)
 /**
  * Return the number of bytes consumed for building the current frame.
  */
-static int get_consumed_bytes(MpegEncContext *s, int buf_size){
-int pos= (get_bits_count(&s->gb)+7)>>3;
+static int get_consumed_bytes(MpegEncContext *s, int buf_size)
+{
+int pos = (get_bits_count(&s->gb) + 7) >> 3;

-if(s->divx_packed || s->avctx->hwaccel){
-//we would have to scan through the whole buf to handle the weird 
reordering ...
+if (s->divx_packed || s->avctx->hwaccel) {
+/* We would have to scan through the whole buf to handle the weird
+ * reordering ... */
 return buf_size;
-}else if(s->flags&CODEC_FLAG_TRUNCATED){
+} else if (s->flags & CODEC_FLAG_TRUNCATED) {
 pos -= s->parse_context.last_index;
-if(pos<0) pos=0; // padding is not really read so this might be -1
+if (pos < 0)
+pos = 0;// padding is not really read so this might be -1
 return pos;
-}else{
-if(pos==0) pos=1; //avoid infinite loops (i doubt that is needed but 
...)
-if(pos+10>buf_size) pos=buf_size; // oops ;)
+} else {
+if (pos == 0)
+pos = 1;// avoid infinite loops (maybe not needed...)
+if (pos + 10 > buf_size)
+pos =

Re: [libav-devel] [PATCH] h263: K&R formatting cosmetics

2013-10-22 Thread Luca Barbato
On 22/10/13 17:33, Vittorio Giovara wrote:
> From: Luca Barbato 
> 
> Signed-off-by: Vittorio Giovara 
> ---
> I just added more line breaks in if checks and aligned the \ in a define 
> clause.
> Ok for the rest, here's the complete patch.
> Cheers,
> Vittorio
> 

Fate isn't happy let's see why.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] nut: Fix unchecked allocations

2013-10-22 Thread Luca Barbato
On 22/10/13 17:34, Derek Buitenhuis wrote:
> Signed-off-by: Derek Buitenhuis 
> ---
>  libavformat/nut.c| 10 +-
>  libavformat/nut.h|  2 +-
>  libavformat/nutdec.c |  5 -
>  libavformat/nutenc.c |  3 ++-
>  4 files changed, 16 insertions(+), 4 deletions(-)
> 

Looks fine, please CC libav-stable as well.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] nut: Fix unchecked allocations

2013-10-22 Thread Derek Buitenhuis
Signed-off-by: Derek Buitenhuis 
---
 libavformat/nut.c| 10 +-
 libavformat/nut.h|  2 +-
 libavformat/nutdec.c |  5 -
 libavformat/nutenc.c |  3 ++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/libavformat/nut.c b/libavformat/nut.c
index 2e1d129..d9a042b 100644
--- a/libavformat/nut.c
+++ b/libavformat/nut.c
@@ -185,11 +185,17 @@ int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint 
*b)
 return ((a->ts - b->ts) >> 32) - ((b->ts - a->ts) >> 32);
 }
 
-void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts)
+int ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts)
 {
 Syncpoint *sp   = av_mallocz(sizeof(Syncpoint));
 struct AVTreeNode *node = av_tree_node_alloc();
 
+if (!sp || !node) {
+av_freep(&sp);
+av_freep(&node);
+return AVERROR(ENOMEM);
+}
+
 sp->pos  = pos;
 sp->back_ptr = back_ptr;
 sp->ts   = ts;
@@ -198,6 +204,8 @@ void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t 
back_ptr, int64_t ts)
 av_free(sp);
 av_free(node);
 }
+
+return 0;
 }
 
 static int enu_free(void *opaque, void *elem)
diff --git a/libavformat/nut.h b/libavformat/nut.h
index 6eddc96..6357b3d 100644
--- a/libavformat/nut.h
+++ b/libavformat/nut.h
@@ -118,7 +118,7 @@ void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, 
int64_t val);
 int64_t ff_lsb2full(StreamContext *stream, int64_t lsb);
 int ff_nut_sp_pos_cmp(const Syncpoint *a, const Syncpoint *b);
 int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b);
-void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts);
+int ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts);
 void ff_nut_free_sp(NUTContext *nut);
 
 extern const Dispositions ff_nut_dispositions[];
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index cc5869e..6328549 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -532,6 +532,7 @@ static int decode_syncpoint(NUTContext *nut, int64_t *ts, 
int64_t *back_ptr)
 AVFormatContext *s = nut->avf;
 AVIOContext *bc= s->pb;
 int64_t end, tmp;
+int ret;
 
 nut->last_syncpoint_pos = avio_tell(bc) - 8;
 
@@ -553,7 +554,9 @@ static int decode_syncpoint(NUTContext *nut, int64_t *ts, 
int64_t *back_ptr)
 
 *ts = tmp / s->nb_streams *
   av_q2d(nut->time_base[tmp % s->nb_streams]) * AV_TIME_BASE;
-ff_nut_add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts);
+
+if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts)) < 
0)
+return ret;
 
 return 0;
 }
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 8977e72..acce86c 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -815,7 +815,8 @@ static int nut_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 ff_put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos) >> 4 : 0);
 put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE);
 
-ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts);
+if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, 
pkt->dts)) < 0)
+return ret;
 }
 assert(nus->last_pts != AV_NOPTS_VALUE);
 
-- 
1.8.4.rc3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] h263: K&R formatting cosmetics

2013-10-22 Thread Vittorio Giovara
From: Luca Barbato 

Signed-off-by: Vittorio Giovara 
---
I just added more line breaks in if checks and aligned the \ in a define clause.
Ok for the rest, here's the complete patch.
Cheers,
Vittorio

 libavcodec/h263dec.c |  657 --
 1 file changed, 365 insertions(+), 292 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 8a021d1..e60f49f 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -42,59 +42,59 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 {
 MpegEncContext *s = avctx->priv_data;
 
-s->avctx = avctx;
+s->avctx  = avctx;
 s->out_format = FMT_H263;
 
-s->width  = avctx->coded_width;
-s->height = avctx->coded_height;
-s->workaround_bugs= avctx->workaround_bugs;
+s->width   = avctx->coded_width;
+s->height  = avctx->coded_height;
+s->workaround_bugs = avctx->workaround_bugs;
 
 // set defaults
 ff_MPV_decode_defaults(s);
-s->quant_precision=5;
-s->decode_mb= ff_h263_decode_mb;
-s->low_delay= 1;
+s->quant_precision = 5;
+s->decode_mb   = ff_h263_decode_mb;
+s->low_delay   = 1;
 if (avctx->codec->id == AV_CODEC_ID_MSS2)
 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 else
 avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
-s->unrestricted_mv= 1;
+s->unrestricted_mv = 1;
 
 /* select sub codec */
-switch(avctx->codec->id) {
+switch (avctx->codec->id) {
 case AV_CODEC_ID_H263:
-s->unrestricted_mv= 0;
+s->unrestricted_mv= 0;
 avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
 break;
 case AV_CODEC_ID_MPEG4:
 break;
 case AV_CODEC_ID_MSMPEG4V1:
-s->h263_pred = 1;
-s->msmpeg4_version=1;
+s->h263_pred   = 1;
+s->msmpeg4_version = 1;
 break;
 case AV_CODEC_ID_MSMPEG4V2:
-s->h263_pred = 1;
-s->msmpeg4_version=2;
+s->h263_pred   = 1;
+s->msmpeg4_version = 2;
 break;
 case AV_CODEC_ID_MSMPEG4V3:
-s->h263_pred = 1;
-s->msmpeg4_version=3;
+s->h263_pred   = 1;
+s->msmpeg4_version = 3;
 break;
 case AV_CODEC_ID_WMV1:
-s->h263_pred = 1;
-s->msmpeg4_version=4;
+s->h263_pred   = 1;
+s->msmpeg4_version = 4;
 break;
 case AV_CODEC_ID_WMV2:
-s->h263_pred = 1;
-s->msmpeg4_version=5;
+s->h263_pred   = 1;
+s->msmpeg4_version = 5;
 break;
 case AV_CODEC_ID_VC1:
 case AV_CODEC_ID_WMV3:
 case AV_CODEC_ID_VC1IMAGE:
 case AV_CODEC_ID_WMV3IMAGE:
 case AV_CODEC_ID_MSS2:
-s->h263_pred = 1;
-s->msmpeg4_version=6;
+s->h263_pred  = 1;
+s->msmpeg4_version= 6;
 avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
 break;
 case AV_CODEC_ID_H263I:
@@ -105,15 +105,16 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 default:
 return -1;
 }
-s->codec_id= avctx->codec->id;
-avctx->hwaccel= ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
+s->codec_id= avctx->codec->id;
+avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
 
 /* for h263, we allocate the images after having read the header */
-if (avctx->codec->id != AV_CODEC_ID_H263 && avctx->codec->id != 
AV_CODEC_ID_MPEG4)
+if (avctx->codec->id != AV_CODEC_ID_H263 &&
+avctx->codec->id != AV_CODEC_ID_MPEG4)
 if (ff_MPV_common_init(s) < 0)
 return -1;
 
-ff_h263_decode_init_vlc();
+ff_h263_decode_init_vlc();
 
 return 0;
 }
@@ -129,232 +130,267 @@ av_cold int ff_h263_decode_end(AVCodecContext *avctx)
 /**
  * Return the number of bytes consumed for building the current frame.
  */
-static int get_consumed_bytes(MpegEncContext *s, int buf_size){
-int pos= (get_bits_count(&s->gb)+7)>>3;
+static int get_consumed_bytes(MpegEncContext *s, int buf_size)
+{
+int pos = (get_bits_count(&s->gb) + 7) >> 3;
 
-if(s->divx_packed || s->avctx->hwaccel){
-//we would have to scan through the whole buf to handle the weird 
reordering ...
+if (s->divx_packed || s->avctx->hwaccel) {
+/* We would have to scan through the whole buf to handle the weird
+ * reordering ... */
 return buf_size;
-}else if(s->flags&CODEC_FLAG_TRUNCATED){
+} else if (s->flags & CODEC_FLAG_TRUNCATED) {
 pos -= s->parse_context.last_index;
-if(pos<0) pos=0; // padding is not really read so this might be -1
+if (pos < 0)
+pos = 0;// padding is not really read so this might be -1
 return pos;
-}else{
-if(pos==0) pos=1; //avoid infinite loops (i doubt that is needed but 
...)
-if(pos+10>buf_size) pos=buf_size; // oops ;)
+} else {
+if (pos == 0)
+

[libav-devel] [PATCH] fate: fieldorder: fix test when asm is disabled

2013-10-22 Thread Vittorio Giovara
---
I'm not entirely sure about why this is needed, but I'm posting the solution 
early so I can get feedback.
Cheers,
Vittorio

 tests/fate/filter-video.mak  |2 +-
 tests/ref/fate/filter-fieldorder |   52 +++---
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 20cd617..68156df 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -22,7 +22,7 @@ FATE_FILTER_VSYNTH-$(CONFIG_FADE_FILTER) += fate-filter-fade
 fate-filter-fade: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf 
fade=in:0:25,fade=out:25:25
 
 FATE_FILTER_VSYNTH-$(call ALLYES, INTERLACE_FILTER FIELDORDER_FILTER) += 
fate-filter-fieldorder
-fate-filter-fieldorder: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf 
interlace=tff,fieldorder=bff
+fate-filter-fieldorder: CMD = framecrc -c:v pgmyuv -r 50 -i $(SRC) -vf 
interlace=tff,fieldorder=bff
 
 FATE_FILTER_VSYNTH-$(CONFIG_GRADFUN_FILTER) += fate-filter-gradfun
 fate-filter-gradfun: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf gradfun
diff --git a/tests/ref/fate/filter-fieldorder b/tests/ref/fate/filter-fieldorder
index 1504255..cc96fb8 100644
--- a/tests/ref/fate/filter-fieldorder
+++ b/tests/ref/fate/filter-fieldorder
@@ -1,26 +1,26 @@
-#tb 0: 2/25
-0,  0,  0,1,   202752, 0x136ad937
-0,  1,  1,1,   202752, 0xd8500359
-0,  2,  2,1,   202752, 0xe7784d3b
-0,  3,  3,1,   202752, 0x49b2f58e
-0,  4,  4,1,   202752, 0x12548c8e
-0,  5,  5,1,   202752, 0x244f500e
-0,  6,  6,1,   202752, 0x98c5506e
-0,  7,  7,1,   202752, 0xe7131398
-0,  8,  8,1,   202752, 0xc0e7c1ec
-0,  9,  9,1,   202752, 0x0113d766
-0, 10, 10,1,   202752, 0x8439cc42
-0, 11, 11,1,   202752, 0x8db397b9
-0, 12, 12,1,   202752, 0x7648eb88
-0, 13, 13,1,   202752, 0xe6a513b3
-0, 14, 14,1,   202752, 0x3c6f3b29
-0, 15, 15,1,   202752, 0x5e4f3ef1
-0, 16, 16,1,   202752, 0x261e0778
-0, 17, 17,1,   202752, 0xb2ce0274
-0, 18, 18,1,   202752, 0x849d7746
-0, 19, 19,1,   202752, 0xadf7b1b1
-0, 20, 20,1,   202752, 0xc4041125
-0, 21, 21,1,   202752, 0x78e4cce8
-0, 22, 22,1,   202752, 0x2f306542
-0, 23, 23,1,   202752, 0x4b4bebc6
-0, 24, 24,1,   202752, 0xb9bfbb17
+#tb 0: 1/25
+0,  0,  0,1,   202752, 0x6e2f1965
+0,  1,  1,1,   202752, 0x831c37c3
+0,  2,  2,1,   202752, 0x24d28d60
+0,  3,  3,1,   202752, 0xbd201a37
+0,  4,  4,1,   202752, 0xb414e380
+0,  5,  5,1,   202752, 0x8b338716
+0,  6,  6,1,   202752, 0xfc858f34
+0,  7,  7,1,   202752, 0xa3194864
+0,  8,  8,1,   202752, 0x59b80b56
+0,  9,  9,1,   202752, 0x6bba097c
+0, 10, 10,1,   202752, 0xa66a0778
+0, 11, 11,1,   202752, 0xbbadce1f
+0, 12, 12,1,   202752, 0xeb412ce4
+0, 13, 13,1,   202752, 0xafde5c2e
+0, 14, 14,1,   202752, 0x3044819b
+0, 15, 15,1,   202752, 0xe8f2818b
+0, 16, 16,1,   202752, 0x895118b6
+0, 17, 17,1,   202752, 0x1f0442da
+0, 18, 18,1,   202752, 0x8c65ba71
+0, 19, 19,1,   202752, 0x1daff7dc
+0, 20, 20,1,   202752, 0xaa194d03
+0, 21, 21,1,   202752, 0x14070d3b
+0, 22, 22,1,   202752, 0x3633af70
+0, 23, 23,1,   202752, 0xaaa128b3
+0, 24, 24,1,   202752, 0x3ae606c5
-- 
1.7.9.5

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Ronald S. Bultje
Hi,

On Tue, Oct 22, 2013 at 10:17 AM, Derek Buitenhuis <
derek.buitenh...@gmail.com> wrote:

> On 10/22/2013 3:08 PM, Ronald S. Bultje wrote:
> > And that supposedly-magic doesn't concern you?
>
> Definitely does.
>
> Guess the consensus is to fail immediately?


That sounds like an outstanding proposal.

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Luca Barbato
On 22/10/13 16:17, Derek Buitenhuis wrote:
> On 10/22/2013 3:08 PM, Ronald S. Bultje wrote:
>> And that supposedly-magic doesn't concern you?
> 
> Definitely does.
> 
> Guess the consensus is to fail immediately?
> 

I'd put some sanity in that file since we are spending time on it,
formatting patch and then some patches for it following soon (maybe a
day since I'm hitting jb head over a fun corner case caused by qsv)

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] h263: K&R formatting cosmetics

2013-10-22 Thread Luca Barbato
---

I'm counting on Vittorio reviewing and improving it =P

 libavcodec/h263dec.c | 647 ---
 1 file changed, 359 insertions(+), 288 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 8a021d1..59a7c24 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -42,59 +42,59 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 {
 MpegEncContext *s = avctx->priv_data;

-s->avctx = avctx;
+s->avctx  = avctx;
 s->out_format = FMT_H263;

-s->width  = avctx->coded_width;
-s->height = avctx->coded_height;
-s->workaround_bugs= avctx->workaround_bugs;
+s->width   = avctx->coded_width;
+s->height  = avctx->coded_height;
+s->workaround_bugs = avctx->workaround_bugs;

 // set defaults
 ff_MPV_decode_defaults(s);
-s->quant_precision=5;
-s->decode_mb= ff_h263_decode_mb;
-s->low_delay= 1;
+s->quant_precision = 5;
+s->decode_mb   = ff_h263_decode_mb;
+s->low_delay   = 1;
 if (avctx->codec->id == AV_CODEC_ID_MSS2)
 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 else
 avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
-s->unrestricted_mv= 1;
+s->unrestricted_mv = 1;

 /* select sub codec */
-switch(avctx->codec->id) {
+switch (avctx->codec->id) {
 case AV_CODEC_ID_H263:
-s->unrestricted_mv= 0;
+s->unrestricted_mv= 0;
 avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
 break;
 case AV_CODEC_ID_MPEG4:
 break;
 case AV_CODEC_ID_MSMPEG4V1:
-s->h263_pred = 1;
-s->msmpeg4_version=1;
+s->h263_pred   = 1;
+s->msmpeg4_version = 1;
 break;
 case AV_CODEC_ID_MSMPEG4V2:
-s->h263_pred = 1;
-s->msmpeg4_version=2;
+s->h263_pred   = 1;
+s->msmpeg4_version = 2;
 break;
 case AV_CODEC_ID_MSMPEG4V3:
-s->h263_pred = 1;
-s->msmpeg4_version=3;
+s->h263_pred   = 1;
+s->msmpeg4_version = 3;
 break;
 case AV_CODEC_ID_WMV1:
-s->h263_pred = 1;
-s->msmpeg4_version=4;
+s->h263_pred   = 1;
+s->msmpeg4_version = 4;
 break;
 case AV_CODEC_ID_WMV2:
-s->h263_pred = 1;
-s->msmpeg4_version=5;
+s->h263_pred   = 1;
+s->msmpeg4_version = 5;
 break;
 case AV_CODEC_ID_VC1:
 case AV_CODEC_ID_WMV3:
 case AV_CODEC_ID_VC1IMAGE:
 case AV_CODEC_ID_WMV3IMAGE:
 case AV_CODEC_ID_MSS2:
-s->h263_pred = 1;
-s->msmpeg4_version=6;
+s->h263_pred  = 1;
+s->msmpeg4_version= 6;
 avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
 break;
 case AV_CODEC_ID_H263I:
@@ -105,15 +105,16 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 default:
 return -1;
 }
-s->codec_id= avctx->codec->id;
-avctx->hwaccel= ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
+s->codec_id= avctx->codec->id;
+avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);

 /* for h263, we allocate the images after having read the header */
-if (avctx->codec->id != AV_CODEC_ID_H263 && avctx->codec->id != 
AV_CODEC_ID_MPEG4)
+if (avctx->codec->id != AV_CODEC_ID_H263 && avctx->codec->id !=
+AV_CODEC_ID_MPEG4)
 if (ff_MPV_common_init(s) < 0)
 return -1;

-ff_h263_decode_init_vlc();
+ff_h263_decode_init_vlc();

 return 0;
 }
@@ -129,232 +130,267 @@ av_cold int ff_h263_decode_end(AVCodecContext *avctx)
 /**
  * Return the number of bytes consumed for building the current frame.
  */
-static int get_consumed_bytes(MpegEncContext *s, int buf_size){
-int pos= (get_bits_count(&s->gb)+7)>>3;
+static int get_consumed_bytes(MpegEncContext *s, int buf_size)
+{
+int pos = (get_bits_count(&s->gb) + 7) >> 3;

-if(s->divx_packed || s->avctx->hwaccel){
-//we would have to scan through the whole buf to handle the weird 
reordering ...
+if (s->divx_packed || s->avctx->hwaccel) {
+/* We would have to scan through the whole buf to handle the weird
+   reordering ... */
 return buf_size;
-}else if(s->flags&CODEC_FLAG_TRUNCATED){
+} else if (s->flags & CODEC_FLAG_TRUNCATED) {
 pos -= s->parse_context.last_index;
-if(pos<0) pos=0; // padding is not really read so this might be -1
+if (pos < 0)
+pos = 0; // padding is not really read so this might be -1
 return pos;
-}else{
-if(pos==0) pos=1; //avoid infinite loops (i doubt that is needed but 
...)
-if(pos+10>buf_size) pos=buf_size; // oops ;)
+} else {
+if (pos == 0)
+pos = 1;  //avoid infinite loops (i doubt that is needed but 
...)
+if (pos + 10 > buf_size)
+pos = buf_size;  

Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Derek Buitenhuis
On 10/22/2013 3:08 PM, Ronald S. Bultje wrote:
> And that supposedly-magic doesn't concern you?

Definitely does.

Guess the consensus is to fail immediately?

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Ronald S. Bultje
Hi,

On Tue, Oct 22, 2013 at 10:06 AM, Derek Buitenhuis <
derek.buitenh...@gmail.com> wrote:

> On 10/22/2013 2:47 PM, Ronald S. Bultje wrote:
> > Right. So the thinking might be, should we perhaps take action based on
> > this hypothetical error-like value of ret, such as perhaps aborting
> > decoding the rest of the frame, and instead returning an error?
>
> I have a sample that actually triggers this error case, and it seems
> to abort fine... I don't know *where* it catches it in this mess of
> MPEG code though...


And that supposedly-magic doesn't concern you?

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Derek Buitenhuis
On 10/22/2013 2:47 PM, Ronald S. Bultje wrote:
> Right. So the thinking might be, should we perhaps take action based on
> this hypothetical error-like value of ret, such as perhaps aborting
> decoding the rest of the frame, and instead returning an error?

I have a sample that actually triggers this error case, and it seems
to abort fine... I don't know *where* it catches it in this mess of
MPEG code though...

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Ronald S. Bultje
Hi,

On Tue, Oct 22, 2013 at 9:29 AM, Derek Buitenhuis <
derek.buitenh...@gmail.com> wrote:

> On 10/22/2013 2:15 PM, Ronald S. Bultje wrote:
> > if ((ret = init_get_bits8(...)) >= 0)
> > ret = ff_mpeg4_decode_...(..);
>
> Currently this accomplishes nothing, since ret is immediately written
> over underneath it.


Right. So the thinking might be, should we perhaps take action based on
this hypothetical error-like value of ret, such as perhaps aborting
decoding the rest of the frame, and instead returning an error?

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 01/11] movenc: Add an F4V muxer

2013-10-22 Thread Martin Storsjö

On Tue, 22 Oct 2013, Luca Barbato wrote:


On 22/10/13 15:16, Martin Storsjö wrote:

On Tue, 22 Oct 2013, Luca Barbato wrote:


On 09/10/13 14:03, Martin Storsjö wrote:

+else if (track->enc->codec_id == AV_CODEC_ID_VP6F ||
+ track->enc->codec_id == AV_CODEC_ID_VP6A) {
+/* Don't write any potential extradata here - the cropping
+ * is signalled via the normal width/height fields. */
+} else if (track->vos_len > 0)
 mov_write_glbl_tag(pb, track);


Not sure if having the condition merged below is nicer, beside that
doesn't look wrong.


No you can't move it below the existing one, since track->vos_len > 0
can be true for VP6 as well, but we intentionally should not write it to
the file. The track->vos_len > 0 case is a catch-all case for writing
"generic" extradata for codecs that don't need any special handling.

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


I meant if (track->vos_tag > 0 && codec_id != AV_CODEC_ID_VP6F)

as said not sure which is the nicer.


Ah, I see. I think I prefer the current one though, which is clearer if 
there's many different similar cases (although not sure if there will be 
many others).


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 01/11] movenc: Add an F4V muxer

2013-10-22 Thread Luca Barbato
On 22/10/13 15:16, Martin Storsjö wrote:
> On Tue, 22 Oct 2013, Luca Barbato wrote:
> 
>> On 09/10/13 14:03, Martin Storsjö wrote:
>>> +else if (track->enc->codec_id == AV_CODEC_ID_VP6F ||
>>> + track->enc->codec_id == AV_CODEC_ID_VP6A) {
>>> +/* Don't write any potential extradata here - the cropping
>>> + * is signalled via the normal width/height fields. */
>>> +} else if (track->vos_len > 0)
>>>  mov_write_glbl_tag(pb, track);
>>
>> Not sure if having the condition merged below is nicer, beside that
>> doesn't look wrong.
> 
> No you can't move it below the existing one, since track->vos_len > 0
> can be true for VP6 as well, but we intentionally should not write it to
> the file. The track->vos_len > 0 case is a catch-all case for writing
> "generic" extradata for codecs that don't need any special handling.
> 
> // Martin
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel

I meant if (track->vos_tag > 0 && codec_id != AV_CODEC_ID_VP6F)

as said not sure which is the nicer.

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Derek Buitenhuis
On 10/22/2013 2:15 PM, Ronald S. Bultje wrote:
> if ((ret = init_get_bits8(...)) >= 0)
> ret = ff_mpeg4_decode_...(..);

Currently this accomplishes nothing, since ret is immediately written
over underneath it.

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 01/11] movenc: Add an F4V muxer

2013-10-22 Thread Martin Storsjö

On Tue, 22 Oct 2013, Luca Barbato wrote:


On 09/10/13 14:03, Martin Storsjö wrote:

+else if (track->enc->codec_id == AV_CODEC_ID_VP6F ||
+ track->enc->codec_id == AV_CODEC_ID_VP6A) {
+/* Don't write any potential extradata here - the cropping
+ * is signalled via the normal width/height fields. */
+} else if (track->vos_len > 0)
 mov_write_glbl_tag(pb, track);


Not sure if having the condition merged below is nicer, beside that
doesn't look wrong.


No you can't move it below the existing one, since track->vos_len > 0 can 
be true for VP6 as well, but we intentionally should not write it to the 
file. The track->vos_len > 0 case is a catch-all case for writing 
"generic" extradata for codecs that don't need any special handling.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Ronald S. Bultje
Hi,

On Tue, Oct 22, 2013 at 7:19 AM, Derek Buitenhuis <
derek.buitenh...@gmail.com> wrote:

> On 10/22/2013 12:09 PM, Luca Barbato wrote:
> >> -init_get_bits(&gb, s->avctx->extradata,
> s->avctx->extradata_size*8);
> >> -ret = ff_mpeg4_decode_picture_header(s, &gb);
> >> +if (init_get_bits8(&gb, s->avctx->extradata,
> s->avctx->extradata_size) >= 0 )
> >> +ret = ff_mpeg4_decode_picture_header(s, &gb);
> >
> > This looks wrong.
>
> Care to elaborate?


if ((ret = init_get_bits8(...)) >= 0)
ret = ff_mpeg4_decode_...(..);

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 01/11] movenc: Add an F4V muxer

2013-10-22 Thread Luca Barbato
On 09/10/13 14:03, Martin Storsjö wrote:
> +else if (track->enc->codec_id == AV_CODEC_ID_VP6F ||
> + track->enc->codec_id == AV_CODEC_ID_VP6A) {
> +/* Don't write any potential extradata here - the cropping
> + * is signalled via the normal width/height fields. */
> +} else if (track->vos_len > 0)
>  mov_write_glbl_tag(pb, track);

Not sure if having the condition merged below is nicer, beside that
doesn't look wrong.

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH v2-for-real-this-time] pthread: Avoid crashes/odd behavior caused by spurious wakeups

2013-10-22 Thread Luca Barbato
On 22/10/13 14:25, Derek Buitenhuis wrote:
> This is similar to 5152196b2b47d446d9a509b9bfb318daa26a1f2b.
> 
> Signed-off-by: Derek Buitenhuis 
> ---
>  libavfilter/pthread.c | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 

s/unsigned int/unsigned/ maybe, the rest still looks ok.

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2] lavfi/pthread: Avoid crashes/odd behavior caused by spurious wakeups

2013-10-22 Thread Luca Barbato
On 22/10/13 14:22, Derek Buitenhuis wrote:
> On 10/22/2013 1:15 PM, Luca Barbato wrote:
>> I guess it is good to go.
> 
> Er nope. I accidentally sent the wrong patch. This does not even compile.
> 

Send over the one supposed to work and let's have a better look then.

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 01/11] movenc: Add an F4V muxer

2013-10-22 Thread Martin Storsjö

On Wed, 9 Oct 2013, Martin Storsjö wrote:


From: Clément Bœsch 

F4V is Adobe's mp4/iso media variant, with the most significant
addition/change being supporting other flash codecs than just
aac/h264.
---
Changelog|1 +
configure|1 +
libavformat/allformats.c |1 +
libavformat/movenc.c |   38 +-
libavformat/movenc.h |1 +
libavformat/version.h|4 ++--
6 files changed, 43 insertions(+), 3 deletions(-)


OK'd by Luca on irc.

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Derek Buitenhuis
On 10/22/2013 1:34 PM, Derek Buitenhuis wrote:
> On 10/22/2013 1:14 PM, Luca Barbato wrote:
>> init_get_bits8 fails
>>
>> ret stays 0
> 
> Ret gets set whatever the call under it returns.
> 
> It seems to fix my crashing sample here, and it's not obvious
> this is the wrong behavior to me...

I should clarify, init_get_bits8 fails here on my sample.

- Derel


___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Derek Buitenhuis
On 10/22/2013 1:14 PM, Luca Barbato wrote:
> init_get_bits8 fails
> 
> ret stays 0

Ret gets set whatever the call under it returns.

It seems to fix my crashing sample here, and it's not obvious
this is the wrong behavior to me...

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH v2-for-real-this-time] pthread: Avoid crashes/odd behavior caused by spurious wakeups

2013-10-22 Thread Derek Buitenhuis
This is similar to 5152196b2b47d446d9a509b9bfb318daa26a1f2b.

Signed-off-by: Derek Buitenhuis 
---
 libavfilter/pthread.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavfilter/pthread.c b/libavfilter/pthread.c
index 17e8e7b..dd3b174 100644
--- a/libavfilter/pthread.c
+++ b/libavfilter/pthread.c
@@ -56,6 +56,7 @@ typedef struct ThreadContext {
 pthread_cond_t current_job_cond;
 pthread_mutex_t current_job_lock;
 int current_job;
+unsigned int current_execute;
 int done;
 } ThreadContext;
 
@@ -64,6 +65,7 @@ static void* attribute_align_arg worker(void *v)
 ThreadContext *c = v;
 int our_job  = c->nb_jobs;
 int nb_threads   = c->nb_threads;
+unsigned int last_execute = 0;
 int self_id;
 
 pthread_mutex_lock(&c->current_job_lock);
@@ -73,8 +75,9 @@ static void* attribute_align_arg worker(void *v)
 if (c->current_job == nb_threads + c->nb_jobs)
 pthread_cond_signal(&c->last_job_cond);
 
-if (!c->done)
+while (last_execute == c->current_execute && !c->done)
 pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
+last_execute = c->current_execute;
 our_job = self_id;
 
 if (c->done) {
@@ -111,7 +114,8 @@ static void slice_thread_uninit(ThreadContext *c)
 
 static void slice_thread_park_workers(ThreadContext *c)
 {
-pthread_cond_wait(&c->last_job_cond, &c->current_job_lock);
+while (c->current_job != c->nb_threads + c->nb_jobs)
+pthread_cond_wait(&c->last_job_cond, &c->current_job_lock);
 pthread_mutex_unlock(&c->current_job_lock);
 }
 
@@ -138,6 +142,8 @@ static int thread_execute(AVFilterContext *ctx, 
avfilter_action_func *func,
 c->rets= &dummy_ret;
 c->nb_rets = 1;
 }
+c->current_execute++;
+
 pthread_cond_broadcast(&c->current_job_cond);
 
 slice_thread_park_workers(c);
-- 
1.8.4.rc3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2] lavfi/pthread: Avoid crashes/odd behavior caused by spurious wakeups

2013-10-22 Thread Derek Buitenhuis
On 10/22/2013 1:15 PM, Luca Barbato wrote:
> I guess it is good to go.

Er nope. I accidentally sent the wrong patch. This does not even compile.

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Luca Barbato
On 22/10/13 13:19, Derek Buitenhuis wrote:
> On 10/22/2013 12:09 PM, Luca Barbato wrote:
>>> -init_get_bits(&gb, s->avctx->extradata, 
>>> s->avctx->extradata_size*8);
>>> -ret = ff_mpeg4_decode_picture_header(s, &gb);
>>> +if (init_get_bits8(&gb, s->avctx->extradata, 
>>> s->avctx->extradata_size) >= 0 )
>>> +ret = ff_mpeg4_decode_picture_header(s, &gb);
>>
>> This looks wrong.
> 
> Care to elaborate?

init_get_bits8 fails

ret stays 0

> You perhaps prefer an explicit error path?

Might be a good idea.

lu



___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2] lavfi/pthread: Avoid crashes/odd behavior caused by spurious wakeups

2013-10-22 Thread Luca Barbato
On 22/10/13 12:50, Derek Buitenhuis wrote:
> This is similar to 5152196b2b47d446d9a509b9bfb318daa26a1f2b.
> 
> Signed-off-by: Derek Buitenhuis 
> ---
>  libavfilter/pthread.c | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 

I guess it is good to go.

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Derek Buitenhuis
On 10/22/2013 12:09 PM, Luca Barbato wrote:
>> -init_get_bits(&gb, s->avctx->extradata, 
>> s->avctx->extradata_size*8);
>> -ret = ff_mpeg4_decode_picture_header(s, &gb);
>> +if (init_get_bits8(&gb, s->avctx->extradata, 
>> s->avctx->extradata_size) >= 0 )
>> +ret = ff_mpeg4_decode_picture_header(s, &gb);
> 
> This looks wrong.

Care to elaborate?

You perhaps prefer an explicit error path?

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2] lavfi/pthread: Avoid crashes/odd behavior caused by spurious wakeups

2013-10-22 Thread Derek Buitenhuis
On 10/22/2013 12:10 PM, Luca Barbato wrote:
> unsigned and while at it "pthread: .."

Changed locally.

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/3] aac: Add support for Enhanced AAC Low Delay (ER AAC ELD).

2013-10-22 Thread Derek Buitenhuis
> This does not include support for LD SBR, epTool, data resilience, nor
> the 960 transform family.
> ---
>  Changelog|   1 +
>  libavcodec/aac.h |   2 +-
>  libavcodec/aacdec.c  | 207 ++
>  libavcodec/aactab.c  | 483 
> +++
>  libavcodec/aactab.h  |   1 +
>  libavcodec/version.h |   2 +-
>  6 files changed, 661 insertions(+), 35 deletions(-)

[...]

> +int aot = ac->oc[1].m4ac.object_type;
> +if (aot != AOT_ER_AAC_ELD) {
> +if (get_bits1(gb)) {
> +av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
> +return AVERROR_INVALIDDATA;
> +}

Unrelated to patch: Should this not be a warning in non-explode mode?


> +if (aot == AOT_AAC_MAIN) {
>  if (decode_prediction(ac, ics, gb)) {
>  return AVERROR_INVALIDDATA;
>  }

Unrelated to patch: No av_log?

Cosmetics aside, patch seem reasonable, though I am not
AAC expert.

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] golomb: K&R formatting cosmetics

2013-10-22 Thread Luca Barbato
On 22/10/13 13:12, Vittorio Giovara wrote:
>  extern const uint8_t ff_golomb_vlc_len[512];
>  extern const uint8_t ff_ue_golomb_vlc_code[512];
> -extern const  int8_t ff_se_golomb_vlc_code[512];
> +extern const int8_t ff_se_golomb_vlc_code[512];
>  extern const uint8_t ff_ue_golomb_len[256];
>  
>  extern const uint8_t ff_interleaved_golomb_vlc_len[256];
>  extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256];
> -extern const  int8_t ff_interleaved_se_golomb_vlc_code[256];
> +extern const int8_t ff_interleaved_se_golomb_vlc_code[256];
>  extern const uint8_t ff_interleaved_dirac_golomb_vlc_code[256];
>  

No, it looks worse.

The rest doesn't look bad.

Thank you.

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] golomb: K&R formatting cosmetics

2013-10-22 Thread Vittorio Giovara
---
 libavcodec/golomb.h |  298 ---
 1 file changed, 161 insertions(+), 137 deletions(-)

diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index 564ba4e..52959d0 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -38,35 +38,34 @@
 
 extern const uint8_t ff_golomb_vlc_len[512];
 extern const uint8_t ff_ue_golomb_vlc_code[512];
-extern const  int8_t ff_se_golomb_vlc_code[512];
+extern const int8_t ff_se_golomb_vlc_code[512];
 extern const uint8_t ff_ue_golomb_len[256];
 
 extern const uint8_t ff_interleaved_golomb_vlc_len[256];
 extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256];
-extern const  int8_t ff_interleaved_se_golomb_vlc_code[256];
+extern const int8_t ff_interleaved_se_golomb_vlc_code[256];
 extern const uint8_t ff_interleaved_dirac_golomb_vlc_code[256];
 
-
- /**
+/**
  * read unsigned exp golomb code.
  */
-static inline int get_ue_golomb(GetBitContext *gb){
+static inline int get_ue_golomb(GetBitContext *gb)
+{
 unsigned int buf;
-int log;
 
 OPEN_READER(re, gb);
 UPDATE_CACHE(re, gb);
-buf=GET_CACHE(re, gb);
+buf = GET_CACHE(re, gb);
 
-if(buf >= (1<<27)){
+if (buf >= (1 << 27)) {
 buf >>= 32 - 9;
 LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
 CLOSE_READER(re, gb);
 
 return ff_ue_golomb_vlc_code[buf];
-}else{
-log= 2*av_log2(buf) - 31;
-buf>>= log;
+} else {
+int log = 2 * av_log2(buf) - 31;
+buf >>= log;
 buf--;
 LAST_SKIP_BITS(re, gb, 32 - log);
 CLOSE_READER(re, gb);
@@ -89,16 +88,17 @@ static inline unsigned get_ue_golomb_long(GetBitContext *gb)
 return get_bits_long(gb, log + 1) - 1;
 }
 
- /**
+/**
  * read unsigned exp golomb code, constraint to a max of 31.
  * the return value is undefined if the stored value exceeds 31.
  */
-static inline int get_ue_golomb_31(GetBitContext *gb){
+static inline int get_ue_golomb_31(GetBitContext *gb)
+{
 unsigned int buf;
 
 OPEN_READER(re, gb);
 UPDATE_CACHE(re, gb);
-buf=GET_CACHE(re, gb);
+buf = GET_CACHE(re, gb);
 
 buf >>= 32 - 9;
 LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
@@ -113,24 +113,24 @@ static inline unsigned svq3_get_ue_golomb(GetBitContext 
*gb)
 
 OPEN_READER(re, gb);
 UPDATE_CACHE(re, gb);
-buf=GET_CACHE(re, gb);
+buf = GET_CACHE(re, gb);
 
-if(buf&0xAA80){
+if (buf & 0xAA80) {
 buf >>= 32 - 8;
 LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
 CLOSE_READER(re, gb);
 
 return ff_interleaved_ue_golomb_vlc_code[buf];
-}else{
+} else {
 unsigned ret = 1;
 
 do {
 buf >>= 32 - 8;
 LAST_SKIP_BITS(re, gb, FFMIN(ff_interleaved_golomb_vlc_len[buf], 
8));
 
-if (ff_interleaved_golomb_vlc_len[buf] != 9){
+if (ff_interleaved_golomb_vlc_len[buf] != 9) {
 ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
-ret |= ff_interleaved_dirac_golomb_vlc_code[buf];
+ret  |= ff_interleaved_dirac_golomb_vlc_code[buf];
 break;
 }
 ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
@@ -146,90 +146,99 @@ static inline unsigned svq3_get_ue_golomb(GetBitContext 
*gb)
 /**
  * read unsigned truncated exp golomb code.
  */
-static inline int get_te0_golomb(GetBitContext *gb, int range){
+static inline int get_te0_golomb(GetBitContext *gb, int range)
+{
 assert(range >= 1);
 
-if(range==1)  return 0;
-else if(range==2) return get_bits1(gb)^1;
-else  return get_ue_golomb(gb);
+if (range == 1)
+return 0;
+else if (range == 2)
+return get_bits1(gb) ^ 1;
+else
+return get_ue_golomb(gb);
 }
 
 /**
  * read unsigned truncated exp golomb code.
  */
-static inline int get_te_golomb(GetBitContext *gb, int range){
+static inline int get_te_golomb(GetBitContext *gb, int range)
+{
 assert(range >= 1);
 
-if(range==2) return get_bits1(gb)^1;
-else return get_ue_golomb(gb);
+if (range == 2)
+return get_bits1(gb) ^ 1;
+else
+return get_ue_golomb(gb);
 }
 
-
 /**
  * read signed exp golomb code.
  */
-static inline int get_se_golomb(GetBitContext *gb){
+static inline int get_se_golomb(GetBitContext *gb)
+{
 unsigned int buf;
-int log;
 
 OPEN_READER(re, gb);
 UPDATE_CACHE(re, gb);
-buf=GET_CACHE(re, gb);
+buf = GET_CACHE(re, gb);
 
-if(buf >= (1<<27)){
+if (buf >= (1 << 27)) {
 buf >>= 32 - 9;
 LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
 CLOSE_READER(re, gb);
 
 return ff_se_golomb_vlc_code[buf];
-}else{
-log= 2*av_log2(buf) - 31;
-buf>>= log;
+} else {
+int log = 2 * av_log2(buf) - 31;
+buf >>= log;
 
 LAST_SKIP_BITS(re, gb, 32 - log);
 CLOSE_READER(re, gb);
 
-   

Re: [libav-devel] [PATCH v2] lavfi/pthread: Avoid crashes/odd behavior caused by spurious wakeups

2013-10-22 Thread Luca Barbato
On 22/10/13 12:50, Derek Buitenhuis wrote:
> +int last_execute = 0;

unsigned and while at it "pthread: .."

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Luca Barbato
On 22/10/13 12:20, Derek Buitenhuis wrote:
> From: Michael Niedermayer 
> 
> Fixes null pointer dereference
> 
> Signed-off-by: Michael Niedermayer 
> Signed-off-by: Derek Buitenhuis 
> ---
> This is supposedly the correct way to fix this.
> ---
>  libavcodec/h263dec.c |   10 ++
>  1 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
> index 8a021d1..f425182 100644
> --- a/libavcodec/h263dec.c
> +++ b/libavcodec/h263dec.c
> @@ -380,10 +380,12 @@ int ff_h263_decode_frame(AVCodecContext *avctx,
>  
>  
>  if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){ //divx 
> 5.01+/xvid frame reorder
> -init_get_bits(&s->gb, s->bitstream_buffer, 
> s->bitstream_buffer_size*8);
> +ret = init_get_bits8(&s->gb, s->bitstream_buffer, 
> s->bitstream_buffer_size);
>  }else
> -init_get_bits(&s->gb, buf, buf_size*8);
> +ret = init_get_bits8(&s->gb, buf, buf_size);
>  s->bitstream_buffer_size=0;
> +if (ret < 0)
> +return ret;

Sounds fine, the first change might be unnecessary but better safe than
sorry.

CC: libav-sta...@libav.org

>  if (!s->context_initialized) {
>  if (ff_MPV_common_init(s) < 0) //we need the idct permutaton for 
> reading a custom matrix
> @@ -408,8 +410,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx,
>  if(s->avctx->extradata_size && s->picture_number==0){
>  GetBitContext gb;
>  
> -init_get_bits(&gb, s->avctx->extradata, 
> s->avctx->extradata_size*8);
> -ret = ff_mpeg4_decode_picture_header(s, &gb);
> +if (init_get_bits8(&gb, s->avctx->extradata, 
> s->avctx->extradata_size) >= 0 )
> +ret = ff_mpeg4_decode_picture_header(s, &gb);

This looks wrong.

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/3] fate: aac: Add test for AAC-ELD

2013-10-22 Thread Derek Buitenhuis
On 10/22/2013 12:04 PM, Alex Converse wrote:
> ---
>  tests/fate/aac.mak | 4 
>  1 file changed, 4 insertions(+)

OK.

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/3] aacdec: Use avpriv_report_missing_feature() instead of custom logging.

2013-10-22 Thread Derek Buitenhuis
On 10/22/2013 12:04 PM, Alex Converse wrote:
> ---
>  libavcodec/aacdec.c | 19 +--
>  1 file changed, 9 insertions(+), 10 deletions(-)

OK.

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/3] aac: Add support for Enhanced AAC Low Delay (ER AAC ELD).

2013-10-22 Thread Alex Converse
This does not include support for LD SBR, epTool, data resilience, nor
the 960 transform family.
---
 Changelog|   1 +
 libavcodec/aac.h |   2 +-
 libavcodec/aacdec.c  | 207 ++
 libavcodec/aactab.c  | 483 +++
 libavcodec/aactab.h  |   1 +
 libavcodec/version.h |   2 +-
 6 files changed, 661 insertions(+), 35 deletions(-)

diff --git a/Changelog b/Changelog
index 657e68c..fd12d90 100644
--- a/Changelog
+++ b/Changelog
@@ -38,6 +38,7 @@ version 10:
 - Low Delay AAC (ER AAC LD) decoding
 - mux chapters in ASF files
 - Opus in Ogg demuxing
+- Enhanced Low Delay AAC (ER AAC ELD) decoding (no LD SBR support)
 
 
 version 9:
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index 40e8dfb..375e6b1 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -234,7 +234,7 @@ typedef struct SingleChannelElement {
 int sf_idx[128];///< scalefactor indices 
(used by encoder)
 uint8_t zeroes[128];///< band is not coded 
(used by encoder)
 DECLARE_ALIGNED(32, float,   coeffs)[1024]; ///< coefficients for IMDCT
-DECLARE_ALIGNED(32, float,   saved)[1024];  ///< overlap
+DECLARE_ALIGNED(32, float,   saved)[1536];  ///< overlap
 DECLARE_ALIGNED(32, float,   ret_buf)[2048];///< PCM output buffer
 DECLARE_ALIGNED(16, float,   ltp_state)[3072];  ///< time signal for LTP
 PredictorState predictor_state[MAX_PREDICTORS];
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 435caab..9cc8149 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -2,6 +2,7 @@
  * AAC decoder
  * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
  * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
+ * Copyright (c) 2008-2013 Alex Converse 
  *
  * AAC LATM decoder
  * Copyright (c) 2008-2010 Paul Kendall 
@@ -778,6 +779,67 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 return 0;
 }
 
+static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx,
+ GetBitContext *gb,
+ MPEG4AudioConfig *m4ac,
+ int channel_config)
+{
+int ret, ep_config, res_flags;
+uint8_t layout_map[MAX_ELEM_ID*4][3];
+int tags = 0;
+const int ELDEXT_TERM = 0;
+
+m4ac->ps  = 0;
+m4ac->sbr = 0;
+
+if (get_bits1(gb)) { // frameLengthFlag
+avpriv_request_sample(avctx, "960/120 MDCT window");
+return AVERROR_PATCHWELCOME;
+}
+
+res_flags = get_bits(gb, 3);
+if (res_flags) {
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "AAC data resilience (flags %x)",
+  res_flags);
+return AVERROR_PATCHWELCOME;
+}
+
+if (get_bits1(gb)) { // ldSbrPresentFlag
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "Low Delay SBR");
+return AVERROR_PATCHWELCOME;
+}
+
+while (get_bits(gb, 4) != ELDEXT_TERM) {
+int len = get_bits(gb, 4);
+if (len == 15)
+len += get_bits(gb, 8);
+if (len == 15 + 255)
+len += get_bits(gb, 16);
+if (get_bits_left(gb) < len * 8 + 4) {
+av_log(ac->avctx, AV_LOG_ERROR, overread_err);
+return AVERROR_INVALIDDATA;
+}
+skip_bits_long(gb, 8 * len);
+}
+
+if ((ret = set_default_channel_config(avctx, layout_map,
+  &tags, channel_config)))
+return ret;
+
+if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0)))
+return ret;
+
+ep_config = get_bits(gb, 2);
+if (ep_config) {
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "epConfig %d", ep_config);
+return AVERROR_PATCHWELCOME;
+}
+return 0;
+}
+
 /**
  * Decode audio specific configuration; reference: table 1.13.
  *
@@ -836,6 +898,11 @@ static int decode_audio_specific_config(AACContext *ac,
 m4ac, m4ac->chan_config)) < 0)
 return ret;
 break;
+case AOT_ER_AAC_ELD:
+if ((ret = decode_eld_specific_config(ac, avctx, &gb,
+  m4ac, m4ac->chan_config)) < 0)
+return ret;
+break;
 default:
 avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
   "Audio object type %s%d",
@@ -1067,22 +1134,25 @@ static void decode_ltp(LongTermPrediction *ltp,
 static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
GetBitContext *gb)
 {
-if (get_bits1(gb)) {
-av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
-return AVERROR_INVALIDDATA;
-}
-ics

[libav-devel] [PATCH 1/3] aacdec: Use avpriv_report_missing_feature() instead of custom logging.

2013-10-22 Thread Alex Converse
---
 libavcodec/aacdec.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 824839a..435caab 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -754,9 +754,9 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 case AOT_ER_AAC_LD:
 res_flags = get_bits(gb, 3);
 if (res_flags) {
-av_log(avctx, AV_LOG_ERROR,
-   "AAC data resilience not supported (flags %x)\n",
-   res_flags);
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "AAC data resilience (flags %x)",
+  res_flags);
 return AVERROR_PATCHWELCOME;
 }
 break;
@@ -770,9 +770,8 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 case AOT_ER_AAC_LD:
 ep_config = get_bits(gb, 2);
 if (ep_config) {
-av_log(avctx, AV_LOG_ERROR,
-   "epConfig %d is not supported.\n",
-   ep_config);
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "epConfig %d", ep_config);
 return AVERROR_PATCHWELCOME;
 }
 }
@@ -838,10 +837,10 @@ static int decode_audio_specific_config(AACContext *ac,
 return ret;
 break;
 default:
-av_log(avctx, AV_LOG_ERROR,
-   "Audio object type %s%d is not supported.\n",
-   m4ac->sbr == 1 ? "SBR+" : "",
-   m4ac->object_type);
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "Audio object type %s%d",
+  m4ac->sbr == 1 ? "SBR+" : "",
+  m4ac->object_type);
 return AVERROR(ENOSYS);
 }
 
-- 
1.8.3.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 3/3] fate: aac: Add test for AAC-ELD

2013-10-22 Thread Alex Converse
---
 tests/fate/aac.mak | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index 4a939dc..375b7f9 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -54,6 +54,10 @@ FATE_AAC += fate-aac-er_ad6000np_44_ep0
 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4
 fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44_ep0.s16
 
+FATE_AAC += fate-aac-er_eld2000np_48_ep0
+fate-aac-er_ad6000np_44_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_eld2000np_48_ep0.mp4
+fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_eld2000np_48_ep0.s16
+
 
 fate-aac-ct%: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/CT_DecoderCheck/$(@:fate-aac-ct-%=%)
 fate-aac-ct%: REF = $(SAMPLES)/aac/CT_DecoderCheck/aacPlusv2.wav
-- 
1.8.3.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH v2] lavfi/pthread: Avoid crashes/odd behavior caused by spurious wakeups

2013-10-22 Thread Derek Buitenhuis
This is similar to 5152196b2b47d446d9a509b9bfb318daa26a1f2b.

Signed-off-by: Derek Buitenhuis 
---
 libavfilter/pthread.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavfilter/pthread.c b/libavfilter/pthread.c
index 17e8e7b..4aa50d6 100644
--- a/libavfilter/pthread.c
+++ b/libavfilter/pthread.c
@@ -56,6 +56,7 @@ typedef struct ThreadContext {
 pthread_cond_t current_job_cond;
 pthread_mutex_t current_job_lock;
 int current_job;
+unsigned int current_execute;
 int done;
 } ThreadContext;
 
@@ -64,6 +65,7 @@ static void* attribute_align_arg worker(void *v)
 ThreadContext *c = v;
 int our_job  = c->nb_jobs;
 int nb_threads   = c->nb_threads;
+int last_execute = 0;
 int self_id;
 
 pthread_mutex_lock(&c->current_job_lock);
@@ -73,8 +75,9 @@ static void* attribute_align_arg worker(void *v)
 if (c->current_job == nb_threads + c->nb_jobs)
 pthread_cond_signal(&c->last_job_cond);
 
-if (!c->done)
+while (last_execute == c->current_execute && !c->done)
 pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
+last_execute = c->current_execute;
 our_job = self_id;
 
 if (c->done) {
@@ -111,7 +114,8 @@ static void slice_thread_uninit(ThreadContext *c)
 
 static void slice_thread_park_workers(ThreadContext *c)
 {
-pthread_cond_wait(&c->last_job_cond, &c->current_job_lock);
+while (c->current_job != thread_count + c->job_count)
+pthread_cond_wait(&c->last_job_cond, &c->current_job_lock);
 pthread_mutex_unlock(&c->current_job_lock);
 }
 
@@ -138,6 +142,8 @@ static int thread_execute(AVFilterContext *ctx, 
avfilter_action_func *func,
 c->rets= &dummy_ret;
 c->nb_rets = 1;
 }
+c->current_execute++;
+
 pthread_cond_broadcast(&c->current_job_cond);
 
 slice_thread_park_workers(c);
-- 
1.8.4.rc3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] h263dec: use init_get_bits8() and check its return code

2013-10-22 Thread Derek Buitenhuis
From: Michael Niedermayer 

Fixes null pointer dereference

Signed-off-by: Michael Niedermayer 
Signed-off-by: Derek Buitenhuis 
---
This is supposedly the correct way to fix this.
---
 libavcodec/h263dec.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 8a021d1..f425182 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -380,10 +380,12 @@ int ff_h263_decode_frame(AVCodecContext *avctx,
 
 
 if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){ //divx 
5.01+/xvid frame reorder
-init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);
+ret = init_get_bits8(&s->gb, s->bitstream_buffer, 
s->bitstream_buffer_size);
 }else
-init_get_bits(&s->gb, buf, buf_size*8);
+ret = init_get_bits8(&s->gb, buf, buf_size);
 s->bitstream_buffer_size=0;
+if (ret < 0)
+return ret;
 
 if (!s->context_initialized) {
 if (ff_MPV_common_init(s) < 0) //we need the idct permutaton for 
reading a custom matrix
@@ -408,8 +410,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx,
 if(s->avctx->extradata_size && s->picture_number==0){
 GetBitContext gb;
 
-init_get_bits(&gb, s->avctx->extradata, 
s->avctx->extradata_size*8);
-ret = ff_mpeg4_decode_picture_header(s, &gb);
+if (init_get_bits8(&gb, s->avctx->extradata, 
s->avctx->extradata_size) >= 0 )
+ret = ff_mpeg4_decode_picture_header(s, &gb);
 }
 ret = ff_mpeg4_decode_picture_header(s, &s->gb);
 } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
-- 
1.7.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avcodec/h264_parser: fix order of operations

2013-10-22 Thread Vittorio Giovara
On Sun, Oct 20, 2013 at 3:39 PM, Luca Barbato  wrote:
> On 20/10/13 15:11, Yusuke Nakamura wrote:
>> From: Michael Niedermayer 
>>
>> Signed-off-by: Michael Niedermayer 
>> ---
>>  libavcodec/h264_parser.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)

Yup, looks ok and the commit message could be simplified to
"h264_parser: fix order of operations"
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] ffv1: Remove asserts

2013-10-22 Thread Vittorio Giovara
On Sun, Oct 20, 2013 at 7:20 PM, Luca Barbato  wrote:
> They seem all reachable from bogus input.
> ---
>  libavcodec/ffv1dec.c | 83 
> 
>  1 file changed, 52 insertions(+), 31 deletions(-)

Looks ok and fate is happy.
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avplay: Accept cpuflags option

2013-10-22 Thread Vittorio Giovara
On Mon, Oct 21, 2013 at 5:05 PM, Luca Barbato  wrote:
> Quite useful for debugging.
>
> Signed-off-by: Luca Barbato 
> ---
>
> Now with documentation move.
>
>  avconv.h |  2 --
>  avconv_opt.c | 13 -
>  cmdutils.c   | 12 
>  cmdutils.h   |  5 +
>  cmdutils_common_opts.h   |  1 +
>  doc/avconv.texi  |  4 
>  doc/avtools-common-opts.texi |  4 
>  7 files changed, 22 insertions(+), 19 deletions(-)

I think this is ok.

> diff --git a/doc/avtools-common-opts.texi b/doc/avtools-common-opts.texi
> index 4be5412..3310876 100644
> --- a/doc/avtools-common-opts.texi
> +++ b/doc/avtools-common-opts.texi
> @@ -143,6 +143,10 @@ the environment variable @env{AV_LOG_FORCE_COLOR}.
>  The use of the environment variable @env{NO_COLOR} is deprecated and
>  will be dropped in a following Libav version.
>
> +@item -cpuflags mask (@emph{global})
> +Set a mask that's applied to autodetected CPU flags.  This option is intended
> +for testing. Do not use it unless you know what you're doing.
> +

You can remove the double space while moving this section (unless it's
intentional).
Cheers,
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] vf_fieldorder: log when processing is skipped

2013-10-22 Thread Vittorio Giovara
---
 libavfilter/vf_fieldorder.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index 19b07b1..852c871 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -101,8 +101,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 uint8_t *data;
 
 if (!frame->interlaced_frame ||
-frame->top_field_first == s->dst_tff)
+frame->top_field_first == s->dst_tff) {
+av_log(ctx, AV_LOG_VERBOSE,
+   "Skipping %s.\n",
+   frame->interlaced_frame ?
+   "frame with same field order" : "progressive frame");
 return ff_filter_frame(outlink, frame);
+}
 
 av_dlog(ctx,
 "picture will move %s one line\n",
-- 
1.7.9.5

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avfilter: Fix typo in Loren's email address

2013-10-22 Thread Vittorio Giovara
On Mon, Oct 21, 2013 at 10:35 PM, Diego Biurrun  wrote:
> ---
>  libavfilter/gradfun.h|2 +-
>  libavfilter/vf_gradfun.c |2 +-
>  libavfilter/x86/vf_gradfun.c |2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

Ok.
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] download: correct version number for 0.8 release

2013-10-22 Thread Luca Barbato
On 21/10/13 20:28, Johan Andersson wrote:
> $subject
> 
> 
> 

Pushing it now. thanks!

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel