Re: [libav-devel] [PATCH] avconv: initialize hwaccel_pix_fmt

2013-12-02 Thread Anton Khirnov

ping2

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


Re: [libav-devel] [PATCH 15/31] vc1dec: move setting repeat_pict after frame_start() has been called.

2013-12-02 Thread Anton Khirnov

On Tue, 3 Dec 2013 07:59:30 +0100, Hendrik Leppkes  wrote:
> On Tue, Dec 3, 2013 at 12:16 AM, Anton Khirnov  wrote:
> > This will allow removing the hacks where each decoder sets
> > current_picture_ptr on its own.
> > ---
> >  libavcodec/vc1dec.c |   24 
> >  1 file changed, 12 insertions(+), 12 deletions(-)
> >
> > diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
> > index 4a73d2c..ab4e098 100644
> > --- a/libavcodec/vc1dec.c
> > +++ b/libavcodec/vc1dec.c
> > @@ -5943,18 +5943,6 @@ static int vc1_decode_frame(AVCodecContext *avctx, 
> > void *data,
> >  goto err;
> >  }
> >
> > -// process pulldown flags
> > -s->current_picture_ptr->f.repeat_pict = 0;
> > -// Pulldown flags are only valid when 'broadcast' has been set.
> > -// So ticks_per_frame will be 2
> > -if (v->rff) {
> > -// repeat field
> > -s->current_picture_ptr->f.repeat_pict = 1;
> > -} else if (v->rptfrm) {
> > -// repeat frames
> > -s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
> > -}
> > -
> >  // for skipping the frame
> >  s->current_picture.f.pict_type = s->pict_type;
> >  s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
> > @@ -5980,6 +5968,18 @@ static int vc1_decode_frame(AVCodecContext *avctx, 
> > void *data,
> >  goto err;
> >  }
> >
> > +// process pulldown flags
> > +s->current_picture_ptr->f.repeat_pict = 0;
> > +// Pulldown flags are only valid when 'broadcast' has been set.
> > +// So ticks_per_frame will be 2
> > +if (v->rff) {
> > +// repeat field
> > +s->current_picture_ptr->f.repeat_pict = 1;
> > +} else if (v->rptfrm) {
> > +// repeat frames
> > +s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
> > +}
> > +
> >  s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
> >  s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
> >
> > --
> > 1.7.10.4
> 
> Why not simply change it to current_picture without _ptr like the
> lines immediately below the block you moved?
> 

Because it's the _ptr one that actually gets returned to the caller.

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


Re: [libav-devel] [PATCH 15/31] vc1dec: move setting repeat_pict after frame_start() has been called.

2013-12-02 Thread Hendrik Leppkes
On Tue, Dec 3, 2013 at 12:16 AM, Anton Khirnov  wrote:
> This will allow removing the hacks where each decoder sets
> current_picture_ptr on its own.
> ---
>  libavcodec/vc1dec.c |   24 
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
> index 4a73d2c..ab4e098 100644
> --- a/libavcodec/vc1dec.c
> +++ b/libavcodec/vc1dec.c
> @@ -5943,18 +5943,6 @@ static int vc1_decode_frame(AVCodecContext *avctx, 
> void *data,
>  goto err;
>  }
>
> -// process pulldown flags
> -s->current_picture_ptr->f.repeat_pict = 0;
> -// Pulldown flags are only valid when 'broadcast' has been set.
> -// So ticks_per_frame will be 2
> -if (v->rff) {
> -// repeat field
> -s->current_picture_ptr->f.repeat_pict = 1;
> -} else if (v->rptfrm) {
> -// repeat frames
> -s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
> -}
> -
>  // for skipping the frame
>  s->current_picture.f.pict_type = s->pict_type;
>  s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
> @@ -5980,6 +5968,18 @@ static int vc1_decode_frame(AVCodecContext *avctx, 
> void *data,
>  goto err;
>  }
>
> +// process pulldown flags
> +s->current_picture_ptr->f.repeat_pict = 0;
> +// Pulldown flags are only valid when 'broadcast' has been set.
> +// So ticks_per_frame will be 2
> +if (v->rff) {
> +// repeat field
> +s->current_picture_ptr->f.repeat_pict = 1;
> +} else if (v->rptfrm) {
> +// repeat frames
> +s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
> +}
> +
>  s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
>  s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
>
> --
> 1.7.10.4

Why not simply change it to current_picture without _ptr like the
lines immediately below the block you moved?

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


Re: [libav-devel] [PATCH 19/31] mjpegenc: cosmetics, reformat jpeg_put_comments()

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:19AM +0100, Anton Khirnov wrote:
> ---
>  libavcodec/mjpegenc.c |   29 ++---
>  1 file changed, 14 insertions(+), 15 deletions(-)

Why not do the whole file while you're at it?

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


Re: [libav-devel] [PATCH 22/31] mjpegenc: do not pass MpegEncContext to jpeg_table_header()

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:22AM +0100, Anton Khirnov wrote:
> Pass the three needed fields from it directly.
> This will allow to deMpegEncContextize the LJpegEncoder.

LJPEG encoder

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


Re: [libav-devel] [PATCH 14/31] mpegvideo: make ff_release_unused_pictures() static

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:14AM +0100, Anton Khirnov wrote:
> It is only called from one place in mpegvideo.c now. Also remove the
> remove_current parameter, which is always 1.
> ---
>  libavcodec/mpegvideo.c |8 +++-
>  libavcodec/mpegvideo.h |1 -
>  2 files changed, 3 insertions(+), 6 deletions(-)

OK

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


Re: [libav-devel] [PATCH 13/31] mpegvideo: make frame_size_alloc() static.

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:13AM +0100, Anton Khirnov wrote:
> It is not called from outside of mpegvideo.c anymore.
> ---
>  libavcodec/mpegvideo.c |8 
>  libavcodec/mpegvideo.h |1 -
>  2 files changed, 4 insertions(+), 5 deletions(-)

OK

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


Re: [libav-devel] [PATCH 05/31] mpeg4videodec: move showed_packed_warning from MpegEncContext to Mpeg4DecContext

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:05AM +0100, Anton Khirnov wrote:
> ---
>  libavcodec/mpeg4video.h|2 ++
>  libavcodec/mpeg4videodec.c |4 ++--
>  libavcodec/mpegvideo.h |1 -
>  3 files changed, 4 insertions(+), 3 deletions(-)

OK

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


Re: [libav-devel] [PATCH 04/31] mpeg4videodec: move intra_dc_threshold from MpegEncContext to Mpeg4DecContext

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:04AM +0100, Anton Khirnov wrote:
> ---
>  libavcodec/mpeg4video.h|2 ++
>  libavcodec/mpeg4videodec.c |8 
>  libavcodec/mpegvideo.h |1 -
>  libavcodec/vaapi_mpeg4.c   |4 ++--
>  4 files changed, 8 insertions(+), 7 deletions(-)

Should be OK.

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


Re: [libav-devel] [PATCH 27/31] ljpeg: remove a commented-out line

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:27AM +0100, Anton Khirnov wrote:
> ---
>  libavcodec/ljpegenc.c |1 -
>  1 file changed, 1 deletion(-)

Yeah, why not.

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


Re: [libav-devel] [PATCH 21/31] mjpegenc: remove commented out never-to-be-finished WIP cruft

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:21AM +0100, Anton Khirnov wrote:
> ---
>  libavcodec/mjpegenc.c |   25 -
>  1 file changed, 25 deletions(-)

OK with me.

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


Re: [libav-devel] [PATCH 11/31] mpegvideo: remove commented out cruft from ff_MPV_frame_end()

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:11AM +0100, Anton Khirnov wrote:
> ---
>  libavcodec/mpegvideo.c |   18 --
>  1 file changed, 18 deletions(-)

Surely nothing I will complain about.

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


Re: [libav-devel] [PATCH 03/31] mpeg12dec: move first_slice from MpegEncContext to Mpeg1Context

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:03AM +0100, Anton Khirnov wrote:
> ---
>  libavcodec/mpeg12dec.c |7 ---
>  libavcodec/mpegvideo.h |1 -
>  2 files changed, 4 insertions(+), 4 deletions(-)

OK

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


Re: [libav-devel] [PATCH 02/31] mpegvideo: remove an unused variable

2013-12-02 Thread Diego Biurrun
On Tue, Dec 03, 2013 at 12:16:02AM +0100, Anton Khirnov wrote:
> ---
>  libavcodec/mpegvideo.h |1 -
>  1 file changed, 1 deletion(-)

OK

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


Re: [libav-devel] [PATCH 4/5] configure: Check for a definition instead of a header for mingw libc

2013-12-02 Thread Diego Biurrun

On 02.12.2013 18:49, Alex Smith wrote:

On Mon, Dec 2, 2013 at 4:19 PM, Diego Biurrun  wrote:

+elif check_cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
  libc_type=mingw
  check_cpp_condition _mingw.h \
  "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) 
|| \


 From config.log:

check_cpp_condition _mingw.h defined __MINGW32_VERSION
check_cpp
BEGIN /msystmp/ffconf.cOtycERm.c
 1 #include <_mingw.h>
 2 #if !(defined __MINGW32_VERSION)
 3 #error "unsatisfied condition: defined __MINGW32_VERSION"
 4 #endif
END /msystmp/ffconf.cOtycERm.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-march=i686 -std=c99 -E -o /msystmp/ffconf.PlYxyFKS.o
/msystmp/ffconf.cOtycERm.c
f:/msys/tmp/ffconf.cOtycERm.c:3:2: error: #error "unsatisfied
condition: defined __MINGW32_VERSION"
  #error "unsatisfied condition: defined __MINGW32_VERSION"


what MinGW version/variant was that?  MinGW64?  Did you also test MinGW32?

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


Re: [libav-devel] [PATCH 4/5] configure: Check for a definition instead of a header for mingw libc

2013-12-02 Thread Alex Smith
On Mon, Dec 2, 2013 at 4:19 PM, Diego Biurrun  wrote:
> +elif check_cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
>  libc_type=mingw
>  check_cpp_condition _mingw.h \
>  "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) 
> || \

>From config.log:

check_cpp_condition _mingw.h defined __MINGW32_VERSION
check_cpp
BEGIN /msystmp/ffconf.cOtycERm.c
1 #include <_mingw.h>
2 #if !(defined __MINGW32_VERSION)
3 #error "unsatisfied condition: defined __MINGW32_VERSION"
4 #endif
END /msystmp/ffconf.cOtycERm.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-march=i686 -std=c99 -E -o /msystmp/ffconf.PlYxyFKS.o
/msystmp/ffconf.cOtycERm.c
f:/msys/tmp/ffconf.cOtycERm.c:3:2: error: #error "unsatisfied
condition: defined __MINGW32_VERSION"
 #error "unsatisfied condition: defined __MINGW32_VERSION"
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 29/31] ljpegenc: accept bgr24 instead of bgra

2013-12-02 Thread Anton Khirnov
The alpha plane is not encoded.
---
 libavcodec/ljpegenc.c |   18 +-
 libavcodec/mjpegenc.c |4 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 4bb6bbf..da39a0d 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -70,8 +70,8 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 int max_pkt_size = FF_MIN_BUFFER_SIZE;
 int ret, header_bits;
 
-if (avctx->pix_fmt == AV_PIX_FMT_BGRA)
-max_pkt_size += width * height * 3 * 4;
+if (avctx->pix_fmt == AV_PIX_FMT_BGR24)
+max_pkt_size += width * height * 3 * 3;
 else {
 max_pkt_size += mb_width * mb_height * 3 * 4
 * s->hsample[0] * s->vsample[0];
@@ -88,7 +88,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 
 header_bits = put_bits_count(&pb);
 
-if(avctx->pix_fmt == AV_PIX_FMT_BGRA){
+if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
 int x, y, i;
 const int linesize = pict->linesize[0];
 uint16_t (*buffer)[4] = s->scratch;
@@ -102,7 +102,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 const int modified_predictor= y ? predictor : 1;
 uint8_t *ptr = pict->data[0] + (linesize * y);
 
-if(pb.buf_end - pb.buf - (put_bits_count(&pb) >> 3) < width * 3 * 
4) {
+if(pb.buf_end - pb.buf - (put_bits_count(&pb) >> 3) < width * 3 * 
3) {
 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
 return -1;
 }
@@ -111,9 +111,9 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 top[i]= left[i]= topleft[i]= buffer[0][i];
 }
 for(x = 0; x < width; x++) {
-buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100;
-buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100;
-buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2;
+buffer[x][1] =  ptr[3 * x + 0] - ptr[3 * x + 1] + 0x100;
+buffer[x][2] =  ptr[3 * x + 2] - ptr[3 * x + 1] + 0x100;
+buffer[x][0] = (ptr[3 * x + 0] + 2 * ptr[3 * x + 1] + ptr[3 * 
x + 2]) >> 2;
 
 for(i=0;i<3;i++) {
 int pred, diff;
@@ -257,7 +257,7 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
 av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
  &chroma_v_shift);
 
-if (avctx->pix_fmt   == AV_PIX_FMT_BGRA) {
+if (avctx->pix_fmt   == AV_PIX_FMT_BGR24) {
 s->vsample[0] = s->hsample[0] =
 s->vsample[1] = s->hsample[1] =
 s->vsample[2] = s->hsample[2] = 1;
@@ -294,7 +294,7 @@ AVCodec ff_ljpeg_encoder = {
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVJ420P,
 AV_PIX_FMT_YUVJ422P,
 AV_PIX_FMT_YUVJ444P,
-AV_PIX_FMT_BGRA,
+AV_PIX_FMT_BGR24,
 AV_PIX_FMT_YUV420P,
 AV_PIX_FMT_YUV422P,
 AV_PIX_FMT_YUVJ444P,
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 054cc66..30433c3 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -186,7 +186,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, 
PutBitContext *pb,
  &chroma_v_shift);
 
 if (avctx->codec->id == AV_CODEC_ID_LJPEG &&
-avctx->pix_fmt   == AV_PIX_FMT_BGRA) {
+avctx->pix_fmt   == AV_PIX_FMT_BGR24) {
 vsample[0] = hsample[0] =
 vsample[1] = hsample[1] =
 vsample[2] = hsample[2] = 1;
@@ -212,7 +212,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, 
PutBitContext *pb,
 }
 
 put_bits(pb, 16, 17);
-if (lossless && avctx->pix_fmt == AV_PIX_FMT_BGRA)
+if (lossless && avctx->pix_fmt == AV_PIX_FMT_BGR24)
 put_bits(pb, 8, 9); /* 9 bits/component RCT */
 else
 put_bits(pb, 8, 8); /* 8 bits/component */
-- 
1.7.10.4

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


[libav-devel] [PATCH 09/31] mpegvideo: do not update last_non_b_pict_type in update_thread_context()

2013-12-02 Thread Anton Khirnov
It is use for encoding only.
---
 libavcodec/mpegvideo.c |4 
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 0c7b9cf..9065c47 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -762,10 +762,6 @@ do {\
 s->last_pict_type = s1->pict_type;
 if (s1->current_picture_ptr)
 s->last_lambda_for[s1->pict_type] = 
s1->current_picture_ptr->f.quality;
-
-if (s1->pict_type != AV_PICTURE_TYPE_B) {
-s->last_non_b_pict_type = s1->pict_type;
-}
 }
 
 return 0;
-- 
1.7.10.4

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


[libav-devel] [PATCH 30/31] ljpegenc: split bgr encoding into a separate function

2013-12-02 Thread Anton Khirnov
---
 libavcodec/ljpegenc.c |  103 -
 1 file changed, 58 insertions(+), 45 deletions(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index da39a0d..e819c57 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -57,6 +57,61 @@ typedef struct LJpegEncContext {
 uint16_t (*scratch)[4];
 } LJpegEncContext;
 
+static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb,
+const AVFrame *frame)
+{
+LJpegEncContext *s= avctx->priv_data;
+const int width   = frame->width;
+const int height  = frame->height;
+const int linesize= frame->linesize[0];
+uint16_t (*buffer)[4] = s->scratch;
+const int predictor   = avctx->prediction_method+1;
+int left[3], top[3], topleft[3];
+int x, y, i;
+
+for (i = 0; i < 3; i++)
+buffer[0][i] = 1 << (9 - 1);
+
+for (y = 0; y < height; y++) {
+const int modified_predictor = y ? predictor : 1;
+uint8_t *ptr = frame->data[0] + (linesize * y);
+
+if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) < width * 3 * 3) 
{
+av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
+return -1;
+}
+
+for (i = 0; i < 3; i++)
+top[i]= left[i]= topleft[i]= buffer[0][i];
+
+for (x = 0; x < width; x++) {
+buffer[x][1] =  ptr[3 * x + 0] - ptr[3 * x + 1] + 0x100;
+buffer[x][2] =  ptr[3 * x + 2] - ptr[3 * x + 1] + 0x100;
+buffer[x][0] = (ptr[3 * x + 0] + 2 * ptr[3 * x + 1] + ptr[3 * x + 
2]) >> 2;
+
+for (i = 0; i < 3; i++) {
+int pred, diff;
+
+PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
+
+topleft[i] = top[i];
+top[i] = buffer[x+1][i];
+
+left[i]= buffer[x][i];
+
+diff   = ((left[i] - pred + 0x100) & 0x1FF) - 0x100;
+
+if (i == 0)
+ff_mjpeg_encode_dc(pb, diff, s->huff_size_dc_luminance, 
s->huff_code_dc_luminance); //FIXME ugly
+else
+ff_mjpeg_encode_dc(pb, diff, s->huff_size_dc_chrominance, 
s->huff_code_dc_chrominance);
+}
+}
+}
+
+return 0;
+}
+
 static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
   const AVFrame *pict, int *got_packet)
 {
@@ -89,51 +144,9 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 header_bits = put_bits_count(&pb);
 
 if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
-int x, y, i;
-const int linesize = pict->linesize[0];
-uint16_t (*buffer)[4] = s->scratch;
-int left[3], top[3], topleft[3];
-
-for(i=0; i<3; i++){
-buffer[0][i]= 1 << (9 - 1);
-}
-
-for(y = 0; y < height; y++) {
-const int modified_predictor= y ? predictor : 1;
-uint8_t *ptr = pict->data[0] + (linesize * y);
-
-if(pb.buf_end - pb.buf - (put_bits_count(&pb) >> 3) < width * 3 * 
3) {
-av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
-return -1;
-}
-
-for(i=0; i<3; i++){
-top[i]= left[i]= topleft[i]= buffer[0][i];
-}
-for(x = 0; x < width; x++) {
-buffer[x][1] =  ptr[3 * x + 0] - ptr[3 * x + 1] + 0x100;
-buffer[x][2] =  ptr[3 * x + 2] - ptr[3 * x + 1] + 0x100;
-buffer[x][0] = (ptr[3 * x + 0] + 2 * ptr[3 * x + 1] + ptr[3 * 
x + 2]) >> 2;
-
-for(i=0;i<3;i++) {
-int pred, diff;
-
-PREDICT(pred, topleft[i], top[i], left[i], 
modified_predictor);
-
-topleft[i]= top[i];
-top[i]= buffer[x+1][i];
-
-left[i]= buffer[x][i];
-
-diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100;
-
-if(i==0)
-ff_mjpeg_encode_dc(&pb, diff, 
s->huff_size_dc_luminance, s->huff_code_dc_luminance); //FIXME ugly
-else
-ff_mjpeg_encode_dc(&pb, diff, 
s->huff_size_dc_chrominance, s->huff_code_dc_chrominance);
-}
-}
-}
+ret = ljpeg_encode_bgr(avctx, &pb, pict);
+if (ret < 0)
+return ret;
 }else{
 int mb_x, mb_y, i;
 
-- 
1.7.10.4

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


[libav-devel] [PATCH 07/31] mpegvideo: move setting encoding-only vars from common_defaults() to encode_defaults()

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mpegvideo.c |3 ---
 libavcodec/mpegvideo_enc.c |3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 0aa725b..541b8ed 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -788,9 +788,6 @@ void ff_MPV_common_defaults(MpegEncContext *s)
 
 s->coded_picture_number  = 0;
 s->picture_number= 0;
-s->input_picture_number  = 0;
-
-s->picture_in_gop_number = 0;
 
 s->f_code= 1;
 s->b_code= 1;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 414be90..bacec72 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -217,6 +217,9 @@ static void MPV_encode_defaults(MpegEncContext *s)
 }
 s->me.mv_penalty = default_mv_penalty;
 s->fcode_tab = default_fcode_tab;
+
+s->input_picture_number  = 0;
+s->picture_in_gop_number = 0;
 }
 
 /* init video encoder */
-- 
1.7.10.4

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


[libav-devel] [PATCH 31/31] ljpegenc: split yuv encoding into a separate function

2013-12-02 Thread Anton Khirnov
---
 libavcodec/ljpegenc.c |  167 +++--
 1 file changed, 93 insertions(+), 74 deletions(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index e819c57..7eb4675 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -112,6 +112,94 @@ static int ljpeg_encode_bgr(AVCodecContext *avctx, 
PutBitContext *pb,
 return 0;
 }
 
+static inline void ljpeg_encode_yuv_mb(LJpegEncContext *s, PutBitContext *pb,
+   const AVFrame *frame, int predictor,
+   int mb_x, int mb_y)
+{
+int i;
+
+if (mb_x == 0 || mb_y == 0) {
+for (i = 0; i < 3; i++) {
+uint8_t *ptr;
+int x, y, h, v, linesize;
+h = s->hsample[i];
+v = s->vsample[i];
+linesize = frame->linesize[i];
+
+for (y = 0; y < v; y++) {
+for (x = 0; x < h; x++) {
+int pred;
+
+ptr = frame->data[i] + (linesize * (v * mb_y + y)) + (h * 
mb_x + x); //FIXME optimize this crap
+if (y == 0 && mb_y == 0) {
+if (x == 0 && mb_x == 0)
+pred = 128;
+else
+pred = ptr[-1];
+} else {
+if (x == 0 && mb_x == 0) {
+pred = ptr[-linesize];
+} else {
+PREDICT(pred, ptr[-linesize - 1], ptr[-linesize],
+ptr[-1], predictor);
+}
+}
+
+if (i == 0)
+ff_mjpeg_encode_dc(pb, *ptr - pred, 
s->huff_size_dc_luminance, s->huff_code_dc_luminance); //FIXME ugly
+else
+ff_mjpeg_encode_dc(pb, *ptr - pred, 
s->huff_size_dc_chrominance, s->huff_code_dc_chrominance);
+}
+}
+}
+} else {
+for (i = 0; i < 3; i++) {
+uint8_t *ptr;
+int x, y, h, v, linesize;
+h = s->hsample[i];
+v = s->vsample[i];
+linesize = frame->linesize[i];
+
+for (y = 0; y < v; y++) {
+for (x = 0; x < h; x++) {
+int pred;
+
+ptr = frame->data[i] + (linesize * (v * mb_y + y)) + (h * 
mb_x + x); //FIXME optimize this crap
+PREDICT(pred, ptr[-linesize - 1], ptr[-linesize], ptr[-1], 
predictor);
+
+if (i == 0)
+ff_mjpeg_encode_dc(pb, *ptr - pred, 
s->huff_size_dc_luminance, s->huff_code_dc_luminance); //FIXME ugly
+else
+ff_mjpeg_encode_dc(pb, *ptr - pred, 
s->huff_size_dc_chrominance, s->huff_code_dc_chrominance);
+}
+}
+}
+}
+}
+
+static int ljpeg_encode_yuv(AVCodecContext *avctx, PutBitContext *pb,
+const AVFrame *frame)
+{
+const int predictor = avctx->prediction_method + 1;
+LJpegEncContext *s  = avctx->priv_data;
+const int mb_width  = (avctx->width  + s->hsample[0] - 1) / s->hsample[0];
+const int mb_height = (avctx->height + s->vsample[0] - 1) / s->vsample[0];
+int mb_x, mb_y;
+
+for (mb_y = 0; mb_y < mb_height; mb_y++) {
+if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) <
+mb_width * 4 * 3 * s->hsample[0] * s->vsample[0]) {
+av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
+return -1;
+}
+
+for (mb_x = 0; mb_x < mb_width; mb_x++)
+ljpeg_encode_yuv_mb(s, pb, frame, predictor, mb_x, mb_y);
+}
+
+return 0;
+}
+
 static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
   const AVFrame *pict, int *got_packet)
 {
@@ -119,7 +207,6 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 PutBitContext pb;
 const int width  = avctx->width;
 const int height = avctx->height;
-const int predictor= avctx->prediction_method+1;
 const int mb_width  = (width  + s->hsample[0] - 1) / s->hsample[0];
 const int mb_height = (height + s->vsample[0] - 1) / s->vsample[0];
 int max_pkt_size = FF_MIN_BUFFER_SIZE;
@@ -143,80 +230,12 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 header_bits = put_bits_count(&pb);
 
-if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
+if (avctx->pix_fmt == AV_PIX_FMT_BGR24)
 ret = ljpeg_encode_bgr(avctx, &pb, pict);
-if (ret < 0)
-return ret;
-}else{
-int mb_x, mb_y, i;
-
-for(mb_y = 0; mb_y < mb_height; mb_y++) {
-if (pb.buf_end - pb.buf - (put_bits_count(&pb) >> 3) <
-mb_width * 4 * 3 * s->hsample[0] * s->vsample[0]) {
-av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");

[libav-devel] [PATCH 18/31] mjpegenc: write the JFIF header if the sample aspect ratio is set

2013-12-02 Thread Anton Khirnov
MpegEncContext.aspect_ratio_info is never set for mjpeg, so this was
never written before.
---
 libavcodec/mjpegenc.c |   19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 0bf3dc1..a22f340 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -148,13 +148,12 @@ static void jpeg_table_header(MpegEncContext *s)
 AV_WB16(ptr, size);
 }
 
-static void jpeg_put_comments(MpegEncContext *s)
+static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)
 {
-PutBitContext *p = &s->pb;
 int size;
 uint8_t *ptr;
 
-if (s->aspect_ratio_info /* && !lossless */)
+if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 
0)
 {
 /* JFIF header */
 put_marker(p, APP0);
@@ -162,14 +161,14 @@ static void jpeg_put_comments(MpegEncContext *s)
 avpriv_put_string(p, "JFIF", 1); /* this puts the trailing zero-byte too */
 put_bits(p, 16, 0x0201); /* v 1.02 */
 put_bits(p, 8, 0); /* units type: 0 - aspect ratio */
-put_bits(p, 16, s->avctx->sample_aspect_ratio.num);
-put_bits(p, 16, s->avctx->sample_aspect_ratio.den);
+put_bits(p, 16, avctx->sample_aspect_ratio.num);
+put_bits(p, 16, avctx->sample_aspect_ratio.den);
 put_bits(p, 8, 0); /* thumbnail width */
 put_bits(p, 8, 0); /* thumbnail height */
 }
 
 /* comment */
-if(!(s->flags & CODEC_FLAG_BITEXACT)){
+if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
 put_marker(p, COM);
 flush_put_bits(p);
 ptr = put_bits_ptr(p);
@@ -179,9 +178,9 @@ static void jpeg_put_comments(MpegEncContext *s)
 AV_WB16(ptr, size);
 }
 
-if(  s->avctx->pix_fmt == AV_PIX_FMT_YUV420P
-   ||s->avctx->pix_fmt == AV_PIX_FMT_YUV422P
-   ||s->avctx->pix_fmt == AV_PIX_FMT_YUV444P){
+if(  avctx->pix_fmt == AV_PIX_FMT_YUV420P
+   ||avctx->pix_fmt == AV_PIX_FMT_YUV422P
+   ||avctx->pix_fmt == AV_PIX_FMT_YUV444P){
 put_marker(p, COM);
 flush_put_bits(p);
 ptr = put_bits_ptr(p);
@@ -198,7 +197,7 @@ void ff_mjpeg_encode_picture_header(MpegEncContext *s)
 
 put_marker(&s->pb, SOI);
 
-jpeg_put_comments(s);
+jpeg_put_comments(s->avctx, &s->pb);
 
 jpeg_table_header(s);
 
-- 
1.7.10.4

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


[libav-devel] [PATCH 11/31] mpegvideo: remove commented out cruft from ff_MPV_frame_end()

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mpegvideo.c |   18 --
 1 file changed, 18 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index c50c2e1..88a0abf 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1602,24 +1602,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 emms_c();
 
-#if 0
-/* copy back current_picture variables */
-for (i = 0; i < MAX_PICTURE_COUNT; i++) {
-if (s->picture[i].f.data[0] == s->current_picture.f.data[0]) {
-s->picture[i] = s->current_picture;
-break;
-}
-}
-assert(i < MAX_PICTURE_COUNT);
-#endif
-
-// clear copies, to avoid confusion
-#if 0
-memset(&s->last_picture,0, sizeof(Picture));
-memset(&s->next_picture,0, sizeof(Picture));
-memset(&s->current_picture, 0, sizeof(Picture));
-#endif
-
 if (s->current_picture.reference)
 ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0);
 }
-- 
1.7.10.4

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


[libav-devel] [PATCH 27/31] ljpeg: remove a commented-out line

2013-12-02 Thread Anton Khirnov
---
 libavcodec/ljpegenc.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index bb3c188..13d52f5 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -215,7 +215,6 @@ static int encode_picture_lossless(AVCodecContext *avctx, 
AVPacket *pkt,
 *got_packet = 1;
 
 return 0;
-//return (put_bits_count(&f->pb)+7)/8;
 }
 
 static av_cold int ljpeg_encode_close(AVCodecContext *avctx)
-- 
1.7.10.4

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


[libav-devel] [PATCH 26/31] ljpegenc: deMpegEncContextize

2013-12-02 Thread Anton Khirnov
The encoder uses almost none of the mpegvideo infrastructure, only some
fields from MpegEncContext.

The FATE results change because now an all-zero quant matrix is written
into the file. Since it is not used for anything for ljpeg, this should
not be a problem.
---
 libavcodec/ljpegenc.c  |  179 +---
 libavcodec/mpegvideo_enc.c |   37 ++---
 tests/ref/vsynth/vsynth1-ljpeg |2 +-
 tests/ref/vsynth/vsynth2-ljpeg |2 +-
 4 files changed, 142 insertions(+), 78 deletions(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 1ca2d37..bb3c188 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -30,55 +30,68 @@
  * lossless JPEG encoder.
  */
 
+#include "libavutil/frame.h"
+#include "libavutil/mem.h"
+#include "libavutil/pixdesc.h"
+
 #include "avcodec.h"
+#include "dsputil.h"
 #include "internal.h"
 #include "mpegvideo.h"
 #include "mjpeg.h"
 #include "mjpegenc.h"
 
+typedef struct LJpegEncContext {
+DSPContext dsp;
+ScanTable scantable;
+uint16_t matrix[64];
+
+int vsample[3];
+int hsample[3];
+
+uint16_t huff_code_dc_luminance[12];
+uint16_t huff_code_dc_chrominance[12];
+uint8_t  huff_size_dc_luminance[12];
+uint8_t  huff_size_dc_chrominance[12];
+
+uint16_t (*scratch)[4];
+} LJpegEncContext;
 
 static int encode_picture_lossless(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
 {
-MpegEncContext * const s = avctx->priv_data;
-MJpegContext * const m = s->mjpeg_ctx;
-const int width= s->width;
-const int height= s->height;
-AVFrame * const p = &s->current_picture.f;
+LJpegEncContext *s = avctx->priv_data;
+PutBitContext pb;
+const int width  = avctx->width;
+const int height = avctx->height;
 const int predictor= avctx->prediction_method+1;
-const int mb_width  = (width  + s->mjpeg_hsample[0] - 1) / 
s->mjpeg_hsample[0];
-const int mb_height = (height + s->mjpeg_vsample[0] - 1) / 
s->mjpeg_vsample[0];
-int ret, max_pkt_size = FF_MIN_BUFFER_SIZE;
+const int mb_width  = (width  + s->hsample[0] - 1) / s->hsample[0];
+const int mb_height = (height + s->vsample[0] - 1) / s->vsample[0];
+int max_pkt_size = FF_MIN_BUFFER_SIZE;
+int ret, header_bits;
 
 if (avctx->pix_fmt == AV_PIX_FMT_BGRA)
 max_pkt_size += width * height * 3 * 4;
 else {
 max_pkt_size += mb_width * mb_height * 3 * 4
-* s->mjpeg_hsample[0] * s->mjpeg_vsample[0];
+* s->hsample[0] * s->vsample[0];
 }
 if ((ret = ff_alloc_packet(pkt, max_pkt_size)) < 0) {
 av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size 
%d.\n", max_pkt_size);
 return ret;
 }
 
-init_put_bits(&s->pb, pkt->data, pkt->size);
+init_put_bits(&pb, pkt->data, pkt->size);
 
-av_frame_unref(p);
-ret = av_frame_ref(p, pict);
-if (ret < 0)
-return ret;
-p->pict_type= AV_PICTURE_TYPE_I;
-p->key_frame= 1;
-
-ff_mjpeg_encode_picture_header(avctx, &s->pb, &s->intra_scantable,
-   s->intra_matrix);
+ff_mjpeg_encode_picture_header(avctx, &pb, &s->scantable,
+   s->matrix);
 
-s->header_bits= put_bits_count(&s->pb);
+header_bits = put_bits_count(&pb);
 
 if(avctx->pix_fmt == AV_PIX_FMT_BGRA){
 int x, y, i;
-const int linesize= p->linesize[0];
-uint16_t (*buffer)[4]= (void *) s->rd_scratchpad;
+const int linesize = pict->linesize[0];
+uint16_t (*buffer)[4] = s->scratch;
 int left[3], top[3], topleft[3];
 
 for(i=0; i<3; i++){
@@ -87,10 +100,10 @@ static int encode_picture_lossless(AVCodecContext *avctx, 
AVPacket *pkt,
 
 for(y = 0; y < height; y++) {
 const int modified_predictor= y ? predictor : 1;
-uint8_t *ptr = p->data[0] + (linesize * y);
+uint8_t *ptr = pict->data[0] + (linesize * y);
 
-if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 
width*3*4){
-av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
+if(pb.buf_end - pb.buf - (put_bits_count(&pb) >> 3) < width * 3 * 
4) {
+av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
 return -1;
 }
 
@@ -115,9 +128,9 @@ static int encode_picture_lossless(AVCodecContext *avctx, 
AVPacket *pkt,
 diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100;
 
 if(i==0)
-ff_mjpeg_encode_dc(&s->pb, diff, 
m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
+ff_mjpeg_encode_dc(&pb, diff, 
s->huff_size_dc_luminance, s->huff_code_dc_luminance); //FIXME ugly
 else
-ff_mjpeg_encode_dc(&s->pb, diff, 
m->huff_size_dc_chrominance, m->huff_code_d

[libav-devel] [PATCH 10/31] mpegvideo: split the encoding-only parts of ff_MPV_frame_end() into a separate function

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mpegvideo.c |   20 ++--
 libavcodec/mpegvideo_enc.c |   45 +++-
 2 files changed, 46 insertions(+), 19 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 9065c47..c50c2e1 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1565,12 +1565,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return 0;
 }
 
-/* generic function for encode/decode called after a
- * frame has been coded/decoded. */
+/* called after a frame has been decoded. */
 void ff_MPV_frame_end(MpegEncContext *s)
 {
-int i;
-
 #if FF_API_XVMC
 FF_DISABLE_DEPRECATION_WARNINGS
 /* redraw edges for the frame if decoding didn't complete */
@@ -1580,7 +1577,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
 } else
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif /* FF_API_XVMC */
-if ((s->er.error_count || s->encoding) &&
+if (s->er.error_count  &&
 !s->avctx->hwaccel &&
 s->unrestricted_mv &&
 s->current_picture.reference &&
@@ -1605,11 +1602,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 emms_c();
 
-s->last_pict_type = s->pict_type;
-s->last_lambda_for [s->pict_type] = s->current_picture_ptr->f.quality;
-if (s->pict_type!= AV_PICTURE_TYPE_B) {
-s->last_non_b_pict_type = s->pict_type;
-}
 #if 0
 /* copy back current_picture variables */
 for (i = 0; i < MAX_PICTURE_COUNT; i++) {
@@ -1621,20 +1613,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
 assert(i < MAX_PICTURE_COUNT);
 #endif
 
-if (s->encoding) {
-/* release non-reference frames */
-for (i = 0; i < MAX_PICTURE_COUNT; i++) {
-if (!s->picture[i].reference)
-ff_mpeg_unref_picture(s, &s->picture[i]);
-}
-}
 // clear copies, to avoid confusion
 #if 0
 memset(&s->last_picture,0, sizeof(Picture));
 memset(&s->next_picture,0, sizeof(Picture));
 memset(&s->current_picture, 0, sizeof(Picture));
 #endif
-s->avctx->coded_frame = &s->current_picture_ptr->f;
 
 if (s->current_picture.reference)
 ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 470418a..258bfcf 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1359,6 +1359,49 @@ no_output_pic:
 return 0;
 }
 
+static void frame_end(MpegEncContext *s)
+{
+int i;
+
+if (s->unrestricted_mv &&
+s->current_picture.reference &&
+!s->intra_only) {
+const AVPixFmtDescriptor *desc = 
av_pix_fmt_desc_get(s->avctx->pix_fmt);
+int hshift = desc->log2_chroma_w;
+int vshift = desc->log2_chroma_h;
+s->dsp.draw_edges(s->current_picture.f.data[0], s->linesize,
+  s->h_edge_pos, s->v_edge_pos,
+  EDGE_WIDTH, EDGE_WIDTH,
+  EDGE_TOP | EDGE_BOTTOM);
+s->dsp.draw_edges(s->current_picture.f.data[1], s->uvlinesize,
+  s->h_edge_pos >> hshift, s->v_edge_pos >> vshift,
+  EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift,
+  EDGE_TOP | EDGE_BOTTOM);
+s->dsp.draw_edges(s->current_picture.f.data[2], s->uvlinesize,
+  s->h_edge_pos >> hshift, s->v_edge_pos >> vshift,
+  EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift,
+  EDGE_TOP | EDGE_BOTTOM);
+}
+
+emms_c();
+
+s->last_pict_type = s->pict_type;
+s->last_lambda_for [s->pict_type] = s->current_picture_ptr->f.quality;
+if (s->pict_type!= AV_PICTURE_TYPE_B)
+s->last_non_b_pict_type = s->pict_type;
+
+if (s->encoding) {
+/* release non-reference frames */
+for (i = 0; i < MAX_PICTURE_COUNT; i++) {
+if (!s->picture[i].reference)
+ff_mpeg_unref_picture(s, &s->picture[i]);
+}
+}
+
+s->avctx->coded_frame = &s->current_picture_ptr->f;
+
+}
+
 int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
   const AVFrame *pic_arg, int *got_packet)
 {
@@ -1414,7 +1457,7 @@ vbv_retry:
 avctx->p_count = s->mb_num - s->i_count - s->skip_count;
 avctx->skip_count  = s->skip_count;
 
-ff_MPV_frame_end(s);
+frame_end(s);
 
 if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
 ff_mjpeg_encode_picture_trailer(s);
-- 
1.7.10.4

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


[libav-devel] [PATCH 06/31] mpegvideo: don't copy input_picture_number in update_thread_context()

2013-12-02 Thread Anton Khirnov
It is encoding-only, frame threading is not used for encoding.
---
 libavcodec/mpegvideo.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 0bcf48b..0aa725b 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -683,7 +683,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
 
 s->coded_picture_number = s1->coded_picture_number;
 s->picture_number   = s1->picture_number;
-s->input_picture_number = s1->input_picture_number;
 
 for (i = 0; i < MAX_PICTURE_COUNT; i++) {
 ff_mpeg_unref_picture(s, &s->picture[i]);
-- 
1.7.10.4

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


[libav-devel] [PATCH 21/31] mjpegenc: remove commented out never-to-be-finished WIP cruft

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mjpegenc.c |   25 -
 1 file changed, 25 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index d67afe2..0322f8b 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -37,11 +37,6 @@
 #include "mjpeg.h"
 #include "mjpegenc.h"
 
-/* use two quantizer tables (one for luminance and one for chrominance) */
-/* not yet working */
-#undef TWOMATRIXES
-
-
 av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
 {
 MJpegContext *m;
@@ -109,25 +104,13 @@ static void jpeg_table_header(MpegEncContext *s)
 
 /* quant matrixes */
 put_marker(p, DQT);
-#ifdef TWOMATRIXES
-put_bits(p, 16, 2 + 2 * (1 + 64));
-#else
 put_bits(p, 16, 2 + 1 * (1 + 64));
-#endif
 put_bits(p, 4, 0); /* 8 bit precision */
 put_bits(p, 4, 0); /* table 0 */
 for(i=0;i<64;i++) {
 j = s->intra_scantable.permutated[i];
 put_bits(p, 8, s->intra_matrix[j]);
 }
-#ifdef TWOMATRIXES
-put_bits(p, 4, 0); /* 8 bit precision */
-put_bits(p, 4, 1); /* table 1 */
-for(i=0;i<64;i++) {
-j = s->intra_scantable.permutated[i];
-put_bits(p, 8, s->chroma_intra_matrix[j]);
-}
-#endif
 
 /* huffman table */
 put_marker(p, DHT);
@@ -224,21 +207,13 @@ void ff_mjpeg_encode_picture_header(MpegEncContext *s)
 put_bits(&s->pb, 8, 2); /* component number */
 put_bits(&s->pb, 4, s->mjpeg_hsample[1]); /* H factor */
 put_bits(&s->pb, 4, s->mjpeg_vsample[1]); /* V factor */
-#ifdef TWOMATRIXES
-put_bits(&s->pb, 8, lossless ? 0 : 1); /* select matrix */
-#else
 put_bits(&s->pb, 8, 0); /* select matrix */
-#endif
 
 /* Cr component */
 put_bits(&s->pb, 8, 3); /* component number */
 put_bits(&s->pb, 4, s->mjpeg_hsample[2]); /* H factor */
 put_bits(&s->pb, 4, s->mjpeg_vsample[2]); /* V factor */
-#ifdef TWOMATRIXES
-put_bits(&s->pb, 8, lossless ? 0 : 1); /* select matrix */
-#else
 put_bits(&s->pb, 8, 0); /* select matrix */
-#endif
 
 /* scan header */
 put_marker(&s->pb, SOS);
-- 
1.7.10.4

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


[libav-devel] [PATCH 16/31] FATE: drop the last partial frame in the wmv8-drm test

2013-12-02 Thread Anton Khirnov
This has already been done in eb066a4ce9e82cddb8f5af574804aa9889450b34,
but the number of frames produced from that file changed due to
timestamps changes since then.
---
 tests/fate/microsoft.mak |2 +-
 tests/ref/fate/wmv8-drm  |1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/fate/microsoft.mak b/tests/fate/microsoft.mak
index b8298ea..195fd3b 100644
--- a/tests/fate/microsoft.mak
+++ b/tests/fate/microsoft.mak
@@ -12,7 +12,7 @@ fate-msvideo1: $(FATE_MSVIDEO1)
 
 FATE_WMV8_DRM += fate-wmv8-drm
 # discard last packet to avoid fails due to overread of VC-1 decoder
-fate-wmv8-drm: CMD = framecrc -cryptokey 
137381538c84c068111902a59c5cf6c340247c39 -i $(TARGET_SAMPLES)/wmv8/wmv_drm.wmv 
-an -vframes 162
+fate-wmv8-drm: CMD = framecrc -cryptokey 
137381538c84c068111902a59c5cf6c340247c39 -i $(TARGET_SAMPLES)/wmv8/wmv_drm.wmv 
-an -frames:v 129
 
 FATE_WMV8_DRM += fate-wmv8-drm-nodec
 fate-wmv8-drm-nodec: CMD = framecrc -cryptokey 
137381538c84c068111902a59c5cf6c340247c39 -i $(TARGET_SAMPLES)/wmv8/wmv_drm.wmv 
-acodec copy -vcodec copy
diff --git a/tests/ref/fate/wmv8-drm b/tests/ref/fate/wmv8-drm
index c2a6dd5..7f4b523 100644
--- a/tests/ref/fate/wmv8-drm
+++ b/tests/ref/fate/wmv8-drm
@@ -128,4 +128,3 @@
 0,   ,   ,0,84480, 0x13962590
 0,   6708,   6708,0,84480, 0xde79482f
 0,   6750,   6750,0,84480, 0x7d1ca064
-0,   6791,   6791,0,84480, 0x2676a064
-- 
1.7.10.4

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


[libav-devel] [PATCH 13/31] mpegvideo: make frame_size_alloc() static.

2013-12-02 Thread Anton Khirnov
It is not called from outside of mpegvideo.c anymore.
---
 libavcodec/mpegvideo.c |8 
 libavcodec/mpegvideo.h |1 -
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 6bbe7d3..ed740d4 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -191,7 +191,7 @@ av_cold int ff_dct_common_init(MpegEncContext *s)
 return 0;
 }
 
-int ff_mpv_frame_size_alloc(MpegEncContext *s, int linesize)
+static int frame_size_alloc(MpegEncContext *s, int linesize)
 {
 int alloc_size = FFALIGN(FFABS(linesize) + 32, 32);
 
@@ -270,7 +270,7 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture 
*pic)
 }
 
 if (!s->edge_emu_buffer &&
-(ret = ff_mpv_frame_size_alloc(s, pic->f.linesize[0])) < 0) {
+(ret = frame_size_alloc(s, pic->f.linesize[0])) < 0) {
 av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed to allocate context scratch buffers.\n");
 ff_mpeg_unref_picture(s, pic);
@@ -636,7 +636,7 @@ int ff_update_duplicate_context(MpegEncContext *dst, 
MpegEncContext *src)
 if (dst->avctx->codec_tag == AV_RL32("VCR2"))
 exchange_uv(dst);
 if (!dst->edge_emu_buffer &&
-(ret = ff_mpv_frame_size_alloc(dst, dst->linesize)) < 0) {
+(ret = frame_size_alloc(dst, dst->linesize)) < 0) {
 av_log(dst->avctx, AV_LOG_ERROR, "failed to allocate context "
"scratch buffers.\n");
 return ret;
@@ -743,7 +743,7 @@ do {\
 // linesize dependend scratch buffer allocation
 if (!s->edge_emu_buffer)
 if (s1->linesize) {
-if (ff_mpv_frame_size_alloc(s, s1->linesize) < 0) {
+if (frame_size_alloc(s, s1->linesize) < 0) {
 av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate context "
"scratch buffers.\n");
 return AVERROR(ENOMEM);
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 9f723ea..f342948 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -771,7 +771,6 @@ void ff_MPV_common_defaults(MpegEncContext *s);
 
 void ff_MPV_decode_defaults(MpegEncContext *s);
 int ff_MPV_common_init(MpegEncContext *s);
-int ff_mpv_frame_size_alloc(MpegEncContext *s, int linesize);
 int ff_MPV_common_frame_size_change(MpegEncContext *s);
 void ff_MPV_common_end(MpegEncContext *s);
 void ff_MPV_decode_mb(MpegEncContext *s, int16_t block[12][64]);
-- 
1.7.10.4

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


[libav-devel] [PATCH 20/31] mjpegenc: do not pass MpegEncContext to put_huffman_table()

2013-12-02 Thread Anton Khirnov
It only needs PutBitContext from it, so pass that directly.
---
 libavcodec/mjpegenc.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index c92be63..d67afe2 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -81,10 +81,9 @@ void ff_mjpeg_encode_close(MpegEncContext *s)
 }
 
 /* table_class: 0 = DC coef, 1 = AC coefs */
-static int put_huffman_table(MpegEncContext *s, int table_class, int table_id,
+static int put_huffman_table(PutBitContext *p, int table_class, int table_id,
  const uint8_t *bits_table, const uint8_t 
*value_table)
 {
-PutBitContext *p = &s->pb;
 int n, i;
 
 put_bits(p, 4, table_class);
@@ -136,14 +135,14 @@ static void jpeg_table_header(MpegEncContext *s)
 ptr = put_bits_ptr(p);
 put_bits(p, 16, 0); /* patched later */
 size = 2;
-size += put_huffman_table(s, 0, 0, avpriv_mjpeg_bits_dc_luminance,
+size += put_huffman_table(p, 0, 0, avpriv_mjpeg_bits_dc_luminance,
   avpriv_mjpeg_val_dc);
-size += put_huffman_table(s, 0, 1, avpriv_mjpeg_bits_dc_chrominance,
+size += put_huffman_table(p, 0, 1, avpriv_mjpeg_bits_dc_chrominance,
   avpriv_mjpeg_val_dc);
 
-size += put_huffman_table(s, 1, 0, avpriv_mjpeg_bits_ac_luminance,
+size += put_huffman_table(p, 1, 0, avpriv_mjpeg_bits_ac_luminance,
   avpriv_mjpeg_val_ac_luminance);
-size += put_huffman_table(s, 1, 1, avpriv_mjpeg_bits_ac_chrominance,
+size += put_huffman_table(p, 1, 1, avpriv_mjpeg_bits_ac_chrominance,
   avpriv_mjpeg_val_ac_chrominance);
 AV_WB16(ptr, size);
 }
-- 
1.7.10.4

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


[libav-devel] [PATCH 23/31] mjpegenc: do not pass MpegEncContext to ff_mjpeg_encode_picture_header()

2013-12-02 Thread Anton Khirnov
This will allow deMpegEncContextizing the LJPEG encoder.
---
 libavcodec/ljpegenc.c  |3 +-
 libavcodec/mjpegenc.c  |  111 ++--
 libavcodec/mjpegenc.h  |4 +-
 libavcodec/mpegvideo_enc.c |3 +-
 4 files changed, 74 insertions(+), 47 deletions(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 4b13239..d94cfbf 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -70,7 +70,8 @@ static int encode_picture_lossless(AVCodecContext *avctx, 
AVPacket *pkt,
 p->pict_type= AV_PICTURE_TYPE_I;
 p->key_frame= 1;
 
-ff_mjpeg_encode_picture_header(s);
+ff_mjpeg_encode_picture_header(avctx, &s->pb, &s->intra_scantable,
+   s->intra_matrix);
 
 s->header_bits= put_bits_count(&s->pb);
 
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 7b54e50..1d69e67 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -32,6 +32,8 @@
 
 #include 
 
+#include "libavutil/pixdesc.h"
+
 #include "avcodec.h"
 #include "mpegvideo.h"
 #include "mjpeg.h"
@@ -172,78 +174,99 @@ static void jpeg_put_comments(AVCodecContext *avctx, 
PutBitContext *p)
 }
 }
 
-void ff_mjpeg_encode_picture_header(MpegEncContext *s)
+void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
+ScanTable *intra_scantable,
+uint16_t intra_matrix[64])
 {
-const int lossless= s->avctx->codec_id != AV_CODEC_ID_MJPEG;
+int chroma_h_shift, chroma_v_shift;
+const int lossless = avctx->codec_id != AV_CODEC_ID_MJPEG;
+int hsample[3], vsample[3];
+
+av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
+ &chroma_v_shift);
+
+if (avctx->codec->id == AV_CODEC_ID_LJPEG &&
+avctx->pix_fmt   == AV_PIX_FMT_BGRA) {
+vsample[0] = hsample[0] =
+vsample[1] = hsample[1] =
+vsample[2] = hsample[2] = 1;
+} else {
+vsample[0] = 2;
+vsample[1] = 2 >> chroma_v_shift;
+vsample[2] = 2 >> chroma_v_shift;
+hsample[0] = 2;
+hsample[1] = 2 >> chroma_h_shift;
+hsample[2] = 2 >> chroma_h_shift;
+}
 
-put_marker(&s->pb, SOI);
+put_marker(pb, SOI);
 
-jpeg_put_comments(s->avctx, &s->pb);
+jpeg_put_comments(avctx, pb);
 
-jpeg_table_header(&s->pb, &s->intra_scantable, s->intra_matrix);
+jpeg_table_header(pb, intra_scantable, intra_matrix);
 
-switch(s->avctx->codec_id){
-case AV_CODEC_ID_MJPEG:  put_marker(&s->pb, SOF0 ); break;
-case AV_CODEC_ID_LJPEG:  put_marker(&s->pb, SOF3 ); break;
+switch (avctx->codec_id) {
+case AV_CODEC_ID_MJPEG:  put_marker(pb, SOF0 ); break;
+case AV_CODEC_ID_LJPEG:  put_marker(pb, SOF3 ); break;
 default: assert(0);
 }
 
-put_bits(&s->pb, 16, 17);
-if(lossless && s->avctx->pix_fmt == AV_PIX_FMT_BGRA)
-put_bits(&s->pb, 8, 9); /* 9 bits/component RCT */
+put_bits(pb, 16, 17);
+if (lossless && avctx->pix_fmt == AV_PIX_FMT_BGRA)
+put_bits(pb, 8, 9); /* 9 bits/component RCT */
 else
-put_bits(&s->pb, 8, 8); /* 8 bits/component */
-put_bits(&s->pb, 16, s->height);
-put_bits(&s->pb, 16, s->width);
-put_bits(&s->pb, 8, 3); /* 3 components */
+put_bits(pb, 8, 8); /* 8 bits/component */
+put_bits(pb, 16, avctx->height);
+put_bits(pb, 16, avctx->width);
+put_bits(pb, 8, 3); /* 3 components */
 
 /* Y component */
-put_bits(&s->pb, 8, 1); /* component number */
-put_bits(&s->pb, 4, s->mjpeg_hsample[0]); /* H factor */
-put_bits(&s->pb, 4, s->mjpeg_vsample[0]); /* V factor */
-put_bits(&s->pb, 8, 0); /* select matrix */
+put_bits(pb, 8, 1); /* component number */
+put_bits(pb, 4, hsample[0]); /* H factor */
+put_bits(pb, 4, vsample[0]); /* V factor */
+put_bits(pb, 8, 0); /* select matrix */
 
 /* Cb component */
-put_bits(&s->pb, 8, 2); /* component number */
-put_bits(&s->pb, 4, s->mjpeg_hsample[1]); /* H factor */
-put_bits(&s->pb, 4, s->mjpeg_vsample[1]); /* V factor */
-put_bits(&s->pb, 8, 0); /* select matrix */
+put_bits(pb, 8, 2); /* component number */
+put_bits(pb, 4, hsample[1]); /* H factor */
+put_bits(pb, 4, vsample[1]); /* V factor */
+put_bits(pb, 8, 0); /* select matrix */
 
 /* Cr component */
-put_bits(&s->pb, 8, 3); /* component number */
-put_bits(&s->pb, 4, s->mjpeg_hsample[2]); /* H factor */
-put_bits(&s->pb, 4, s->mjpeg_vsample[2]); /* V factor */
-put_bits(&s->pb, 8, 0); /* select matrix */
+put_bits(pb, 8, 3); /* component number */
+put_bits(pb, 4, hsample[2]); /* H factor */
+put_bits(pb, 4, vsample[2]); /* V factor */
+put_bits(pb, 8, 0); /* select matrix */
 
 /* scan header */
-put_marker(&s->pb, SOS);
-put_bits(&s->pb, 16, 12); /* length */
-put_bits(&s->pb, 8, 3); /* 3 components */
+

[libav-devel] [PATCH 04/31] mpeg4videodec: move intra_dc_threshold from MpegEncContext to Mpeg4DecContext

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mpeg4video.h|2 ++
 libavcodec/mpeg4videodec.c |8 
 libavcodec/mpegvideo.h |1 -
 libavcodec/vaapi_mpeg4.c   |4 ++--
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
index 4e43186..9e1c8d9 100644
--- a/libavcodec/mpeg4video.h
+++ b/libavcodec/mpeg4video.h
@@ -84,6 +84,8 @@ typedef struct Mpeg4DecContext {
 int enhancement_type;
 int scalability;
 int use_intra_dc_vlc;
+///< QP above whch the ac VLC should be used for intra dc
+int intra_dc_threshold;
 
 /* bug workarounds */
 int divx_version;
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index c45bb5f..270cc04 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1179,7 +1179,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, 
int16_t block[6][64])
 mb_type = s->current_picture.mb_type[xy];
 cbp = s->cbp_table[xy];
 
-ctx->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
+ctx->use_intra_dc_vlc = s->qscale < ctx->intra_dc_threshold;
 
 if (s->current_picture.qscale_table[xy] != s->qscale)
 ff_set_qscale(s, s->current_picture.qscale_table[xy]);
@@ -1577,7 +1577,7 @@ intra:
 }
 cbp = (cbpc & 3) | (cbpy << 2);
 
-ctx->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
+ctx->use_intra_dc_vlc = s->qscale < ctx->intra_dc_threshold;
 
 if (dquant)
 ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
@@ -2180,7 +2180,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, 
GetBitContext *gb)
 if (s->pict_type == AV_PICTURE_TYPE_B)
 skip_bits_long(gb, ctx->cplx_estimation_trash_b);
 
-s->intra_dc_threshold = ff_mpeg4_dc_threshold[get_bits(gb, 3)];
+ctx->intra_dc_threshold = ff_mpeg4_dc_threshold[get_bits(gb, 3)];
 if (!s->progressive_sequence) {
 s->top_field_first = get_bits1(gb);
 s->alternate_scan  = get_bits1(gb);
@@ -2245,7 +2245,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, 
GetBitContext *gb)
s->data_partitioning, ctx->resync_marker,
ctx->num_sprite_warping_points, s->sprite_warping_accuracy,
1 - s->no_rounding, s->vo_type,
-   s->vol_control_parameters ? " VOLC" : " ", 
s->intra_dc_threshold,
+   s->vol_control_parameters ? " VOLC" : " ", 
ctx->intra_dc_threshold,
ctx->cplx_estimation_trash_i, ctx->cplx_estimation_trash_p,
ctx->cplx_estimation_trash_b);
 }
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 6db4145..a35d41b 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -591,7 +591,6 @@ typedef struct MpegEncContext {
 int low_delay;   ///< no reordering needed / has no 
b-frames
 int vo_type;
 int vol_control_parameters;  ///< does the stream contain the 
low_delay flag, used to workaround buggy encoders
-int intra_dc_threshold;  ///< QP above whch the ac VLC should be 
used for intra dc
 PutBitContext tex_pb;///< used for data partitioned VOPs
 PutBitContext pb2;   ///< used for data partitioned VOPs
 int mpeg_quant;
diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c
index f5298d1..b771482 100644
--- a/libavcodec/vaapi_mpeg4.c
+++ b/libavcodec/vaapi_mpeg4.c
@@ -25,7 +25,7 @@
 #include "mpeg4video.h"
 
 /** Reconstruct bitstream intra_dc_vlc_thr */
-static int mpeg4_get_intra_dc_vlc_thr(MpegEncContext *s)
+static int mpeg4_get_intra_dc_vlc_thr(Mpeg4DecContext *s)
 {
 switch (s->intra_dc_threshold) {
 case 99: return 0;
@@ -83,7 +83,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, 
av_unused const uint8_
 pic_param->vop_fields.bits.vop_coding_type  = s->pict_type - 
AV_PICTURE_TYPE_I;
 pic_param->vop_fields.bits.backward_reference_vop_coding_type = 
s->pict_type == AV_PICTURE_TYPE_B ? s->next_picture.f.pict_type - 
AV_PICTURE_TYPE_I : 0;
 pic_param->vop_fields.bits.vop_rounding_type= s->no_rounding;
-pic_param->vop_fields.bits.intra_dc_vlc_thr = 
mpeg4_get_intra_dc_vlc_thr(s);
+pic_param->vop_fields.bits.intra_dc_vlc_thr = 
mpeg4_get_intra_dc_vlc_thr(ctx);
 pic_param->vop_fields.bits.top_field_first  = s->top_field_first;
 pic_param->vop_fields.bits.alternate_vertical_scan_flag = 
s->alternate_scan;
 pic_param->vop_fcode_forward= s->f_code;
-- 
1.7.10.4

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


[libav-devel] [PATCH 25/31] mjpegenc: do not pass MpegEncContext to ff_mjpeg_encode_dc()

2013-12-02 Thread Anton Khirnov
This will allow deMpegEncContextizing the LJPEG encoder.
---
 libavcodec/ljpegenc.c |   16 
 libavcodec/mjpegenc.c |   12 ++--
 libavcodec/mjpegenc.h |2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 46b51ab..1ca2d37 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -115,9 +115,9 @@ static int encode_picture_lossless(AVCodecContext *avctx, 
AVPacket *pkt,
 diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100;
 
 if(i==0)
-ff_mjpeg_encode_dc(s, diff, m->huff_size_dc_luminance, 
m->huff_code_dc_luminance); //FIXME ugly
+ff_mjpeg_encode_dc(&s->pb, diff, 
m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
 else
-ff_mjpeg_encode_dc(s, diff, 
m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
+ff_mjpeg_encode_dc(&s->pb, diff, 
m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
 }
 }
 }
@@ -158,9 +158,9 @@ static int encode_picture_lossless(AVCodecContext *avctx, 
AVPacket *pkt,
 }
 
 if(i==0)
-ff_mjpeg_encode_dc(s, *ptr - pred, 
m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
+ff_mjpeg_encode_dc(&s->pb, *ptr - pred, 
m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
 else
-ff_mjpeg_encode_dc(s, *ptr - pred, 
m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
+ff_mjpeg_encode_dc(&s->pb, *ptr - pred, 
m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
 }
 }
 }
@@ -170,19 +170,19 @@ static int encode_picture_lossless(AVCodecContext *avctx, 
AVPacket *pkt,
 int x, y, h, v, linesize;
 h = s->mjpeg_hsample[i];
 v = s->mjpeg_vsample[i];
-linesize= p->linesize[i];
+linesize = pict->linesize[i];
 
 for(y=0; ydata[i] + (linesize * (v * mb_y + y)) 
+ (h * mb_x + x); //FIXME optimize this crap
+ptr = pict->data[i] + (linesize * (v * mb_y + 
y)) + (h * mb_x + x); //FIXME optimize this crap
 PREDICT(pred, ptr[-linesize-1], 
ptr[-linesize], ptr[-1], predictor);
 
 if(i==0)
-ff_mjpeg_encode_dc(s, *ptr - pred, 
m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
+ff_mjpeg_encode_dc(&s->pb, *ptr - pred, 
m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
 else
-ff_mjpeg_encode_dc(s, *ptr - pred, 
m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
+ff_mjpeg_encode_dc(&s->pb, *ptr - pred, 
m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
 }
 }
 }
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index f5c70f9..054cc66 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -340,13 +340,13 @@ void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, 
int header_bits)
 put_marker(pb, EOI);
 }
 
-void ff_mjpeg_encode_dc(MpegEncContext *s, int val,
+void ff_mjpeg_encode_dc(PutBitContext *pb, int val,
 uint8_t *huff_size, uint16_t *huff_code)
 {
 int mant, nbits;
 
 if (val == 0) {
-put_bits(&s->pb, huff_size[0], huff_code[0]);
+put_bits(pb, huff_size[0], huff_code[0]);
 } else {
 mant = val;
 if (val < 0) {
@@ -356,9 +356,9 @@ void ff_mjpeg_encode_dc(MpegEncContext *s, int val,
 
 nbits= av_log2_16bit(val) + 1;
 
-put_bits(&s->pb, huff_size[nbits], huff_code[nbits]);
+put_bits(pb, huff_size[nbits], huff_code[nbits]);
 
-put_sbits(&s->pb, nbits, mant);
+put_sbits(pb, nbits, mant);
 }
 }
 
@@ -375,11 +375,11 @@ static void encode_block(MpegEncContext *s, int16_t 
*block, int n)
 dc = block[0]; /* overflow is impossible */
 val = dc - s->last_dc[component];
 if (n < 4) {
-ff_mjpeg_encode_dc(s, val, m->huff_size_dc_luminance, 
m->huff_code_dc_luminance);
+ff_mjpeg_encode_dc(&s->pb, val, m->huff_size_dc_luminance, 
m->huff_code_dc_luminance);
 huff_size_ac = m->huff_size_ac_luminance;
 huff_code_ac = m->huff_code_ac_luminance;
 } else {
-ff_mjpeg_encode_dc(s, val, m->huff_size_dc_chrominance, 
m->huff_code_dc_chrominance);
+ff_mj

[libav-devel] [PATCH 12/31] mpegvideo: move encode-only parts of common_end() to encode_end()

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mpegvideo.c |   31 +--
 libavcodec/mpegvideo.h |1 +
 libavcodec/mpegvideo_enc.c |   14 ++
 3 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 88a0abf..6bbe7d3 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -280,7 +280,7 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture 
*pic)
 return 0;
 }
 
-static void free_picture_tables(Picture *pic)
+void ff_free_picture_tables(Picture *pic)
 {
 int i;
 
@@ -409,7 +409,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int 
shared)
 fail:
 av_log(s->avctx, AV_LOG_ERROR, "Error allocating a picture.\n");
 ff_mpeg_unref_picture(s, pic);
-free_picture_tables(pic);
+ff_free_picture_tables(pic);
 return AVERROR(ENOMEM);
 }
 
@@ -433,7 +433,7 @@ void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic)
 av_buffer_unref(&pic->hwaccel_priv_buf);
 
 if (pic->needs_realloc)
-free_picture_tables(pic);
+ff_free_picture_tables(pic);
 
 memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
 }
@@ -449,7 +449,7 @@ do {\
 av_buffer_unref(&dst->table);\
 dst->table = av_buffer_ref(src->table);\
 if (!dst->table) {\
-free_picture_tables(dst);\
+ff_free_picture_tables(dst);\
 return AVERROR(ENOMEM);\
 }\
 }\
@@ -1233,32 +1233,19 @@ void ff_MPV_common_end(MpegEncContext *s)
 av_freep(&s->bitstream_buffer);
 s->allocated_bitstream_buffer_size = 0;
 
-av_freep(&s->avctx->stats_out);
-av_freep(&s->ac_stats);
-
-av_freep(&s->q_intra_matrix);
-av_freep(&s->q_inter_matrix);
-av_freep(&s->q_intra_matrix16);
-av_freep(&s->q_inter_matrix16);
-av_freep(&s->input_picture);
-av_freep(&s->reordered_input_picture);
-av_freep(&s->dct_offset);
-
 if (s->picture) {
 for (i = 0; i < MAX_PICTURE_COUNT; i++) {
-free_picture_tables(&s->picture[i]);
+ff_free_picture_tables(&s->picture[i]);
 ff_mpeg_unref_picture(s, &s->picture[i]);
 }
 }
 av_freep(&s->picture);
-free_picture_tables(&s->last_picture);
+ff_free_picture_tables(&s->last_picture);
 ff_mpeg_unref_picture(s, &s->last_picture);
-free_picture_tables(&s->current_picture);
+ff_free_picture_tables(&s->current_picture);
 ff_mpeg_unref_picture(s, &s->current_picture);
-free_picture_tables(&s->next_picture);
+ff_free_picture_tables(&s->next_picture);
 ff_mpeg_unref_picture(s, &s->next_picture);
-free_picture_tables(&s->new_picture);
-ff_mpeg_unref_picture(s, &s->new_picture);
 
 free_context_frame(s);
 
@@ -1317,7 +1304,7 @@ int ff_find_unused_picture(MpegEncContext *s, int shared)
 if (ret >= 0 && ret < MAX_PICTURE_COUNT) {
 if (s->picture[ret].needs_realloc) {
 s->picture[ret].needs_realloc = 0;
-free_picture_tables(&s->picture[ret]);
+ff_free_picture_tables(&s->picture[ret]);
 ff_mpeg_unref_picture(s, &s->picture[ret]);
 avcodec_get_frame_defaults(&s->picture[ret].f);
 }
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index a140c15..9f723ea 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -926,5 +926,6 @@ void ff_wmv2_encode_mb(MpegEncContext * s,
 
 int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src);
 void ff_mpeg_unref_picture(MpegEncContext *s, Picture *picture);
+void ff_free_picture_tables(Picture *pic);
 
 #endif /* AVCODEC_MPEGVIDEO_H */
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 258bfcf..981bf6b 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -847,6 +847,20 @@ av_cold int ff_MPV_encode_end(AVCodecContext *avctx)
 for (i = 0; i < FF_ARRAY_ELEMS(s->tmp_frames); i++)
 av_frame_free(&s->tmp_frames[i]);
 
+ff_free_picture_tables(&s->new_picture);
+ff_mpeg_unref_picture(s, &s->new_picture);
+
+av_freep(&s->avctx->stats_out);
+av_freep(&s->ac_stats);
+
+av_freep(&s->q_intra_matrix);
+av_freep(&s->q_inter_matrix);
+av_freep(&s->q_intra_matrix16);
+av_freep(&s->q_inter_matrix16);
+av_freep(&s->input_picture);
+av_freep(&s->reordered_input_picture);
+av_freep(&s->dct_offset);
+
 return 0;
 }
 
-- 
1.7.10.4

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


[libav-devel] [PATCH 03/31] mpeg12dec: move first_slice from MpegEncContext to Mpeg1Context

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mpeg12dec.c |7 ---
 libavcodec/mpegvideo.h |1 -
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 9d0c3be..cc65283 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -52,6 +52,7 @@ typedef struct Mpeg1Context {
 AVRational frame_rate_ext;   ///< MPEG-2 specific framerate modificator
 int sync;///< Did we reach a sync point like a 
GOP/SEQ/KEYFrame?
 int closed_gop;  ///< GOP is closed
+int first_slice;
 int extradata_decoded;
 } Mpeg1Context;
 
@@ -2243,7 +2244,7 @@ static int decode_chunks(AVCodecContext *avctx,
 /* we have a complete image: we try to decompress it */
 if (mpeg1_decode_picture(avctx, buf_ptr, input_size) < 0)
 s2->pict_type = 0;
-s2->first_slice = 1;
+s->first_slice = 1;
 last_code = PICTURE_START_CODE;
 } else {
 av_log(avctx, AV_LOG_ERROR, "ignoring pic after %X\n", 
last_code);
@@ -2353,9 +2354,9 @@ static int decode_chunks(AVCodecContext *avctx,
 break;
 }
 
-if (s2->first_slice) {
+if (s->first_slice) {
 skip_frame = 0;
-s2->first_slice = 0;
+s->first_slice = 0;
 if (mpeg_field_start(s2, buf, buf_size) < 0)
 return -1;
 }
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 3d531b8..6db4145 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -667,7 +667,6 @@ typedef struct MpegEncContext {
 int progressive_frame;
 int full_pel[2];
 int interlaced_dct;
-int first_slice;
 int first_field; ///< is 1 for the first field of a field picture 
0 otherwise
 int drop_frame_timecode; ///< timecode is in drop frame format.
 int scan_offset; ///< reserve space for SVCD scan offset user data.
-- 
1.7.10.4

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


[libav-devel] [PATCH 22/31] mjpegenc: do not pass MpegEncContext to jpeg_table_header()

2013-12-02 Thread Anton Khirnov
Pass the three needed fields from it directly.
This will allow to deMpegEncContextize the LJpegEncoder.
---
 libavcodec/mjpegenc.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 0322f8b..7b54e50 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -96,9 +96,9 @@ static int put_huffman_table(PutBitContext *p, int 
table_class, int table_id,
 return n + 17;
 }
 
-static void jpeg_table_header(MpegEncContext *s)
+static void jpeg_table_header(PutBitContext *p, ScanTable *intra_scantable,
+  uint16_t intra_matrix[64])
 {
-PutBitContext *p = &s->pb;
 int i, j, size;
 uint8_t *ptr;
 
@@ -108,8 +108,8 @@ static void jpeg_table_header(MpegEncContext *s)
 put_bits(p, 4, 0); /* 8 bit precision */
 put_bits(p, 4, 0); /* table 0 */
 for(i=0;i<64;i++) {
-j = s->intra_scantable.permutated[i];
-put_bits(p, 8, s->intra_matrix[j]);
+j = intra_scantable->permutated[i];
+put_bits(p, 8, intra_matrix[j]);
 }
 
 /* huffman table */
@@ -180,7 +180,7 @@ void ff_mjpeg_encode_picture_header(MpegEncContext *s)
 
 jpeg_put_comments(s->avctx, &s->pb);
 
-jpeg_table_header(s);
+jpeg_table_header(&s->pb, &s->intra_scantable, s->intra_matrix);
 
 switch(s->avctx->codec_id){
 case AV_CODEC_ID_MJPEG:  put_marker(&s->pb, SOF0 ); break;
-- 
1.7.10.4

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


[libav-devel] [PATCH 08/31] mpegvideo: move encoding-only initialization from common_init() to encode_init()

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mpegvideo.c |   31 ---
 libavcodec/mpegvideo_enc.c |   26 ++
 2 files changed, 26 insertions(+), 31 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 541b8ed..0c7b9cf 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1037,37 +1037,6 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
 
 s->stream_codec_tag   = avpriv_toupper4(s->avctx->stream_codec_tag);
 
-if (s->width && s->height) {
-s->avctx->coded_frame = &s->current_picture.f;
-
-if (s->encoding) {
-if (s->msmpeg4_version) {
-FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,
-  2 * 2 * (MAX_LEVEL + 1) *
-  (MAX_RUN + 1) * 2 * sizeof(int), fail);
-}
-FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
-
-FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix,
-  64 * 32   * sizeof(int), fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix,
-  64 * 32   * sizeof(int), fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16,
-  64 * 32 * 2 * sizeof(uint16_t), fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16,
-  64 * 32 * 2 * sizeof(uint16_t), fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture,
-  MAX_PICTURE_COUNT * sizeof(Picture *), fail);
-FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,
-  MAX_PICTURE_COUNT * sizeof(Picture *), fail);
-
-if (s->avctx->noise_reduction) {
-FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,
-  2 * 64 * sizeof(uint16_t), fail);
-}
-}
-}
-
 FF_ALLOCZ_OR_GOTO(s->avctx, s->picture,
   MAX_PICTURE_COUNT * sizeof(Picture), fail);
 for (i = 0; i < MAX_PICTURE_COUNT; i++) {
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index bacec72..470418a 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -716,6 +716,29 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
 if (ARCH_X86)
 ff_MPV_encode_init_x86(s);
 
+s->avctx->coded_frame = &s->current_picture.f;
+
+if (s->msmpeg4_version) {
+FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,
+  2 * 2 * (MAX_LEVEL + 1) *
+  (MAX_RUN + 1) * 2 * sizeof(int), fail);
+}
+FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
+
+FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix,   64 * 32 * sizeof(int), 
fail);
+FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix,   64 * 32 * sizeof(int), 
fail);
+FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2 * 
sizeof(uint16_t), fail);
+FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2 * 
sizeof(uint16_t), fail);
+FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture,
+  MAX_PICTURE_COUNT * sizeof(Picture *), fail);
+FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,
+  MAX_PICTURE_COUNT * sizeof(Picture *), fail);
+
+if (s->avctx->noise_reduction) {
+FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,
+  2 * 64 * sizeof(uint16_t), fail);
+}
+
 ff_h263dsp_init(&s->h263dsp);
 if (!s->dct_quantize)
 s->dct_quantize = ff_dct_quantize_c;
@@ -802,6 +825,9 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
 }
 
 return 0;
+fail:
+ff_MPV_encode_end(avctx);
+return AVERROR_UNKNOWN;
 }
 
 av_cold int ff_MPV_encode_end(AVCodecContext *avctx)
-- 
1.7.10.4

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


[libav-devel] [PATCH 28/31] ljpegenc: rename the encoding function.

2013-12-02 Thread Anton Khirnov
The new name is more consistent with the rest of Libav.
---
 libavcodec/ljpegenc.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 13d52f5..4bb6bbf 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -57,8 +57,8 @@ typedef struct LJpegEncContext {
 uint16_t (*scratch)[4];
 } LJpegEncContext;
 
-static int encode_picture_lossless(AVCodecContext *avctx, AVPacket *pkt,
-   const AVFrame *pict, int *got_packet)
+static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+  const AVFrame *pict, int *got_packet)
 {
 LJpegEncContext *s = avctx->priv_data;
 PutBitContext pb;
@@ -289,7 +289,7 @@ AVCodec ff_ljpeg_encoder = {
 .id = AV_CODEC_ID_LJPEG,
 .priv_data_size = sizeof(LJpegEncContext),
 .init   = ljpeg_encode_init,
-.encode2= encode_picture_lossless,
+.encode2= ljpeg_encode_frame,
 .close  = ljpeg_encode_close,
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVJ420P,
 AV_PIX_FMT_YUVJ422P,
-- 
1.7.10.4

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


[libav-devel] [PATCH 15/31] vc1dec: move setting repeat_pict after frame_start() has been called.

2013-12-02 Thread Anton Khirnov
This will allow removing the hacks where each decoder sets
current_picture_ptr on its own.
---
 libavcodec/vc1dec.c |   24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 4a73d2c..ab4e098 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -5943,18 +5943,6 @@ static int vc1_decode_frame(AVCodecContext *avctx, void 
*data,
 goto err;
 }
 
-// process pulldown flags
-s->current_picture_ptr->f.repeat_pict = 0;
-// Pulldown flags are only valid when 'broadcast' has been set.
-// So ticks_per_frame will be 2
-if (v->rff) {
-// repeat field
-s->current_picture_ptr->f.repeat_pict = 1;
-} else if (v->rptfrm) {
-// repeat frames
-s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
-}
-
 // for skipping the frame
 s->current_picture.f.pict_type = s->pict_type;
 s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
@@ -5980,6 +5968,18 @@ static int vc1_decode_frame(AVCodecContext *avctx, void 
*data,
 goto err;
 }
 
+// process pulldown flags
+s->current_picture_ptr->f.repeat_pict = 0;
+// Pulldown flags are only valid when 'broadcast' has been set.
+// So ticks_per_frame will be 2
+if (v->rff) {
+// repeat field
+s->current_picture_ptr->f.repeat_pict = 1;
+} else if (v->rptfrm) {
+// repeat frames
+s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
+}
+
 s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
 s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
 
-- 
1.7.10.4

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


[libav-devel] [PATCH 19/31] mjpegenc: cosmetics, reformat jpeg_put_comments()

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mjpegenc.c |   29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index a22f340..c92be63 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -153,18 +153,17 @@ static void jpeg_put_comments(AVCodecContext *avctx, 
PutBitContext *p)
 int size;
 uint8_t *ptr;
 
-if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 
0)
-{
-/* JFIF header */
-put_marker(p, APP0);
-put_bits(p, 16, 16);
-avpriv_put_string(p, "JFIF", 1); /* this puts the trailing zero-byte too */
-put_bits(p, 16, 0x0201); /* v 1.02 */
-put_bits(p, 8, 0); /* units type: 0 - aspect ratio */
-put_bits(p, 16, avctx->sample_aspect_ratio.num);
-put_bits(p, 16, avctx->sample_aspect_ratio.den);
-put_bits(p, 8, 0); /* thumbnail width */
-put_bits(p, 8, 0); /* thumbnail height */
+if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 
0) {
+/* JFIF header */
+put_marker(p, APP0);
+put_bits(p, 16, 16);
+avpriv_put_string(p, "JFIF", 1); /* this puts the trailing zero-byte 
too */
+put_bits(p, 16, 0x0201); /* v 1.02 */
+put_bits(p,  8, 0);  /* units type: 0 - aspect ratio */
+put_bits(p, 16, avctx->sample_aspect_ratio.num);
+put_bits(p, 16, avctx->sample_aspect_ratio.den);
+put_bits(p, 8, 0); /* thumbnail width */
+put_bits(p, 8, 0); /* thumbnail height */
 }
 
 /* comment */
@@ -178,9 +177,9 @@ static void jpeg_put_comments(AVCodecContext *avctx, 
PutBitContext *p)
 AV_WB16(ptr, size);
 }
 
-if(  avctx->pix_fmt == AV_PIX_FMT_YUV420P
-   ||avctx->pix_fmt == AV_PIX_FMT_YUV422P
-   ||avctx->pix_fmt == AV_PIX_FMT_YUV444P){
+if (avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
+avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
+avctx->pix_fmt == AV_PIX_FMT_YUV444P) {
 put_marker(p, COM);
 flush_put_bits(p);
 ptr = put_bits_ptr(p);
-- 
1.7.10.4

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


[libav-devel] [PATCH 24/31] mjpegenc: do not pass MpegEncContext to ff_mjpeg_encode_picture_trailer()

2013-12-02 Thread Anton Khirnov
This will allow deMpegEncContextizing the LJPEG encoder.
---
 libavcodec/ljpegenc.c  |2 +-
 libavcodec/mjpegenc.c  |   22 +++---
 libavcodec/mjpegenc.h  |2 +-
 libavcodec/mpegvideo_enc.c |2 +-
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index d94cfbf..46b51ab 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -193,7 +193,7 @@ static int encode_picture_lossless(AVCodecContext *avctx, 
AVPacket *pkt,
 
 emms_c();
 
-ff_mjpeg_encode_picture_trailer(s);
+ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits);
 s->picture_number++;
 
 flush_put_bits(&s->pb);
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 1d69e67..f5c70f9 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -269,11 +269,11 @@ void ff_mjpeg_encode_picture_header(AVCodecContext 
*avctx, PutBitContext *pb,
 put_bits(pb, 8, 0); /* Ah/Al (not used) */
 }
 
-static void escape_FF(MpegEncContext *s, int start)
+static void escape_FF(PutBitContext *pb, int start)
 {
-int size= put_bits_count(&s->pb) - start*8;
+int size = put_bits_count(pb) - start * 8;
 int i, ff_count;
-uint8_t *buf= s->pb.buf + start;
+uint8_t *buf = pb->buf + start;
 int align= (-(size_t)(buf))&3;
 
 assert((size&7) == 0);
@@ -306,8 +306,8 @@ static void escape_FF(MpegEncContext *s, int start)
 
 if(ff_count==0) return;
 
-flush_put_bits(&s->pb);
-skip_put_bytes(&s->pb, ff_count);
+flush_put_bits(pb);
+skip_put_bytes(pb, ff_count);
 
 for(i=size-1; ff_count; i--){
 int v= buf[i];
@@ -328,16 +328,16 @@ void ff_mjpeg_encode_stuffing(PutBitContext * pbc)
 if(length) put_bits(pbc, length, (1pb);
+ff_mjpeg_encode_stuffing(pb);
+flush_put_bits(pb);
 
-assert((s->header_bits&7)==0);
+assert((header_bits & 7) == 0);
 
-escape_FF(s, s->header_bits>>3);
+escape_FF(pb, header_bits >> 3);
 
-put_marker(&s->pb, EOI);
+put_marker(pb, EOI);
 }
 
 void ff_mjpeg_encode_dc(MpegEncContext *s, int val,
diff --git a/libavcodec/mjpegenc.h b/libavcodec/mjpegenc.h
index 62085cd..81dd747 100644
--- a/libavcodec/mjpegenc.h
+++ b/libavcodec/mjpegenc.h
@@ -54,7 +54,7 @@ void ff_mjpeg_encode_close(MpegEncContext *s);
 void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
 ScanTable *intra_scantable,
 uint16_t intra_matrix[64]);
-void ff_mjpeg_encode_picture_trailer(MpegEncContext *s);
+void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
 void ff_mjpeg_encode_stuffing(PutBitContext *pbc);
 void ff_mjpeg_encode_dc(MpegEncContext *s, int val,
 uint8_t *huff_size, uint16_t *huff_code);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index f00eb29..4fbe10e 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1474,7 +1474,7 @@ vbv_retry:
 frame_end(s);
 
 if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
-ff_mjpeg_encode_picture_trailer(s);
+ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits);
 
 if (avctx->rc_buffer_size) {
 RateControlContext *rcc = &s->rc_context;
-- 
1.7.10.4

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


[libav-devel] [PATCH 14/31] mpegvideo: make ff_release_unused_pictures() static

2013-12-02 Thread Anton Khirnov
It is only called from one place in mpegvideo.c now. Also remove the
remove_current parameter, which is always 1.
---
 libavcodec/mpegvideo.c |8 +++-
 libavcodec/mpegvideo.h |1 -
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index ed740d4..5036e2a 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1256,16 +1256,14 @@ void ff_MPV_common_end(MpegEncContext *s)
 s->linesize = s->uvlinesize = 0;
 }
 
-void ff_release_unused_pictures(MpegEncContext*s, int remove_current)
+static void release_unused_pictures(MpegEncContext *s)
 {
 int i;
 
 /* release non reference frames */
 for (i = 0; i < MAX_PICTURE_COUNT; i++) {
-if (!s->picture[i].reference &&
-(remove_current || &s->picture[i] !=  s->current_picture_ptr)) {
+if (!s->picture[i].reference)
 ff_mpeg_unref_picture(s, &s->picture[i]);
-}
 }
 }
 
@@ -1368,7 +1366,7 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext 
*avctx)
 ff_mpeg_unref_picture(s, &s->current_picture);
 
 if (!s->encoding) {
-ff_release_unused_pictures(s, 1);
+release_unused_pictures(s);
 
 if (s->current_picture_ptr &&
 s->current_picture_ptr->f.buf[0] == NULL) {
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index f342948..e29527f 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -794,7 +794,6 @@ void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int 
h);
 void ff_mpeg_flush(AVCodecContext *avctx);
 void ff_print_debug_info(MpegEncContext *s, Picture *p);
 void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix);
-void ff_release_unused_pictures(MpegEncContext *s, int remove_current);
 int ff_find_unused_picture(MpegEncContext *s, int shared);
 void ff_denoise_dct(MpegEncContext *s, int16_t *block);
 int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src);
-- 
1.7.10.4

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


[libav-devel] [PATCH 02/31] mpegvideo: remove an unused variable

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mpegvideo.h |1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index b5e08ba..3d531b8 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -637,7 +637,6 @@ typedef struct MpegEncContext {
 /* Mpeg1 specific */
 int gop_picture_number;  ///< index of the first picture of a GOP based on 
fake_pic_num & mpeg1 specific
 int last_mv_dir; ///< last mv_dir, used for b frame encoding
-int broken_link; ///< no_output_of_prior_pics_flag
 uint8_t *vbv_delay_ptr;  ///< pointer to vbv_delay in the bitstream
 
 /* MPEG-2-specific - I wished not to have to support this mess. */
-- 
1.7.10.4

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


[libav-devel] [PATCH 17/31] mpegvideo: do not set current_picture_ptr in decoders

2013-12-02 Thread Anton Khirnov
This code was originally added in
5f1948111a4920ff74e31b4284ab0200f7938539 to h263 to set decoded frame
pts to some random numbers (removed in
a1c5cc429d99216406170eac7e8352860076d3e8) and then cargo culted to other
decoders.

The code is left in h263dec for now, since some part of the decoder
(apparrently OBMC) relies on the specific previous frame to be reused.
---
 libavcodec/h261dec.c |9 -
 libavcodec/mss2.c|7 ---
 libavcodec/vc1dec.c  |9 -
 3 files changed, 25 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 4842fa0..49eaee1 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -584,15 +584,6 @@ retry:
 if (ff_MPV_common_init(s) < 0)
 return -1;
 
-/* We need to set current_picture_ptr before reading the header,
- * otherwise we cannot store anything in there. */
-if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
-int i = ff_find_unused_picture(s, 0);
-if (i < 0)
-return i;
-s->current_picture_ptr = &s->picture[i];
-}
-
 ret = h261_decode_picture_header(h);
 
 /* skip if the header was thrashed */
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index d219b67..3fe8620 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -377,13 +377,6 @@ static int decode_wmv9(AVCodecContext *avctx, const 
uint8_t *buf, int buf_size,
 
 ff_mpeg_flush(avctx);
 
-if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
-int i = ff_find_unused_picture(s, 0);
-if (i < 0)
-return i;
-s->current_picture_ptr = &s->picture[i];
-}
-
 init_get_bits(&s->gb, buf, buf_size * 8);
 
 s->loop_filter = avctx->skip_loop_filter < AVDISCARD_ALL;
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index ab4e098..141969f 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -5914,15 +5914,6 @@ static int vc1_decode_frame(AVCodecContext *avctx, void 
*data,
 }
 }
 
-/* We need to set current_picture_ptr before reading the header,
- * otherwise we cannot store anything in there. */
-if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
-int i = ff_find_unused_picture(s, 0);
-if (i < 0)
-goto err;
-s->current_picture_ptr = &s->picture[i];
-}
-
 // do parse frame header
 v->pic_header_flag = 0;
 v->first_pic_header_flag = 1;
-- 
1.7.10.4

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


[libav-devel] [PATCH 01/31] mpeg4videodec: move use_intra_dc_vlc from MpegEncContext to Mpeg4DecContext

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mpeg4video.h|1 +
 libavcodec/mpeg4videodec.c |   17 +
 libavcodec/mpegvideo.h |1 -
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
index 63956a6..4e43186 100644
--- a/libavcodec/mpeg4video.h
+++ b/libavcodec/mpeg4video.h
@@ -83,6 +83,7 @@ typedef struct Mpeg4DecContext {
 int new_pred;
 int enhancement_type;
 int scalability;
+int use_intra_dc_vlc;
 
 /* bug workarounds */
 int divx_version;
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 5c79fb2..c45bb5f 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -925,9 +925,10 @@ int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx)
  * Decode a block.
  * @return <0 if an error occurred
  */
-static inline int mpeg4_decode_block(MpegEncContext *s, int16_t *block,
+static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
  int n, int coded, int intra, int rvlc)
 {
+MpegEncContext *s = &ctx->m;
 int level, i, last, run, qmul, qadd, dc_pred_dir;
 RLTable *rl;
 RL_VLC_ELEM *rl_vlc;
@@ -936,7 +937,7 @@ static inline int mpeg4_decode_block(MpegEncContext *s, 
int16_t *block,
 // Note intra & rvlc should be optimized away if this is inlined
 
 if (intra) {
-if (s->use_intra_dc_vlc) {
+if (ctx->use_intra_dc_vlc) {
 /* DC coef */
 if (s->partitioned_frame) {
 level = s->dc_val[0][s->block_index[n]];
@@ -1151,7 +1152,7 @@ static inline int mpeg4_decode_block(MpegEncContext *s, 
int16_t *block,
 
 not_coded:
 if (intra) {
-if (!s->use_intra_dc_vlc) {
+if (!ctx->use_intra_dc_vlc) {
 block[0] = ff_mpeg4_pred_dc(s, n, block[0], &dc_pred_dir, 0);
 
 i -= i >> 31;  // if (i == -1) i = 0;
@@ -1178,7 +1179,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, 
int16_t block[6][64])
 mb_type = s->current_picture.mb_type[xy];
 cbp = s->cbp_table[xy];
 
-s->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
+ctx->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
 
 if (s->current_picture.qscale_table[xy] != s->qscale)
 ff_set_qscale(s, s->current_picture.qscale_table[xy]);
@@ -1228,7 +1229,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, 
int16_t block[6][64])
 s->dsp.clear_blocks(s->block[0]);
 /* decode each block */
 for (i = 0; i < 6; i++) {
-if (mpeg4_decode_block(s, block[i], i, cbp & 32, s->mb_intra, 
ctx->rvlc) < 0) {
+if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, s->mb_intra, 
ctx->rvlc) < 0) {
 av_log(s->avctx, AV_LOG_ERROR,
"texture corrupted at %d %d %d\n",
s->mb_x, s->mb_y, s->mb_intra);
@@ -1576,7 +1577,7 @@ intra:
 }
 cbp = (cbpc & 3) | (cbpy << 2);
 
-s->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
+ctx->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
 
 if (dquant)
 ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
@@ -1587,7 +1588,7 @@ intra:
 s->dsp.clear_blocks(s->block[0]);
 /* decode each block */
 for (i = 0; i < 6; i++) {
-if (mpeg4_decode_block(s, block[i], i, cbp & 32, 1, 0) < 0)
+if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, 1, 0) < 0)
 return -1;
 cbp += cbp;
 }
@@ -1596,7 +1597,7 @@ intra:
 
 /* decode each block */
 for (i = 0; i < 6; i++) {
-if (mpeg4_decode_block(s, block[i], i, cbp & 32, 0, 0) < 0)
+if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, 0, 0) < 0)
 return -1;
 cbp += cbp;
 }
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 73c6611..b5e08ba 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -592,7 +592,6 @@ typedef struct MpegEncContext {
 int vo_type;
 int vol_control_parameters;  ///< does the stream contain the 
low_delay flag, used to workaround buggy encoders
 int intra_dc_threshold;  ///< QP above whch the ac VLC should be 
used for intra dc
-int use_intra_dc_vlc;
 PutBitContext tex_pb;///< used for data partitioned VOPs
 PutBitContext pb2;   ///< used for data partitioned VOPs
 int mpeg_quant;
-- 
1.7.10.4

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


[libav-devel] [PATCH 05/31] mpeg4videodec: move showed_packed_warning from MpegEncContext to Mpeg4DecContext

2013-12-02 Thread Anton Khirnov
---
 libavcodec/mpeg4video.h|2 ++
 libavcodec/mpeg4videodec.c |4 ++--
 libavcodec/mpegvideo.h |1 -
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
index 9e1c8d9..59358eb 100644
--- a/libavcodec/mpeg4video.h
+++ b/libavcodec/mpeg4video.h
@@ -92,6 +92,8 @@ typedef struct Mpeg4DecContext {
 int divx_build;
 int xvid_build;
 int lavc_build;
+///< flag for having shown the warning about divxs invalid b frames
+int showed_packed_warning;
 
 int cplx_estimation_trash_i;
 int cplx_estimation_trash_p;
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 270cc04..5eb8fd0 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -2016,10 +2016,10 @@ static int decode_user_data(Mpeg4DecContext *ctx, 
GetBitContext *gb)
 ctx->divx_version = ver;
 ctx->divx_build   = build;
 s->divx_packed  = e == 3 && last == 'p';
-if (s->divx_packed && !s->showed_packed_warning) {
+if (s->divx_packed && !ctx->showed_packed_warning) {
 av_log(s->avctx, AV_LOG_WARNING,
"Invalid and inefficient vfw-avi packed B frames 
detected\n");
-s->showed_packed_warning = 1;
+ctx->showed_packed_warning = 1;
 }
 }
 
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index a35d41b..a140c15 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -552,7 +552,6 @@ typedef struct MpegEncContext {
 /* H.263 specific */
 int gob_index;
 int obmc;   ///< overlapped block motion compensation
-int showed_packed_warning;  ///< flag for having shown the warning 
about divxs invalid b frames
 int mb_info;///< interval for outputting info about mb 
offsets as side data
 int prev_mb_info, last_mb_info;
 uint8_t *mb_info_ptr;
-- 
1.7.10.4

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


Re: [libav-devel] [PATCH] libvpx: don't mark VP9 as experimental when using libvpx >= 1.3.0

2013-12-02 Thread Luca Barbato
On 02/12/13 21:37, Guillaume Martres wrote:
> libvpx 1.3.0 has just been tagged so the patch should be testable now.

\o/

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

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


Re: [libav-devel] [PATCH v2] jack: use condition variable instead of semaphore

2013-12-02 Thread Tristan Matthews
On Sun, Dec 1, 2013 at 4:21 PM, Rémi Denis-Courmont  wrote:
> Le dimanche 1 décembre 2013, 16:15:22 Tristan Matthews a écrit :
>> jack_ringbuffers are used instead of AVFifoBuffers as they are safe for
>> lock-free use (in single-writer, single-reader scenarios).
>
> The use of condition variable without locked predicate/state makes as little
> sense (i.e. no) as in previous iterations IMO.

In this version, the process callback is locking the mutex before
signaling (with try_lock),
is that not adequate? In any case, even if the reader misses a signal
because it is not yet waiting on the condition variable, it will catch
the next one. Moreover,
it will only start waiting if it finds the ringbuffer to be empty.

I agree that using a semaphore is better (since you avoid the above
missed signal problem), but that's the whole issue with
https://bugzilla.libav.org/show_bug.cgi?id=312
Could someone clarify what exactly is wrong with Mac OS X semaphores?
I've only found this so far:
http://dev.alopix.net/2012/10/os-x-dont-trust-posix-certificate.html

in which case, could this be more simply resolved by using a named semaphore?

Best,
Tristan

-- 
Tristan Matthews
web: http://tristanswork.blogspot.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 3/5] configure: Move adding of compat objects out of libc detection

2013-12-02 Thread Diego Biurrun
---

This is required to (more easily) only set compat objects for the
target, not the host.

 configure | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index dfa8d9d..129b340 100755
--- a/configure
+++ b/configure
@@ -3395,10 +3395,6 @@ elif check_header _mingw.h; then
 add_cppflags -U__STRICT_ANSI__
 elif check_func_headers stdlib.h _get_doserrno; then
 libc_type=msvcrt
-add_compat strtod.o strtod=avpriv_strtod
-add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
- _snprintf=avpriv_snprintf  \
- vsnprintf=avpriv_vsnprintf
 # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
 # 0x601 by default unless something else is set by the user.
 # This can easily lead to us detecting functions only present
@@ -3410,11 +3406,22 @@ elif check_cpp_condition stddef.h "defined __KLIBC__"; 
then
 libc_type=klibc
 elif check_cpp_condition sys/cdefs.h "defined __BIONIC__"; then
 libc_type=bionic
-add_compat strtod.o strtod=avpriv_strtod
 fi
 
 test -n "$libc_type" && enable $libc_type
 
+case $libc_type in
+bionic)
+add_compat strtod.o strtod=avpriv_strtod
+;;
+msvcrt)
+add_compat strtod.o strtod=avpriv_strtod
+add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
+ _snprintf=avpriv_snprintf  \
+ vsnprintf=avpriv_vsnprintf
+;;
+esac
+
 # hacks for compiler/libc/os combinations
 
 if enabled_all tms470 glibc; then
-- 
1.8.3.2

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


[libav-devel] [v2] Split host and target libc detection

2013-12-02 Thread Diego Biurrun
This is maturing away from being purely RFC type stuff.
It needs a bunch of preliminaries, most of which are probably desirable
either way.  I'm fairly confident of the basic bits now.

This still fails on MSVC, as I did not add a host version of
check_func_headers().  Instead, we should switch the msvcrt test
over to some CPP condition, like we do for all other libcs.  The
test we currently have enables a bunch of variables, which would
generate unwanted sideeffects if it was done once for the target
and then for the host.  Splitting all of this properly is a lot
of work, instead, finding a CPP-based test for msvcrt should be
fairly simple.

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


[libav-devel] [PATCH 2/5] configure: Add host compiler to informative output

2013-12-02 Thread Diego Biurrun
---

This could be squashed with 1/5, it's fairly silly standalone.

 configure | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configure b/configure
index 9b3ec02..dfa8d9d 100755
--- a/configure
+++ b/configure
@@ -4141,6 +4141,9 @@ check_deps $CONFIG_LIST   \
 echo "install prefix$prefix"
 echo "source path   $source_path"
 echo "C compiler$cc"
+if test "$host_cc" != "$cc"; then
+echo "host C compiler   $host_cc"
+fi
 echo "C library $libc_type"
 echo "ARCH  $arch ($cpu)"
 if test "$build_suffix" != ""; then
-- 
1.8.3.2

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


[libav-devel] [PATCH 5/5] configure: Split host and target libc detection

2013-12-02 Thread Diego Biurrun
---

Still needs testing on a bunch of systems and crosscompiling scenarios.
Should work (TM) on everything but msvcrt though (see introductory mail).

 configure | 101 ++
 1 file changed, 69 insertions(+), 32 deletions(-)

diff --git a/configure b/configure
index 58a7e45..71b7190 100755
--- a/configure
+++ b/configure
@@ -1004,6 +1004,10 @@ require_pkg_config(){
 add_extralibs $(get_safe ${pkg}_libs)
 }
 
+hostcc_e(){
+eval printf '%s\\n' $HOSTCC_E
+}
+
 hostcc_o(){
 eval printf '%s\\n' $HOSTCC_O
 }
@@ -1015,6 +1019,13 @@ check_host_cc(){
 check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
 }
 
+check_host_cpp(){
+log check_host_cpp "$@"
+cat > $TMPC
+log_file $TMPC
+check_cmd $host_cc $HOSTCPPFLAGS $HOSTCFLAGS "$@" $(hostcc_e $TMPO) $TMPC
+}
+
 check_host_cppflags(){
 log check_host_cppflags "$@"
 check_host_cc "$@" <
+#if !($condition)
+#error "unsatisfied condition: $condition"
+#endif
+EOF
+}
+
 apply(){
 file=$1
 shift
@@ -2076,11 +2100,12 @@ LD_O='-o $@'
 LD_LIB='-l%'
 LD_PATH='-L'
 HOSTCC_C='-c'
+HOSTCC_E='-E -o $@'
 HOSTCC_O='-o $@'
 HOSTLD_O='-o $@'
 
 host_cflags='-O3 -g'
-host_cppflags='-D_ISOC99_SOURCE -D_XOPEN_SOURCE=600'
+host_cppflags='-D_ISOC99_SOURCE'
 host_libs='-lm'
 host_cflags_filter=echo
 host_ldflags_filter=echo
@@ -3375,40 +3400,49 @@ esac
 
 # determine libc flavour
 
-# uclibc defines __GLIBC__, so it needs to be checked before glibc.
-if check_cpp_condition features.h "defined __UCLIBC__"; then
-libc_type=uclibc
-add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
-elif check_cpp_condition features.h "defined __GLIBC__"; then
-libc_type=glibc
-add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
-# MinGW headers can be installed on Cygwin, so check for newlib first.
-elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
-libc_type=newlib
-add_cppflags -U__STRICT_ANSI__
-elif check_cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
-libc_type=mingw
-check_cpp_condition _mingw.h \
-"defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) || 
\
+probe_libc(){
+pfx=$1
+# uclibc defines __GLIBC__, so it needs to be checked before glibc.
+if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
+eval ${pfx}libc_type=uclibc
+add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
+elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
+eval ${pfx}libc_type=glibc
+add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
+# MinGW headers can be installed on Cygwin, so check for newlib first.
+elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
+eval ${pfx}libc_type=newlib
+add_${pfx}cppflags -U__STRICT_ANSI__
+elif check_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
+eval ${pfx}libc_type=mingw
+check_${pfx}cpp_condition _mingw.h \
+"defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 
3) || \
 (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
-die "ERROR: MinGW runtime version must be >= 3.15."
-add_cppflags -U__STRICT_ANSI__
-elif check_func_headers stdlib.h _get_doserrno; then
-libc_type=msvcrt
-# The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
-# 0x601 by default unless something else is set by the user.
-# This can easily lead to us detecting functions only present
-# in such new versions and producing binaries requiring windows 7.0.
-# Therefore explicitly set the default to XP unless the user has
-# set something else on the command line.
-check_cpp_condition stdlib.h "defined(_WIN32_WINNT)" || add_cppflags 
-D_WIN32_WINNT=0x0502
-elif check_cpp_condition stddef.h "defined __KLIBC__"; then
-libc_type=klibc
-elif check_cpp_condition sys/cdefs.h "defined __BIONIC__"; then
-libc_type=bionic
-fi
+die "ERROR: MinGW runtime version must be >= 3.15."
+add_${pfx}cppflags -U__STRICT_ANSI__
+elif check_${pfx}func_headers stdlib.h _get_doserrno; then
+eval ${pfx}libc_type=msvcrt
+# The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
+# 0x601 by default unless something else is set by the user.
+# This can easily lead to us detecting functions only present
+# in such new versions and producing binaries requiring windows 7.0.
+# Therefore explicitly set the default to XP unless the user has
+# set something else on the command line.
+check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
+add_${pfx}cppflags -D_WIN32_WINNT=0x0502
+elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
+eval ${pfx}libc_type=klibc
+elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; the

[libav-devel] [PATCH 4/5] configure: Check for a definition instead of a header for mingw libc

2013-12-02 Thread Diego Biurrun
This is more robust and does not interfere with host libc separation.
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 129b340..58a7e45 100755
--- a/configure
+++ b/configure
@@ -3386,7 +3386,7 @@ elif check_cpp_condition features.h "defined __GLIBC__"; 
then
 elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
 libc_type=newlib
 add_cppflags -U__STRICT_ANSI__
-elif check_header _mingw.h; then
+elif check_cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
 libc_type=mingw
 check_cpp_condition _mingw.h \
 "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) || 
\
-- 
1.8.3.2

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


[libav-devel] [PATCH 1/5] configure: Add detected C library to informative output

2013-12-02 Thread Diego Biurrun
---
 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index 832a54a..9b3ec02 100755
--- a/configure
+++ b/configure
@@ -4141,6 +4141,7 @@ check_deps $CONFIG_LIST   \
 echo "install prefix$prefix"
 echo "source path   $source_path"
 echo "C compiler$cc"
+echo "C library $libc_type"
 echo "ARCH  $arch ($cpu)"
 if test "$build_suffix" != ""; then
 echo "build suffix  $build_suffix"
-- 
1.8.3.2

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


Re: [libav-devel] [PATCH] libvpx: don't mark VP9 as experimental when using libvpx >= 1.3.0

2013-12-02 Thread Guillaume Martres
libvpx 1.3.0 has just been tagged so the patch should be testable now.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] Add a libwebp encoder

2013-12-02 Thread Pascal Massimino
Justin,


On Mon, Dec 2, 2013 at 4:26 PM, Justin Ruggles wrote:

> On 12/02/2013 09:39 AM, Pascal Massimino wrote:
>
>> Hi,
>>
>>
>> On Sun, Dec 1, 2013 at 11:04 PM, Justin Ruggles > >wrote:
>>
>> +av_image_copy(alt_frame->data, alt_frame->linesize,
>> +  frame->data, frame->linesize,
>>
>> FYI, i get a warning related to frame->data constness here:
>>
>> libavcodec/libwebpenc.c: In function ‘libwebp_encode_frame’:
>> libavcodec/libwebpenc.c:171:27: warning: passing argument 3 of
>> ‘av_image_copy’ from incompatible pointer type [enabled by default]
>> ./libavutil/imgutils.h:115:6: note: expected ‘const uint8_t **’ but
>> argument is of type ‘uint8_t * const*’
>>
>
> Yeah, this is safe though. av_image_copy() does not modify anything in the
> source.
>
>
>
>>
>> +  avctx->pix_fmt, frame->width, frame->height);
>>
>>> +frame = alt_frame;
>>> +}
>>> +pic->use_argb  = 0;
>>> +pic->y = frame->data[0];
>>> +pic->u = frame->data[1];
>>> +pic->v = frame->data[2];
>>> +pic->y_stride  = frame->linesize[0];
>>> +pic->uv_stride = frame->linesize[1];
>>> +if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) {
>>> +pic->colorspace = WEBP_YUV420A;
>>> +pic->a  = frame->data[3];
>>> +pic->a_stride   = frame->linesize[3];
>>> +} else {
>>> +pic->colorspace = WEBP_YUV420;
>>> +}
>>> +
>>> +if (s->lossless) {
>>>
>>>  normally, whole this block should be unnecessary. But, trying the
>> patch, i
>> realized
>> there's a bug in libwebp (uhttps://
>> code.google.com/p/webp/issues/detail?id=178)
>> that prevents automatic conversion as it should. Sorry about that, the
>> workaround
>> you have must have been puzzling to find.
>> I've got a fix (https://gerrit.chromium.org/gerrit/#/c/67969) but it's
>> going to be available
>> only in future versions. A temporary ugly fix can be:
>>
>> #if (WEBP_ENCODER_ABI_VERSION <= 0x201)
>>if (s->lossless) {   /* workaround issue #178 */
>>pic->memory_ = (void*)1;  /* something non-null */
>>if (!WebPPictureYUVAToARGB(pic)) goto end;
>>pic->memory_ = NULL;  /* restore pointer */
>>}
>> #endif
>>
>>
>> but that's pretty hacky. Your call.
>>
>> (PS: Otherwise, patch works ok!)
>>
>>
> That does look hacky, but it's definitely simpler. What does that do
> exactly,


it just safely works around a spurious, unwarranted test in
WebPPictureYUVAToARGB()

and do I still need to call WebPPictureFree(pic)
>

yep, nothing changes here.


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


Re: [libav-devel] [PATCH] Add a libwebp encoder

2013-12-02 Thread Justin Ruggles

On 12/02/2013 09:39 AM, Pascal Massimino wrote:

Hi,


On Sun, Dec 1, 2013 at 11:04 PM, Justin Ruggles wrote:

+av_image_copy(alt_frame->data, alt_frame->linesize,
+  frame->data, frame->linesize,

FYI, i get a warning related to frame->data constness here:

libavcodec/libwebpenc.c: In function ‘libwebp_encode_frame’:
libavcodec/libwebpenc.c:171:27: warning: passing argument 3 of
‘av_image_copy’ from incompatible pointer type [enabled by default]
./libavutil/imgutils.h:115:6: note: expected ‘const uint8_t **’ but
argument is of type ‘uint8_t * const*’


Yeah, this is safe though. av_image_copy() does not modify anything in 
the source.





+  avctx->pix_fmt, frame->width, frame->height);

+frame = alt_frame;
+}
+pic->use_argb  = 0;
+pic->y = frame->data[0];
+pic->u = frame->data[1];
+pic->v = frame->data[2];
+pic->y_stride  = frame->linesize[0];
+pic->uv_stride = frame->linesize[1];
+if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) {
+pic->colorspace = WEBP_YUV420A;
+pic->a  = frame->data[3];
+pic->a_stride   = frame->linesize[3];
+} else {
+pic->colorspace = WEBP_YUV420;
+}
+
+if (s->lossless) {


normally, whole this block should be unnecessary. But, trying the patch, i
realized
there's a bug in libwebp (uhttps://
code.google.com/p/webp/issues/detail?id=178)
that prevents automatic conversion as it should. Sorry about that, the
workaround
you have must have been puzzling to find.
I've got a fix (https://gerrit.chromium.org/gerrit/#/c/67969) but it's
going to be available
only in future versions. A temporary ugly fix can be:

#if (WEBP_ENCODER_ABI_VERSION <= 0x201)
   if (s->lossless) {   /* workaround issue #178 */
   pic->memory_ = (void*)1;  /* something non-null */
   if (!WebPPictureYUVAToARGB(pic)) goto end;
   pic->memory_ = NULL;  /* restore pointer */
   }
#endif


but that's pretty hacky. Your call.

(PS: Otherwise, patch works ok!)



That does look hacky, but it's definitely simpler. What does that do 
exactly, and do I still need to call WebPPictureFree(pic)?


Thanks,
Justin

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


Re: [libav-devel] [PATCH] Add a libwebp encoder

2013-12-02 Thread Diego Biurrun
On Sun, Dec 01, 2013 at 05:04:25PM -0500, Justin Ruggles wrote:
> --- /dev/null
> +++ b/libavcodec/libwebpenc.c
> @@ -0,0 +1,309 @@
> +
> +typedef struct {
> +AVClass *avclass;   // class for AVOptions
> +int lossless;   // use lossless encoding
> +float quality;  // lossy quality 0 - 100
> +int preset; // configuration preset
> +WebPConfig config;  // libwebp configuration
> +int chroma_warning; // chroma linesize mismatch warning has been 
> printed
> +int conversion_warning; // pixel format conversion warning has been 
> printed
> +} LibWebPContext;

Let's try to avoid anonymous struct typedeffing.  It has caused trouble in
headers in the past, I think the only way to avoid them creeping back into
headers is to try to form a habit not to use them anywhere.

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


Re: [libav-devel] Release preparation

2013-12-02 Thread Tim W.
On 01 Dec 2013, at 17:00, Reinhard Tartler  wrote:

> On Mon, Nov 25, 2013 at 8:25 AM, Luca Barbato  wrote:
>> Hi, we already have enough fixes piled up for another release, I'd aim
>> to get 0.8 and 9 out early in December.
>> 
>> Given the requests from some of our community members we could even
>> think about getting ready for a libav10 pre-release before the end of
>> the year, most of the features we discussed at the vdd and return to
>> have a seasonal major release with just some major feature increase.
> 
> Any ideas on a codename for Libav 10?

"Vista"

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


Re: [libav-devel] [PATCH] Add a libwebp encoder

2013-12-02 Thread Pascal Massimino
Hi,


On Sun, Dec 1, 2013 at 11:04 PM, Justin Ruggles wrote:

> ---
> Added check and fallback for differing chroma linesizes.
> Fixed some memleaks.
> Only print warnings once.
>
>  Changelog   |1 +
>  configure   |4 +
>  doc/encoders.texi   |   58 +
>  doc/general.texi|4 +-
>  libavcodec/Makefile |1 +
>  libavcodec/allcodecs.c  |1 +
>  libavcodec/libwebpenc.c |  309
> +++
>  libavcodec/version.h|2 +-
>  libavformat/img2enc.c   |2 +-
>  9 files changed, 378 insertions(+), 4 deletions(-)
>  create mode 100644 libavcodec/libwebpenc.c
>
> diff --git a/Changelog b/Changelog
> index 9747720..110b8cb 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -50,6 +50,7 @@ version 10:
>  - VP9 decoder
>  - support for decoding through VDPAU in avconv (the -hwaccel option)
>  - remove mp3_header_(de)compress bitstream filters
> +- WebP encoding via libwebp
>
>
>  version 9:
> diff --git a/configure b/configure
> index 832a54a..a959f73 100755
> --- a/configure
> +++ b/configure
> @@ -202,6 +202,7 @@ External library support:
>--enable-libvorbis   enable Vorbis encoding via libvorbis [no]
>--enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
>--enable-libwavpack  enable wavpack encoding via libwavpack [no]
> +  --enable-libwebp enable WebP encoding via libwebp [no]
>--enable-libx264 enable H.264 encoding via x264 [no]
>--enable-libxavs enable AVS encoding via xavs [no]
>--enable-libxvid enable Xvid encoding via xvidcore,
> @@ -1092,6 +1093,7 @@ EXTERNAL_LIBRARY_LIST="
>  libvorbis
>  libvpx
>  libwavpack
> +libwebp
>  libx264
>  libxavs
>  libxvid
> @@ -1836,6 +1838,7 @@ libvpx_vp8_encoder_deps="libvpx"
>  libvpx_vp9_decoder_deps="libvpx"
>  libvpx_vp9_encoder_deps="libvpx"
>  libwavpack_encoder_deps="libwavpack"
> +libwebp_encoder_deps="libwebp"
>  libx264_encoder_deps="libx264"
>  libxavs_encoder_deps="libxavs"
>  libxvid_encoder_deps="libxvid"
> @@ -3871,6 +3874,7 @@ enabled libvpx&& {
>  enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h
> vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; }
>  enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h
> vpx/vp8cx.h" "vpx_codec_vp9_cx" -lvpx || disable libvpx_vp9_encoder; } }
>  enabled libwavpack&& require libwavpack wavpack/wavpack.h
> WavpackOpenFileOutput  -lwavpack
> +enabled libwebp   && require_pkg_config libwebp webp/encode.h
> WebPGetEncoderVersion
>  enabled libx264   && require libx264 x264.h x264_encoder_encode
> -lx264 &&
>   { check_cpp_condition x264.h "X264_BUILD >=
> 118" ||
> die "ERROR: libx264 version must be >=
> 0.118."; }
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index d6f4bce..aa27962 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -446,6 +446,64 @@ Same as 3, but with extra processing enabled -
> corresponding to the wavpack
>  @chapter Video Encoders
>  @c man begin VIDEO ENCODERS
>
> +@section libwebp
> +
> +libwebp WebP Image encoder wrapper
> +
> +libwebp is Google's official encoder for WebP images. It can encode in
> either
> +lossy or lossless mode. Lossy images are essentially a wrapper around a
> VP8
> +frame. Lossless images are a separate codec developed by Google.
> +
> +@subsection Pixel Format
> +
> +Currently, libwebp only supports YUV420 for lossy and RGB for lossless due
> +to limitations of the format and libwebp. Alpha is supported for either
> mode.
> +Because of API limitations, if RGB is passed in when encoding lossy or
> YUV is
> +passed in for encoding lossless, the pixel format will automatically be
> +converted using functions from libwebp. This is not ideal and is done
> only for
> +convenience.
> +
> +@subsection Options
> +
> +@table @option
> +
> +@item -lossless @var{boolean}
> +Enables/Disables use of lossless mode. Default is 0.
> +
> +@item -compression_level @var{number}
> +For lossy, this is a quality/speed tradeoff. Higher values give better
> quality
> +for a given size at the cost of increased encoding time. For lossless,
> this is
> +a size/speed tradeoff. Higher values give smaller size at the cost of
> increased
> +encoding time. This maps to the @var{method} option in libwebp. The valid
> range
> +is 0 to 6. Default is 4.
> +
> +@item -qscale @var{number}
> +Image quality, 0 to 100. This is used for lossy encoding only.
> +Note that for usage via libavcodec, this option is called
> @var{global_quality}
> +and must be multiplied by @var{FF_QP2LAMBDA}.
> +
> +@item -preset @var{type}
> +Configuration preset. This does some automatic settings based on the
> general
> +type of the image.
> +@table @option
> +@item none
> +Do not use a preset.
> +@item default
> +Use the encoder default.
> +@item picture
> +Digital p

Re: [libav-devel] [PATCH 1/2] configure: Check for a group of function presence

2013-12-02 Thread Luca Barbato
On 02/12/13 03:57, Diego Biurrun wrote:
> On Sun, Dec 01, 2013 at 04:34:45AM +0100, Luca Barbato wrote:
>> And use it to check for pthreads support.
>>
>> Unbreak f058f384a0d76bfd125f4738dceab7c890186432 for *BSD since their
>> compilers have a false positive with pthread_join.
>> ---
>>  configure | 31 ---
>>  1 file changed, 24 insertions(+), 7 deletions(-)
> 
> Feels very hackish to me.  I'm confident there is a better solution
> to the root problem that this is working around.

As stated (even in the comment in configure) the pthreads tests is
brittle and requires to have the least amount of libs around when it is
done (thus moving down zlib and bz2 checks).

A "correct way" to do that is to extend my patch to cover ALL the
symbols we use.

On BSD they have this _strange_ separation between libc and libthr
causing the problem with this specific pick of symbols.

Another possible solution would be changing the order and do

- check for -pthread
- check for -pthreads
- check for nothing-at-all
- check for -lpthread

Assuming the compiler would fail to parse the option if it is not supported.

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