Re: [libav-devel] [PATCH] mpjpeg: Initial implementation

2015-05-19 Thread Vittorio Giovara
On Sat, May 16, 2015 at 4:03 PM, Luca Barbato lu_z...@gentoo.org wrote:
 Support only streams with Content-Length.

 Signed-off-by: Luca Barbato lu_z...@gentoo.org
 ---

 I'd have to change ff_get_line to make it work.

The problem is that ff_get_line does not parse ^M characters right?
I don't know if it would make sense to add a parameter to that
function so that other formats may use if needed.

  libavformat/Makefile |   1 +
  libavformat/allformats.c |   2 +-
  libavformat/mpjpegdec.c  | 234 
 +++
  3 files changed, 236 insertions(+), 1 deletion(-)
  create mode 100644 libavformat/mpjpegdec.c

Bump MINOR version when you push this please.

 +static int mpjpeg_read_header(AVFormatContext *s)
 +{
 +AVStream *st;
 +char boundary[70 + 2 + 1];
 +int64_t pos = avio_tell(s-pb);
 +int ret;
 +
 +
 +ret = get_line(s-pb, boundary, sizeof(boundary));
 +if (ret  0)
 +return ret;

nit: extra line

Looks ok on a first read.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/4] mpegvideo: Drop flags and flags2

2015-05-19 Thread Vittorio Giovara
On Tue, May 12, 2015 at 2:16 AM, Vittorio Giovara
vittorio.giov...@gmail.com wrote:
 On Sun, May 10, 2015 at 11:01 PM, Luca Barbato lu_z...@gentoo.org wrote:
 On 01/05/15 08:39, Anton Khirnov wrote:

 More specific benchmarks. As expected they aren't really different.

  Performance counter stats for './avconv-v12_dev0-1273-g46914ff -nostats
 -v quiet -filter_complex testsrc -t 600 -c:v mpeg2video -f null -' (30
 runs):

   18186.236693  task-clock (msec) #1.271 CPUs
 utilized( +-  1.06% )
 300332  context-switches  #0.017 M/sec
   ( +-  0.00% )
851  cpu-migrations#0.047 K/sec
   ( +-  5.59% )
 153625  page-faults   #0.008 M/sec
   ( +-  0.00% )
47684924907  cycles#2.622 GHz
   ( +-  0.14% )
17169614279  stalled-cycles-frontend   #   36.01% frontend
 cycles idle ( +-  0.38% )
  0  stalled-cycles-backend#0.00% backend
 cycles idle
   103427443643  instructions  #2.17  insns per cycle
   #0.17  stalled
 cycles per insn  ( +-  0.00% )
 9126880556  branches  #  501.856 M/sec
   ( +-  0.00% )
  113808703  branch-misses #1.25% of all
 branches  ( +-  0.13% )

   14.306429475 seconds time elapsed
  ( +-  1.11% )


  Performance counter stats for './avconv-v12_dev0-1276-g9503449 -nostats
 -v quiet -filter_complex testsrc -t 600 -c:v mpeg2video -f null -' (30
 runs):

   18207.403592  task-clock (msec) #1.273 CPUs
 utilized( +-  0.99% )
 300327  context-switches  #0.016 M/sec
   ( +-  0.00% )
860  cpu-migrations#0.047 K/sec
   ( +-  6.30% )
 153626  page-faults   #0.008 M/sec
   ( +-  0.00% )
47685530782  cycles#2.619 GHz
   ( +-  0.15% )
17165731850  stalled-cycles-frontend   #   36.00% frontend
 cycles idle ( +-  0.41% )
  0  stalled-cycles-backend#0.00% backend
 cycles idle
   103428007012  instructions  #2.17  insns per cycle
   #0.17  stalled
 cycles per insn  ( +-  0.00% )
 9127004846  branches  #  501.280 M/sec
   ( +-  0.00% )
  113822534  branch-misses #1.25% of all
 branches  ( +-  0.12% )

   14.305442763 seconds time elapsed
  ( +-  1.01% )


  Performance counter stats for './avconv-v12_dev0-1273-g46914ff -nostats
 -v quiet -i /tmp/test.mkv -f null -' (30 runs):

2364.470888  task-clock (msec) #1.564 CPUs
 utilized( +-  1.49% )
 150459  context-switches  #0.064 M/sec
   ( +-  0.02% )
177  cpu-migrations#0.075 K/sec
   ( +- 12.06% )
773  page-faults   #0.327 K/sec
   ( +-  0.05% )
 6823046093  cycles#2.886 GHz
   ( +-  0.33% )
 3953734628  stalled-cycles-frontend   #   57.95% frontend
 cycles idle ( +-  0.56% )
  0  stalled-cycles-backend#0.00% backend
 cycles idle
 8204593415  instructions  #1.20  insns per cycle
   #0.48  stalled
 cycles per insn  ( +-  0.00% )
 1187962103  branches  #  502.422 M/sec
   ( +-  0.01% )
   20631618  branch-misses #1.74% of all
 branches  ( +-  0.20% )

1.511403840 seconds time elapsed
  ( +-  1.48% )


  Performance counter stats for './avconv-v12_dev0-1276-g9503449 -nostats
 -v quiet -i /tmp/test.mkv -f null -' (30 runs):

2347.891829  task-clock (msec) #1.562 CPUs
 utilized( +-  1.72% )
 150424  context-switches  #0.064 M/sec
   ( +-  0.02% )
138  cpu-migrations#0.059 K/sec
   ( +-  8.35% )
773  page-faults   #0.329 K/sec
   ( +-  0.05% )
 6809473884  cycles#2.900 GHz
   ( +-  0.33% )
 3941879048  stalled-cycles-frontend   #   57.89% frontend
 cycles idle ( +-  0.59% )
  0  stalled-cycles-backend#0.00% backend
 cycles idle
 8204107450  instructions  #1.20  insns per cycle
   #

Re: [libav-devel] [PATCH 10/14] Introduce AVStats to carry side data compression statistics

2015-05-19 Thread Vittorio Giovara
On Tue, May 12, 2015 at 2:11 AM, Vittorio Giovara
vittorio.giov...@gmail.com wrote:
 On Thu, May 7, 2015 at 5:52 PM, Vittorio Giovara
 vittorio.giov...@gmail.com wrote:
 The question of the structure name remains. How about
 AVPacketEncoderParams? It should carry all the properties needed and
 suggestions received.

 AVPacketEncoderParams is it then?

AVPacketCodingParams has been deemed as more fitting from multiple
sources, I'll redo the set using this name.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] lavc: check memory allocations

2015-05-19 Thread Vittorio Giovara
---
 libavcodec/aacpsy.c|  6 ++
 libavcodec/asvenc.c|  2 ++
 libavcodec/dct.c   |  2 ++
 libavcodec/eatgv.c |  4 +++-
 libavcodec/huffyuvenc.c|  2 +-
 libavcodec/jpeglsdec.c |  6 ++
 libavcodec/lclenc.c|  2 ++
 libavcodec/libtheoraenc.c  |  6 ++
 libavcodec/libx264.c   |  4 
 libavcodec/libxvid.c   |  6 ++
 libavcodec/psymodel.c  | 12 
 libavcodec/pthread_frame.c |  7 +++
 libavcodec/ratecontrol.c   | 11 ++-
 libavcodec/svq1enc.c   | 17 -
 libavcodec/truemotion2.c   | 10 ++
 libavcodec/wmaenc.c|  4 
 libavcodec/xsubdec.c   | 13 +
 17 files changed, 110 insertions(+), 4 deletions(-)

No functional changes from the reviews in separate bits.
All ok'd changes squashed in a single commit, going to push this at the end
of the week if no objections.
Vittorio

diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index ac58968..6cfe3e3 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -298,6 +298,8 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
 const float num_bark   = calc_bark((float)bandwidth);
 
 ctx-model_priv_data = av_mallocz(sizeof(AacPsyContext));
+if (!ctx-model_priv_data)
+return AVERROR(ENOMEM);
 pctx = (AacPsyContext*) ctx-model_priv_data;
 
 pctx-chan_bitrate = chan_bitrate;
@@ -349,6 +351,10 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
 }
 
 pctx-ch = av_mallocz(sizeof(AacPsyChannel) * ctx-avctx-channels);
+if (!pctx-ch) {
+av_freep(pctx);
+return AVERROR(ENOMEM);
+}
 
 lame_window_init(pctx, ctx-avctx);
 
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index f8c52af..0879615 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -299,6 +299,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
  avctx-global_quality / 2) / avctx-global_quality;
 
 avctx-extradata   = av_mallocz(8);
+if (!avctx-extradata)
+return AVERROR(ENOMEM);
 avctx-extradata_size  = 8;
 ((uint32_t *) avctx-extradata)[0] = av_le2ne32(a-inv_qscale);
 ((uint32_t *) avctx-extradata)[1] = av_le2ne32(AV_RL32(ASUS));
diff --git a/libavcodec/dct.c b/libavcodec/dct.c
index 4dbbff8..180477e 100644
--- a/libavcodec/dct.c
+++ b/libavcodec/dct.c
@@ -191,6 +191,8 @@ av_cold int ff_dct_init(DCTContext *s, int nbits, enum 
DCTTransformType inverse)
 
 s-costab = ff_cos_tabs[nbits + 2];
 s-csc2   = av_malloc(n / 2 * sizeof(FFTSample));
+if (!s-csc2)
+return AVERROR(ENOMEM);
 
 if (ff_rdft_init(s-rdft, nbits, inverse == DCT_III)  0) {
 av_free(s-csc2);
diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c
index c400b56..a77c4c3 100644
--- a/libavcodec/eatgv.c
+++ b/libavcodec/eatgv.c
@@ -173,7 +173,9 @@ static int tgv_decode_inter(TgvContext *s, AVFrame *frame,
 
 /* allocate codebook buffers as necessary */
 if (num_mvs  s-num_mvs) {
-s-mv_codebook = av_realloc(s-mv_codebook, num_mvs*2*sizeof(int));
+int err = av_reallocp(s-mv_codebook, num_mvs * 2 * sizeof(int));
+if (err  0)
+return err;
 s-num_mvs = num_mvs;
 }
 
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 6b3ff76..175b256 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -155,7 +155,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 s-version = 2;
 
 avctx-coded_frame = av_frame_alloc();
-if (!avctx-coded_frame)
+if (!avctx-extradata || !avctx-stats_out || !avctx-coded_frame)
 return AVERROR(ENOMEM);
 
 avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I;
diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
index d9b08fb..3b93799 100644
--- a/libavcodec/jpeglsdec.c
+++ b/libavcodec/jpeglsdec.c
@@ -278,10 +278,16 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int 
near,
 int off = 0, stride = 1, width, shift, ret = 0;
 
 zero = av_mallocz(s-picture_ptr-linesize[0]);
+if (!zero)
+return AVERROR(ENOMEM);
 last = zero;
 cur  = s-picture_ptr-data[0];
 
 state = av_mallocz(sizeof(JLSState));
+if (!state) {
+av_free(zero);
+return AVERROR(ENOMEM);
+}
 /* initialize JPEG-LS state from JPEG parameters */
 state-near   = near;
 state-bpp= (s-bits  2) ? 2 : s-bits;
diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c
index 20841bc..2448b9e 100644
--- a/libavcodec/lclenc.c
+++ b/libavcodec/lclenc.c
@@ -135,6 +135,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
 assert(avctx-width  avctx-height);
 
 avctx-extradata= av_mallocz(8);
+if (!avctx-extradata)
+return AVERROR(ENOMEM);
 
 avctx-coded_frame = av_frame_alloc();
 if (!avctx-coded_frame)
diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index 462bc94..097336b 100644
--- 

Re: [libav-devel] [PATCH] configure: Disable i686 for i586 and lower CPUs

2015-05-19 Thread Vittorio Giovara
On Fri, May 15, 2015 at 3:35 PM, Sebastian Ramacher
sramac...@debian.org wrote:
 On 2014-09-15 06:04:02, Diego Biurrun wrote:
 ---
  configure | 1 +
  1 file changed, 1 insertion(+)

 diff --git a/configure b/configure
 index 3bb8ca8..0afb719 100755
 --- a/configure
 +++ b/configure
 @@ -3303,6 +3303,7 @@ elif enabled x86; then
  case $cpu in
  i[345]86|pentium)
  cpuflags=-march=$cpu
 +disable i686
  disable mmx
  ;;
  # targets that do NOT support nopl and conditional mov (cmov)

 Please also apply this patch to release/11.

 Cheers
 --
 Sebastian Ramacher

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


[libav-devel] [PATCH] nvenc: Initial implementation

2015-05-19 Thread Luca Barbato
Partially based on the work of Timo Rothenpieler t...@rothenpieler.org
---

Tested on my macbook

 configure   |   16 +
 libavcodec/Makefile |3 +
 libavcodec/allcodecs.c  |2 +
 libavcodec/nvenc.c  | 1145 +++
 libavcodec/nvenc.h  |  124 +
 libavcodec/nvenc_h264.c |  110 +
 libavcodec/nvenc_hevc.c |  108 +
 7 files changed, 1508 insertions(+)
 create mode 100644 libavcodec/nvenc.c
 create mode 100644 libavcodec/nvenc.h
 create mode 100644 libavcodec/nvenc_h264.c
 create mode 100644 libavcodec/nvenc_hevc.c

diff --git a/configure b/configure
index 5bcc2df..a7174d4 100755
--- a/configure
+++ b/configure
@@ -219,6 +219,7 @@ External library support:
   --enable-libxvid enable Xvid encoding via xvidcore,
native MPEG-4/Xvid encoder exists [no]
   --enable-mmalenable decoding via MMAL [no]
+  --enable-nvenc   enable encoding via NVENC [no]
   --enable-openssl enable openssl [no]
   --enable-x11grab enable X11 grabbing (legacy) [no]
   --enable-zlibenable zlib [autodetect]
@@ -1188,6 +1189,7 @@ EXTERNAL_LIBRARY_LIST=
 libxcb_xfixes
 libxvid
 mmal
+nvenc
 openssl
 x11grab
 zlib
@@ -1476,6 +1478,7 @@ SYSTEM_FUNCS=
 inet_aton
 isatty
 jack_port_get_latency_range
+LoadLibrary
 localtime_r
 mach_absolute_time
 MapViewOfFile
@@ -1771,6 +1774,8 @@ mpegvideo_select=blockdsp hpeldsp idctdsp me_cmp 
videodsp
 mpegvideoenc_select=me_cmp mpegvideo pixblockdsp qpeldsp
 qsvdec_select=qsv
 qsvenc_select=qsv
+nvenc_if_any=dlopen LoadLibrary
+nvenc_extralibs='$ldl'

 # decoders / encoders
 aac_decoder_select=imdct15 mdct sinewin
@@ -1838,11 +1843,13 @@ h263i_decoder_select=h263_decoder
 h263p_encoder_select=h263_encoder
 h264_decoder_select=cabac golomb h264chroma h264dsp h264pred h264qpel 
startcode videodsp
 h264_decoder_suggest=error_resilience
+h264_nvenc_encoder_deps=nvenc
 h264_qsv_decoder_deps=libmfx
 h264_qsv_decoder_select=h264_mp4toannexb_bsf h264_parser qsvdec 
h264_qsv_hwaccel
 h264_qsv_encoder_deps=libmfx
 h264_qsv_encoder_select=qsvenc
 hevc_decoder_select=bswapdsp cabac golomb videodsp
+hevc_nvenc_encoder_deps=nvenc
 huffyuv_decoder_select=bswapdsp huffyuvdsp
 huffyuv_encoder_select=bswapdsp huffman huffyuvencdsp
 iac_decoder_select=imc_decoder
@@ -3790,6 +3797,7 @@ die_license_disabled gpl x11grab

 die_license_disabled nonfree libfaac
 die_license_disabled nonfree libfdk_aac
+die_license_disabled nonfree nvenc
 die_license_disabled nonfree openssl

 die_license_disabled version3 libopencore_amrnb
@@ -4147,6 +4155,7 @@ check_func_headers windows.h CoTaskMemFree -lole32
 check_func_headers windows.h GetProcessAffinityMask
 check_func_headers windows.h GetProcessTimes
 check_func_headers windows.h GetSystemTimeAsFileTime
+check_func_headers windows.h LoadLibrary
 check_func_headers windows.h MapViewOfFile
 check_func_headers windows.h SetConsoleTextAttribute
 check_func_headers windows.h Sleep
@@ -4298,6 +4307,13 @@ if enabled libdc1394; then
 die ERROR: No version of libdc1394 found 
 fi

+if enabled nvenc; then
+check_header cuda.h || die ERROR: cuda.h not found.;
+check_header nvEncodeAPI.h || die ERROR: nvEncodeAPI.h not found.;
+check_cpp_condition nvEncodeAPI.h NVENCAPI_MAJOR_VERSION = 5 ||
+die ERROR: NVENC API version 4 or older is not supported;
+fi
+
 if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
 check_cpp_condition SDL.h (SDL_MAJOR_VERSION16 | SDL_MINOR_VERSION8 | 
SDL_PATCHLEVEL) = 0x010201 $sdl_cflags 
 check_cpp_condition SDL.h (SDL_MAJOR_VERSION16 | SDL_MINOR_VERSION8 | 
SDL_PATCHLEVEL)  0x010300 $sdl_cflags 
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fc8c6e9..0c349b5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -80,6 +80,7 @@ OBJS-$(CONFIG_MPEGVIDEOENC)+= mpegvideo_enc.o 
mpeg12data.o  \
   motion_est.o ratecontrol.o\
   mpegvideoencdsp.o
 OBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o
+OBJS-${CONFIG_NVENC}   += nvenc.o
 OBJS-$(CONFIG_QPELDSP) += qpeldsp.o
 OBJS-$(CONFIG_QSV) += qsv.o
 OBJS-$(CONFIG_QSVDEC)  += qsvdec.o
@@ -226,11 +227,13 @@ OBJS-$(CONFIG_H264_DECODER)+= h264.o 
h264_cabac.o h264_cavlc.o \
   h264_mb.o h264_picture.o h264_ps.o \
   h264_refs.o h264_sei.o h264_slice.o
 OBJS-$(CONFIG_H264_MMAL_DECODER)   += mmaldec.o
+OBJS-$(CONFIG_H264_NVENC_ENCODER)  += nvenc_h264.o
 OBJS-$(CONFIG_H264_QSV_DECODER)+= qsvdec_h264.o
 OBJS-$(CONFIG_H264_QSV_ENCODER)+= qsvenc_h264.o
 OBJS-$(CONFIG_HEVC_DECODER)+= hevc.o hevc_mvs.o hevc_ps.o 
hevc_sei.o \
   hevc_cabac.o 

[libav-devel] [PATCH] libvpx: Support all pixel formats available

2015-05-19 Thread Vittorio Giovara
---
Another set of eyes for the pixel format mapping would be welcome.
Vittorio

 libavcodec/libvpx.c| 26 ++
 libavcodec/libvpx.h|  2 ++
 libavcodec/libvpxdec.c |  4 ++--
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libvpx.c b/libavcodec/libvpx.c
index 20f4484..5adad66 100644
--- a/libavcodec/libvpx.c
+++ b/libavcodec/libvpx.c
@@ -33,3 +33,29 @@ int ff_vp9_check_experimental(AVCodecContext *avctx)
 }
 return 0;
 }
+
+enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img)
+{
+switch(img) {
+case VPX_IMG_FMT_RGB24: return AV_PIX_FMT_RGB24;
+case VPX_IMG_FMT_RGB565:return AV_PIX_FMT_RGB565BE;
+case VPX_IMG_FMT_RGB555:return AV_PIX_FMT_RGB555BE;
+case VPX_IMG_FMT_UYVY:  return AV_PIX_FMT_UYVY422;
+case VPX_IMG_FMT_YUY2:  return AV_PIX_FMT_YUYV422;
+case VPX_IMG_FMT_YVYU:  return AV_PIX_FMT_YVYU422;
+case VPX_IMG_FMT_BGR24: return AV_PIX_FMT_BGR24;
+case VPX_IMG_FMT_ARGB:  return AV_PIX_FMT_ARGB;
+case VPX_IMG_FMT_ARGB_LE:   return AV_PIX_FMT_BGRA;
+case VPX_IMG_FMT_RGB565_LE: return AV_PIX_FMT_RGB565LE;
+case VPX_IMG_FMT_RGB555_LE: return AV_PIX_FMT_RGB555LE;
+case VPX_IMG_FMT_I420:  return AV_PIX_FMT_YUV420P;
+case VPX_IMG_FMT_I422:  return AV_PIX_FMT_YUV422P;
+case VPX_IMG_FMT_I444:  return AV_PIX_FMT_YUV444P;
+case VPX_IMG_FMT_I440:  return AV_PIX_FMT_YUV440P;
+case VPX_IMG_FMT_444A:  return AV_PIX_FMT_YUVA444P;
+case VPX_IMG_FMT_I42016:return AV_PIX_FMT_YUV420P16BE;
+case VPX_IMG_FMT_I42216:return AV_PIX_FMT_YUV422P16BE;
+case VPX_IMG_FMT_I44416:return AV_PIX_FMT_YUV444P16BE;
+default:return AV_PIX_FMT_NONE;
+}
+}
diff --git a/libavcodec/libvpx.h b/libavcodec/libvpx.h
index cb1ed09..79a05f4 100644
--- a/libavcodec/libvpx.h
+++ b/libavcodec/libvpx.h
@@ -25,4 +25,6 @@
 
 int ff_vp9_check_experimental(AVCodecContext *avctx);
 
+enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img);
+
 #endif /* AVCODEC_LIBVPX_H */
diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
index 6052207..a1f9c22 100644
--- a/libavcodec/libvpxdec.c
+++ b/libavcodec/libvpxdec.c
@@ -56,7 +56,6 @@ static av_cold int vpx_init(AVCodecContext *avctx,
 return AVERROR(EINVAL);
 }
 
-avctx-pix_fmt = AV_PIX_FMT_YUV420P;
 return 0;
 }
 
@@ -82,7 +81,8 @@ static int vp8_decode(AVCodecContext *avctx,
 }
 
 if ((img = vpx_codec_get_frame(ctx-decoder, iter))) {
-if (img-fmt != VPX_IMG_FMT_I420) {
+avctx-pix_fmt = ff_vpx_imgfmt_to_pixfmt(img-fmt);
+if (avctx-pix_fmt == AV_PIX_FMT_NONE) {
 av_log(avctx, AV_LOG_ERROR, Unsupported output colorspace (%d)\n,
img-fmt);
 return AVERROR_INVALIDDATA;
-- 
1.9.5 (Apple Git-50.3)

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


[libav-devel] [PATCH 10/13] lavc: Gather all coded_frame allocation and free functions to a single place

2015-05-19 Thread Vittorio Giovara
Allocating coded_frame is what most encoders do anyway, so it makes
sense to always allocate it in a single place. This bring uniformity to
encoder behaviour and prevents applications from erroneusly accessing
this field when not allocated.

Additionally this helps isolating encoders that export information with
it, and it heavily simplifies its deprecation.

Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
 libavcodec/a64multienc.c|  7 ---
 libavcodec/alacenc.c|  7 ---
 libavcodec/aliaspixenc.c| 16 
 libavcodec/asvenc.c | 18 ++
 libavcodec/bmpenc.c | 11 ---
 libavcodec/cljrenc.c| 17 -
 libavcodec/dnxhdenc.c   |  6 --
 libavcodec/dpxenc.c | 11 ---
 libavcodec/dvenc.c  | 11 ---
 libavcodec/ffv1enc.c|  5 -
 libavcodec/flashsvenc.c |  8 
 libavcodec/gif.c|  6 --
 libavcodec/huffyuvenc.c |  6 --
 libavcodec/jpeglsenc.c  | 11 ---
 libavcodec/lclenc.c |  6 --
 libavcodec/libopencore-amr.c|  1 -
 libavcodec/libopenjpegenc.c |  8 
 libavcodec/libschroedingerenc.c |  6 --
 libavcodec/libtheoraenc.c   |  6 --
 libavcodec/libvpxenc.c  |  7 ---
 libavcodec/libx264.c|  6 --
 libavcodec/libx265.c|  8 
 libavcodec/libxavs.c|  6 --
 libavcodec/libxvid.c|  4 
 libavcodec/ljpegenc.c   |  5 -
 libavcodec/mpegvideo_enc.c  |  3 +--
 libavcodec/pamenc.c | 11 ---
 libavcodec/pcm.c| 11 ---
 libavcodec/pcxenc.c | 11 ---
 libavcodec/pngenc.c | 11 ---
 libavcodec/pnmenc.c | 14 --
 libavcodec/proresenc.c  |  5 -
 libavcodec/qsvenc.c |  6 --
 libavcodec/qtrleenc.c   |  8 
 libavcodec/rawenc.c | 11 ---
 libavcodec/sgienc.c | 11 ---
 libavcodec/sunrastenc.c | 11 ---
 libavcodec/svq1enc.c|  4 +---
 libavcodec/targaenc.c   | 11 ---
 libavcodec/tiffenc.c| 11 ---
 libavcodec/utils.c  | 12 ++--
 libavcodec/utvideoenc.c |  9 -
 libavcodec/v210enc.c| 12 
 libavcodec/v410enc.c| 15 ---
 libavcodec/xbmenc.c | 11 ---
 libavcodec/xwdenc.c | 18 --
 libavcodec/zmbvenc.c|  8 
 47 files changed, 14 insertions(+), 413 deletions(-)

diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index 969a071..f065ebb 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -166,7 +166,6 @@ static void render_charset(AVCodecContext *avctx, uint8_t 
*charset,
 static av_cold int a64multi_close_encoder(AVCodecContext *avctx)
 {
 A64Context *c = avctx-priv_data;
-av_frame_free(avctx-coded_frame);
 av_free(c-mc_meta_charset);
 av_free(c-mc_best_cb);
 av_free(c-mc_charset);
@@ -218,12 +217,6 @@ static av_cold int a64multi_encode_init(AVCodecContext 
*avctx)
 AV_WB32(avctx-extradata, c-mc_lifetime);
 AV_WB32(avctx-extradata + 16, INTERLACED);
 
-avctx-coded_frame = av_frame_alloc();
-if (!avctx-coded_frame) {
-a64multi_close_encoder(avctx);
-return AVERROR(ENOMEM);
-}
-
 avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I;
 avctx-coded_frame-key_frame = 1;
 if (!avctx-codec_tag)
diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index 401f26f..cf7 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -483,7 +483,6 @@ static av_cold int alac_encode_close(AVCodecContext *avctx)
 ff_lpc_end(s-lpc_ctx);
 av_freep(avctx-extradata);
 avctx-extradata_size = 0;
-av_freep(avctx-coded_frame);
 return 0;
 }
 
@@ -579,12 +578,6 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
 goto error;
 }
 
-avctx-coded_frame = av_frame_alloc();
-if (!avctx-coded_frame) {
-ret = AVERROR(ENOMEM);
-goto error;
-}
-
 s-avctx = avctx;
 
 if ((ret = ff_lpc_init(s-lpc_ctx, avctx-frame_size,
diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c
index 47e0612..5e3bcb4 100644
--- a/libavcodec/aliaspixenc.c
+++ b/libavcodec/aliaspixenc.c
@@ -27,14 +27,6 @@
 
 #define ALIAS_HEADER_SIZE 10
 
-static av_cold int encode_init(AVCodecContext *avctx)
-{
-avctx-coded_frame = av_frame_alloc();
-if (!avctx-coded_frame)
-return AVERROR(ENOMEM);
-return 0;
-}
-
 static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 const AVFrame *frame, int *got_packet)
 {
@@ -114,20 +106,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 return 0;
 }
 

[libav-devel] [PATCH 04/13] libvpxenc: Do not entangle coded_frame

2015-05-19 Thread Vittorio Giovara
Keep coded_frame.key_frame a write-only variable.
---
 libavcodec/libvpxenc.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index ec8f1f1..21f47aa 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -391,19 +391,19 @@ static inline void cx_pktcpy(struct FrameListData *dst,
  * @return a negative AVERROR on error
  */
 static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
-  AVPacket *pkt, AVFrame *coded_frame)
+  AVPacket *pkt)
 {
 int ret = ff_alloc_packet(pkt, cx_frame-sz);
 if (ret = 0) {
 memcpy(pkt-data, cx_frame-buf, pkt-size);
 pkt-pts = pkt-dts= cx_frame-pts;
-coded_frame-key_frame = !!(cx_frame-flags  VPX_FRAME_IS_KEY);
+avctx-coded_frame-key_frame = !!(cx_frame-flags  VPX_FRAME_IS_KEY);
 
-if (coded_frame-key_frame) {
-coded_frame-pict_type = AV_PICTURE_TYPE_I;
+if (!!(cx_frame-flags  VPX_FRAME_IS_KEY)) {
+avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I;
 pkt-flags|= AV_PKT_FLAG_KEY;
 } else
-coded_frame-pict_type = AV_PICTURE_TYPE_P;
+avctx-coded_frame-pict_type = AV_PICTURE_TYPE_P;
 } else {
 av_log(avctx, AV_LOG_ERROR,
Error getting output packet of size %zu.\n, cx_frame-sz);
@@ -420,8 +420,7 @@ static int storeframe(AVCodecContext *avctx, struct 
FrameListData *cx_frame,
  * @return AVERROR(EINVAL) on output size error
  * @return AVERROR(ENOMEM) on coded frame queue data allocation error
  */
-static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out,
-AVFrame *coded_frame)
+static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
 {
 VP8Context *ctx = avctx-priv_data;
 const struct vpx_codec_cx_pkt *pkt;
@@ -431,7 +430,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket 
*pkt_out,
 if (ctx-coded_frame_list) {
 struct FrameListData *cx_frame = ctx-coded_frame_list;
 /* return the leading frame if we've already begun queueing */
-size = storeframe(avctx, cx_frame, pkt_out, coded_frame);
+size = storeframe(avctx, cx_frame, pkt_out);
 if (size  0)
 return size;
 ctx-coded_frame_list = cx_frame-next;
@@ -450,7 +449,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket 
*pkt_out,
provided a frame for output */
 assert(!ctx-coded_frame_list);
 cx_pktcpy(cx_frame, pkt);
-size = storeframe(avctx, cx_frame, pkt_out, coded_frame);
+size = storeframe(avctx, cx_frame, pkt_out);
 if (size  0)
 return size;
 } else {
@@ -529,7 +528,7 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt,
 log_encoder_error(avctx, Error encoding frame);
 return AVERROR_INVALIDDATA;
 }
-coded_size = queue_frames(avctx, pkt, avctx-coded_frame);
+coded_size = queue_frames(avctx, pkt);
 
 if (!frame  avctx-flags  CODEC_FLAG_PASS1) {
 unsigned int b64_size = AV_BASE64_SIZE(ctx-twopass_stats.sz);
-- 
1.9.5 (Apple Git-50.3)

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


[libav-devel] [PATCH 07/13] ffv1enc: Keep coded_frame.key_frame a write-only variable

2015-05-19 Thread Vittorio Giovara
---
 libavcodec/ffv1.h|  1 +
 libavcodec/ffv1enc.c | 11 ++-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index bc433bc..6e8c798 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -78,6 +78,7 @@ typedef struct FFV1Context {
 int transparency;
 int flags;
 int picture_number;
+int key_frame;
 const AVFrame *frame;
 AVFrame *last_picture;
 
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 2ef2913..7099c16 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -884,7 +884,7 @@ static int encode_slice(AVCodecContext *c, void *arg)
? (f-bits_per_raw_sample  8) + 1
: 4;
 
-if (c-coded_frame-key_frame)
+if (f-key_frame)
 ffv1_clear_slice_state(f, fs);
 if (f-version  2) {
 encode_slice_header(f, fs);
@@ -931,7 +931,6 @@ static int ffv1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 {
 FFV1Context *f  = avctx-priv_data;
 RangeCoder *const c = f-slice_context[0]-c;
-AVFrame *const p= avctx-coded_frame;
 int used_count  = 0;
 uint8_t keystate= 128;
 uint8_t *buf_p;
@@ -951,12 +950,12 @@ static int ffv1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 if (avctx-gop_size == 0 || f-picture_number % avctx-gop_size == 0) {
 put_rac(c, keystate, 1);
-p-key_frame = 1;
+f-key_frame = 1;
 f-gob_count++;
 write_header(f);
 } else {
 put_rac(c, keystate, 0);
-p-key_frame = 0;
+f-key_frame = 0;
 }
 
 if (f-ac  1) {
@@ -1050,9 +1049,11 @@ static int ffv1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 } else if (avctx-flags  CODEC_FLAG_PASS1)
 avctx-stats_out[0] = '\0';
 
+avctx-coded_frame-key_frame = f-key_frame;
+
 f-picture_number++;
 pkt-size   = buf_p - pkt-data;
-pkt-flags |= AV_PKT_FLAG_KEY * p-key_frame;
+pkt-flags |= AV_PKT_FLAG_KEY * f-key_frame;
 *got_packet = 1;
 
 return 0;
-- 
1.9.5 (Apple Git-50.3)

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


[libav-devel] [PATCH 08/13] libtheoraenc: Keep coded_frame.key_frame a write-only variable

2015-05-19 Thread Vittorio Giovara
---
 libavcodec/libtheoraenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index 462bc94..3781043 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -343,7 +343,7 @@ static int encode_frame(AVCodecContext* avc_context, 
AVPacket *pkt,
 // multithreaded (which will be disabled unless explicitly requested)
 pkt-pts = pkt-dts = frame-pts;
 avc_context-coded_frame-key_frame = !(o_packet.granulepos  
h-keyframe_mask);
-if (avc_context-coded_frame-key_frame)
+if (!(o_packet.granulepos  h-keyframe_mask))
 pkt-flags |= AV_PKT_FLAG_KEY;
 *got_packet = 1;
 
-- 
1.9.5 (Apple Git-50.3)

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


[libav-devel] [PATCH 06/13] svq1enc: Do not entangle coded_frame

2015-05-19 Thread Vittorio Giovara
Just save the fields needed for encoding.
---
 libavcodec/svq1enc.c | 32 +---
 libavcodec/svq1enc.h |  4 
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index f49f487..78d6770 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -238,14 +238,13 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
  unsigned char *decoded_plane,
  int width, int height, int src_stride, int stride)
 {
-const AVFrame *f = s-avctx-coded_frame;
 int x, y;
 int i;
 int block_width, block_height;
 int level;
 int threshold[6];
 uint8_t *src = s-scratchbuf + stride * 16;
-const int lambda = (f-quality * f-quality) 
+const int lambda = (s-quality * s-quality) 
(2 * FF_LAMBDA_SHIFT);
 
 /* figure out the acceptable level thresholds in advance */
@@ -256,7 +255,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 block_width  = (width  + 15) / 16;
 block_height = (height + 15) / 16;
 
-if (f-pict_type == AV_PICTURE_TYPE_P) {
+if (s-pict_type == AV_PICTURE_TYPE_P) {
 s-m.avctx = s-avctx;
 s-m.current_picture_ptr   = s-m.current_picture;
 s-m.last_picture_ptr  = s-m.last_picture;
@@ -272,13 +271,13 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 s-m.mb_stride = s-m.mb_width + 1;
 s-m.b8_stride = 2 * s-m.mb_width + 1;
 s-m.f_code= 1;
-s-m.pict_type = f-pict_type;
+s-m.pict_type = s-pict_type;
 s-m.me_method = s-avctx-me_method;
 s-m.me.scene_change_score = 0;
 s-m.flags = s-avctx-flags;
 // s-m.out_format= FMT_H263;
 // s-m.unrestricted_mv   = 1;
-s-m.lambda= f-quality;
+s-m.lambda= s-quality;
 s-m.qscale= s-m.lambda * 139 +
  FF_LAMBDA_SCALE * 64 
  FF_LAMBDA_SHIFT + 7;
@@ -371,13 +370,13 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 ff_init_block_index(s-m);
 ff_update_block_index(s-m);
 
-if (f-pict_type == AV_PICTURE_TYPE_I ||
+if (s-pict_type == AV_PICTURE_TYPE_I ||
 (s-m.mb_type[x + y * s-m.mb_stride] 
  CANDIDATE_MB_TYPE_INTRA)) {
 for (i = 0; i  6; i++)
 init_put_bits(s-reorder_pb[i], reorder_buffer[0][i],
   7 * 32);
-if (f-pict_type == AV_PICTURE_TYPE_P) {
+if (s-pict_type == AV_PICTURE_TYPE_P) {
 const uint8_t *vlc = 
ff_svq1_block_type_vlc[SVQ1_BLOCK_INTRA];
 put_bits(s-reorder_pb[5], vlc[1], vlc[0]);
 score[0] = vlc[1] * lambda;
@@ -393,7 +392,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
 
 best = 0;
 
-if (f-pict_type == AV_PICTURE_TYPE_P) {
+if (s-pict_type == AV_PICTURE_TYPE_P) {
 const uint8_t *vlc = ff_svq1_block_type_vlc[SVQ1_BLOCK_INTER];
 int mx, my, pred_x, pred_y, dxy;
 int16_t *motion_ptr;
@@ -564,7 +563,6 @@ static int svq1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
  const AVFrame *pict, int *got_packet)
 {
 SVQ1EncContext *const s = avctx-priv_data;
-AVFrame *const p= avctx-coded_frame;
 int i, ret;
 
 if (!pkt-data 
@@ -599,12 +597,16 @@ static int svq1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 init_put_bits(s-pb, pkt-data, pkt-size);
 
-p-pict_type = avctx-gop_size  avctx-frame_number % avctx-gop_size ?
-   AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
-p-key_frame = p-pict_type == AV_PICTURE_TYPE_I;
-p-quality   = pict-quality;
+if (avctx-gop_size  (avctx-frame_number % avctx-gop_size))
+s-pict_type = AV_PICTURE_TYPE_P;
+else
+s-pict_type = AV_PICTURE_TYPE_I;
+s-quality = pict-quality;
 
-svq1_write_header(s, p-pict_type);
+avctx-coded_frame-pict_type = s-pict_type;
+avctx-coded_frame-key_frame = s-pict_type == AV_PICTURE_TYPE_I;
+
+svq1_write_header(s, s-pict_type);
 for (i = 0; i  3; i++)
 if (svq1_encode_plane(s, i,
   pict-data[i],
@@ -623,7 +625,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 flush_put_bits(s-pb);
 
 pkt-size = put_bits_count(s-pb) / 8;
-if (p-pict_type == AV_PICTURE_TYPE_I)
+if (s-pict_type == AV_PICTURE_TYPE_I)
 

[libav-devel] [PATCH 13/13] Deprecate avctx.coded_frame

2015-05-19 Thread Vittorio Giovara
The rationale is that before the alternative AVPacketCodingParams API,
in most cases coded_frame was only used to communicate key_frame,
pict_type and quality to the caller (or a few other random fields).

These values are not required for the encoding or muxing, and only serve
a pure parametrical value. Additionally, it is per-frame data, and
the new AVPacketCodingParams API is directly associated with the packet
they belong to.

There was agreement that there was no usecase for coded_frame, as it is
a full-sized AVFrame container used for just 2-3 int-sized properties,
which shouldn't even belong into the AVCodecContext in the first place.

Now key_frame is exported via the appropriate avpacket.flags, which
is something already in place since several years, and all the others
compression values (pict_type, quality and error) are exported via
AVPacketCodingParams packet side data.

Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
 doc/APIchanges |  3 +++
 libavcodec/avcodec.h   |  5 +
 libavcodec/pthread_frame.c |  4 
 libavcodec/utils.c | 18 ++
 libavcodec/version.h   |  5 -
 5 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 08bd913..d45b6ab 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxx - lavc 56.25.1
+  Deprecate avctx.coded_frame in favour of AVPacketCodingParams-style 
reporting.
+
 2015-xx-xx - xxx - lavc 56.25.0 - avcodec.h
   Add AV_PKT_DATA_CODING_PARAMS and to carry AVPacket compression parameters
   in the form of an AVPacketCodingParams structure.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index eb28e7b..4323933 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2556,12 +2556,17 @@ typedef struct AVCodecContext {
 attribute_deprecated int lowres;
 #endif
 
+#if FF_API_CODED_FRAME
 /**
  * the picture in the bitstream
  * - encoding: Set by libavcodec.
  * - decoding: unused
+ *
+ * @deprecated use AVStats side data instead
  */
+attribute_deprecated
 AVFrame *coded_frame;
+#endif /* FF_API_CODED_FRAME */
 
 /**
  * thread count
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index effc9a5..c760ba2 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -215,7 +215,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 
 if (for_user) {
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
 dst-coded_frame = src-coded_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 } else {
 if (dst-codec-update_thread_context)
 err = dst-codec-update_thread_context(dst, src);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 52d0bcc..779d8f2 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1186,11 +1186,15 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 
 if (av_codec_is_encoder(avctx-codec)) {
 int i;
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
 avctx-coded_frame = av_frame_alloc();
 if (!avctx-coded_frame) {
 ret = AVERROR(ENOMEM);
 goto free_and_end;
 }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 if (avctx-codec-sample_fmts) {
 for (i = 0; avctx-codec-sample_fmts[i] != AV_SAMPLE_FMT_NONE; 
i++) {
 if (avctx-sample_fmt == avctx-codec-sample_fmts[i])
@@ -1318,7 +1322,11 @@ free_and_end:
 av_opt_free(avctx-priv_data);
 av_opt_free(avctx);
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
 av_frame_free(avctx-coded_frame);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
 av_dict_free(tmp);
 av_freep(avctx-priv_data);
@@ -1533,7 +1541,9 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
 
 ret = avctx-codec-encode2(avctx, avpkt, frame, got_packet_ptr);
 if (!ret) {
+#if FF_API_CODED_FRAME
 AVPacketCodingParams *params;
+#endif /* FF_API_CODED_FRAME */
 
 if (!*got_packet_ptr)
 avpkt-size = 0;
@@ -1546,6 +1556,8 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
 avpkt-data = avpkt-buf-data;
 }
 
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
 params = (AVPacketCodingParams *)
 av_packet_get_side_data(avpkt, AV_PKT_DATA_CODING_PARAMS, NULL);
 if (params) {
@@ -1561,6 +1573,8 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
 cf-sample_aspect_ratio = frame-sample_aspect_ratio;
 cf-pts = frame-pts;
 }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif /* FF_API_CODED_FRAME */
 
 avctx-frame_number++;
 }
@@ -1857,7 +1871,11 @@ av_cold int avcodec_close(AVCodecContext *avctx)
 av_freep(avctx-priv_data);
 if (av_codec_is_encoder(avctx-codec)) 

[libav-devel] [PATCH 03/13] roqvideoenc: Skip assigning coded_frame

2015-05-19 Thread Vittorio Giovara
Its field are never initialized to begin with.
---
 libavcodec/roqvideoenc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index 872bee8..32dabae 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -955,8 +955,6 @@ static int roq_encode_video(RoqContext *enc)
 reconstruct_and_encode_image(enc, tempData, enc-width, enc-height,
  enc-width*enc-height/64);
 
-enc-avctx-coded_frame = enc-current_frame;
-
 /* Rotate frame history */
 FFSWAP(AVFrame *, enc-current_frame, enc-last_frame);
 FFSWAP(motion_vect *, enc-last_motion4, enc-this_motion4);
-- 
1.9.5 (Apple Git-50.3)

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


[libav-devel] [PATCH 02/13] Drop a few peculiar usages of coded_frame

2015-05-19 Thread Vittorio Giovara
Do not overwrite its pointer, and do not fill it twice.

All exported fields are still correctly initialized in the compatibility
layer, taking place at the end of encode_frame().

Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
 avconv.c| 2 --
 libavcodec/a64multienc.c| 8 +++-
 libavcodec/dnxhdenc.c   | 1 -
 libavcodec/ffv1enc.c| 8 
 libavcodec/libschroedingerenc.c | 3 +--
 libavcodec/libvpxenc.c  | 1 -
 libavcodec/libxavs.c| 1 -
 libavcodec/mpegvideo_enc.c  | 2 --
 libavdevice/v4l2.c  | 6 --
 9 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/avconv.c b/avconv.c
index 275c3eb..0174854 100644
--- a/avconv.c
+++ b/avconv.c
@@ -548,8 +548,6 @@ static void do_video_out(AVFormatContext *s,
 /* raw pictures are written as AVPicture structure to
avoid any copies. We support temporarily the older
method. */
-enc-coded_frame-interlaced_frame = in_picture-interlaced_frame;
-enc-coded_frame-top_field_first  = in_picture-top_field_first;
 pkt.data   = (uint8_t *)in_picture;
 pkt.size   =  sizeof(AVPicture);
 pkt.pts= av_rescale_q(in_picture-pts, enc-time_base, 
ost-st-time_base);
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index d742dee..969a071 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -44,7 +44,8 @@ static const int mc_colors[5]={0x0,0xb,0xc,0xf,0x1};
 //static const int mc_colors[5]={0x0,0x8,0xa,0xf,0x7};
 //static const int mc_colors[5]={0x0,0x9,0x8,0xa,0x3};
 
-static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)
+static void to_meta_with_crop(AVCodecContext *avctx,
+  const AVFrame *p, int *dest)
 {
 int blockx, blocky, x, y;
 int luma = 0;
@@ -252,7 +253,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
  const AVFrame *pict, int *got_packet)
 {
 A64Context *c = avctx-priv_data;
-AVFrame *const p = avctx-coded_frame;
+const AVFrame *p = pict;
 
 int frame;
 int x, y;
@@ -296,9 +297,6 @@ static int a64multi_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 } else {
 /* fill up mc_meta_charset with data until lifetime exceeds */
 if (c-mc_frame_counter  c-mc_lifetime) {
-*p = *pict;
-p-pict_type = AV_PICTURE_TYPE_I;
-p-key_frame = 1;
 to_meta_with_crop(avctx, p, meta + 32000 * c-mc_frame_counter);
 c-mc_frame_counter++;
 if (c-next_pts == AV_NOPTS_VALUE)
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index dd7d8d1..f28c338 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -1022,7 +1022,6 @@ static void dnxhd_load_picture(DNXHDEncContext *ctx, 
const AVFrame *frame)
 ctx-thread[i]-dct_uv_offset = ctx-m.uvlinesize*8;
 }
 
-ctx-m.avctx-coded_frame-interlaced_frame = frame-interlaced_frame;
 ctx-cur_field = frame-interlaced_frame  !frame-top_field_first;
 }
 
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index f689bd9..2ef2913 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -863,12 +863,12 @@ static void encode_slice_header(FFV1Context *f, 
FFV1Context *fs)
 put_symbol(c, state, f-plane[j].quant_table_index, 0);
 av_assert0(f-plane[j].quant_table_index == f-avctx-context_model);
 }
-if (!f-avctx-coded_frame-interlaced_frame)
+if (!f-frame-interlaced_frame)
 put_symbol(c, state, 3, 0);
 else
-put_symbol(c, state, 1 + !f-avctx-coded_frame-top_field_first, 0);
-put_symbol(c, state, f-avctx-coded_frame-sample_aspect_ratio.num, 0);
-put_symbol(c, state, f-avctx-coded_frame-sample_aspect_ratio.den, 0);
+put_symbol(c, state, 1 + !f-frame-top_field_first, 0);
+put_symbol(c, state, f-avctx-sample_aspect_ratio.num, 0);
+put_symbol(c, state, f-avctx-sample_aspect_ratio.den, 0);
 }
 
 static int encode_slice(AVCodecContext *c, void *arg)
diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c
index b2c492b..d99ba69 100644
--- a/libavcodec/libschroedingerenc.c
+++ b/libavcodec/libschroedingerenc.c
@@ -392,8 +392,7 @@ static int libschroedinger_encode_frame(AVCodecContext 
*avctx, AVPacket *pkt,
 /* Use the frame number of the encoded frame as the pts. It is OK to
  * do so since Dirac is a constant frame rate codec. It expects input
  * to be of constant frame rate. */
-pkt-pts =
-avctx-coded_frame-pts = p_frame_output-frame_num;
+pkt-pts = p_frame_output-frame_num;
 pkt-dts = p_schro_params-dts++;
 enc_size = p_frame_output-size;
 
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 4164769..ec8f1f1 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -397,7 +397,6 @@ static int storeframe(AVCodecContext *avctx, 

[libav-devel] [PATCH 00/13] coded_frame v2

2015-05-19 Thread Vittorio Giovara
In this set, the new structure name is used, AVPacketCodingParams,
along with the appropriate side data type. The compatibility layer
has been extended to report other (random?) fields set by various
encoder.

Cheers,
Vittorio

Vittorio Giovara (13):
  Introduce AVPacketCodingParams to carry compression parameters
  Drop a few peculiar usages of coded_frame
  roqvideoenc: Skip assigning coded_frame
  libvpxenc: Do not entangle coded_frame
  proresenc: Do not entangle coded_frame
  svq1enc: Do not entangle coded_frame
  ffv1enc: Keep coded_frame.key_frame a write-only variable
  libtheoraenc: Keep coded_frame.key_frame a write-only variable
  qtrleenc: Keep coded_frame.key_frame a write-only variable
  lavc: Gather all coded_frame allocation and free functions to a single
place
  lavc: Replace every instance of coded_frame with AVPacketCodingParams
  avconv: Use the new AVPacketCodingParams API
  Deprecate avctx.coded_frame

 avconv.c| 41 +-
 avconv.h|  4 +++
 avconv_opt.c|  9 ++
 doc/APIchanges  |  7 +
 libavcodec/a64multienc.c| 21 +
 libavcodec/alacenc.c|  7 -
 libavcodec/aliaspixenc.c| 23 +++
 libavcodec/asvenc.c | 25 
 libavcodec/avcodec.h| 28 ++
 libavcodec/bmpenc.c | 17 +++
 libavcodec/cljrenc.c| 24 +++
 libavcodec/dnxhdenc.c   | 19 +---
 libavcodec/dpxenc.c | 18 +++-
 libavcodec/dvenc.c  | 22 --
 libavcodec/ffv1.h   |  1 +
 libavcodec/ffv1enc.c| 29 +-
 libavcodec/flashsvenc.c | 24 +++
 libavcodec/gif.c| 13 +++--
 libavcodec/huffyuvenc.c | 13 +++--
 libavcodec/internal.h   |  5 
 libavcodec/jpeglsenc.c  | 18 +++-
 libavcodec/lclenc.c | 13 +++--
 libavcodec/libopencore-amr.c|  1 -
 libavcodec/libopenjpegenc.c |  8 -
 libavcodec/libschroedingerenc.c | 25 +---
 libavcodec/libtheoraenc.c   | 22 +-
 libavcodec/libvpxenc.c  | 35 ++
 libavcodec/libx264.c| 23 ---
 libavcodec/libx265.c| 21 +++--
 libavcodec/libxavs.c| 23 +++
 libavcodec/libxvid.c| 29 +-
 libavcodec/ljpegenc.c   | 13 -
 libavcodec/mpegvideo_enc.c  | 17 +++
 libavcodec/pamenc.c | 24 +++
 libavcodec/pcm.c| 11 ---
 libavcodec/pcxenc.c | 24 +++
 libavcodec/pngenc.c | 19 
 libavcodec/pnmenc.c | 31 
 libavcodec/proresenc.c  | 27 -
 libavcodec/pthread_frame.c  |  4 +++
 libavcodec/qsvenc.c | 20 +++--
 libavcodec/qtrleenc.c   | 34 +++--
 libavcodec/rawenc.c | 18 
 libavcodec/roqvideoenc.c|  2 --
 libavcodec/sgienc.c | 18 +++-
 libavcodec/sunrastenc.c | 17 +++
 libavcodec/svq1enc.c| 43 +++
 libavcodec/svq1enc.h|  4 +++
 libavcodec/targaenc.c   | 24 +++
 libavcodec/tiffenc.c| 25 
 libavcodec/utils.c  | 65 +++--
 libavcodec/utvideoenc.c | 14 ++---
 libavcodec/v210enc.c| 18 +++-
 libavcodec/v410enc.c| 22 +++---
 libavcodec/version.h|  7 +++--
 libavcodec/xbmenc.c | 23 +++
 libavcodec/xwdenc.c | 25 +++-
 libavcodec/zmbvenc.c| 19 ++--
 libavdevice/v4l2.c  |  6 
 libavformat/dump.c  | 23 +++
 60 files changed, 507 insertions(+), 658 deletions(-)

-- 
1.9.5 (Apple Git-50.3)

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


[libav-devel] [PATCH 01/13] Introduce AVPacketCodingParams to carry compression parameters

2015-05-19 Thread Vittorio Giovara
Add an helper function and a compatibility layer for exporting
information through coded_frame.

Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
A small fixup/leftover, right on the first patch. ;-;
Vittorio

 doc/APIchanges|  4 
 libavcodec/avcodec.h  | 23 +++
 libavcodec/internal.h |  5 +
 libavcodec/utils.c| 37 +
 libavcodec/version.h  |  2 +-
 libavformat/dump.c| 23 +++
 6 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5d39ec6..08bd913 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxx - lavc 56.25.0 - avcodec.h
+  Add AV_PKT_DATA_CODING_PARAMS and to carry AVPacket compression parameters
+  in the form of an AVPacketCodingParams structure.
+
 2015-xx-xx - xxx - lavc 56.23.0
   Add av_vda_default_init2.
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3440126..eb28e7b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -853,6 +853,23 @@ typedef struct AVPanScan{
  */
 #define AV_GET_BUFFER_FLAG_REF (1  0)
 
+typedef struct AVPacketCodingParams {
+/**
+ * Picture type of the frame contained in the packet.
+ */
+enum AVPictureType pict_type;
+
+/**
+ * Quality after compression, between 1 (good) and FF_LAMBDA_MAX (bad).
+ */
+int quality;
+
+/**
+ * Compression error for each data pointer.
+ */
+uint64_t error[AV_NUM_DATA_POINTERS];
+} AVPacketCodingParams;
+
 /**
  * @defgroup lavc_packet AVPacket
  *
@@ -927,6 +944,12 @@ enum AVPacketSideDataType {
  * to enum AVAudioServiceType.
  */
 AV_PKT_DATA_AUDIO_SERVICE_TYPE,
+
+/**
+ * This side data should be associated with a video stream and corresponds
+ * to statistical data, as described in AVPacketCodingParams.
+ */
+AV_PKT_DATA_CODING_PARAMS,
 };
 
 typedef struct AVPacketSideData {
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 634400f..6afbbda 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -219,6 +219,11 @@ int ff_side_data_update_matrix_encoding(AVFrame *frame,
 enum AVMatrixEncoding matrix_encoding);
 
 /**
+ * Allocate and initialize an AV_PKT_DATA_CODING_PARAMS side data.
+ */
+int ff_packet_default_coding_params(AVPacket *pkt);
+
+/**
  * Select the (possibly hardware accelerated) pixel format.
  * This is a wrapper around AVCodecContext.get_format() and should be used
  * instead of calling get_format() directly.
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index c9ae19b..0a98138 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -177,6 +177,23 @@ int ff_side_data_update_matrix_encoding(AVFrame *frame,
 return 0;
 }
 
+int ff_packet_default_coding_params(AVPacket *pkt)
+{
+int i;
+AVPacketCodingParams *params = (AVPacketCodingParams *)
+av_packet_new_side_data(pkt, AV_PKT_DATA_CODING_PARAMS,
+sizeof(AVPacketCodingParams));
+if (!params)
+return AVERROR(ENOMEM);
+
+params-pict_type = AV_PICTURE_TYPE_I;
+params-quality = 0;
+for (i = 0; i  AV_NUM_DATA_POINTERS; i++)
+params-error[i] = 0;
+
+return 0;
+}
+
 #if HAVE_SIMD_ALIGN_16
 #   define STRIDE_ALIGN 16
 #else
@@ -1509,6 +1526,8 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
 
 ret = avctx-codec-encode2(avctx, avpkt, frame, got_packet_ptr);
 if (!ret) {
+AVPacketCodingParams *params;
+
 if (!*got_packet_ptr)
 avpkt-size = 0;
 else if (!(avctx-codec-capabilities  CODEC_CAP_DELAY))
@@ -1520,6 +1539,24 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
 avpkt-data = avpkt-buf-data;
 }
 
+params = (AVPacketCodingParams *)
+av_packet_get_side_data(avpkt, AV_PKT_DATA_CODING_PARAMS, NULL);
+if (params) {
+int i;
+AVFrame *cf = avctx-coded_frame;
+cf-key_frame = avpkt-flags  AV_PKT_FLAG_KEY;
+cf-pict_type = params-pict_type;
+cf-quality   = params-quality;
+for (i = 0; i  AV_NUM_DATA_POINTERS; i++)
+avctx-coded_frame-error[i] = params-error[i];
+if (frame) {
+cf-interlaced_frame= frame-interlaced_frame;
+cf-top_field_first = frame-top_field_first;
+cf-sample_aspect_ratio = frame-sample_aspect_ratio;
+cf-pts = frame-pts;
+}
+}
+
 avctx-frame_number++;
 }
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index c478ca3..c57bd85 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 #include libavutil/version.h
 
 #define LIBAVCODEC_VERSION_MAJOR 56
-#define 

[libav-devel] [PATCH 09/13] qtrleenc: Keep coded_frame.key_frame a write-only variable

2015-05-19 Thread Vittorio Giovara
---
 libavcodec/qtrleenc.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index 7c98bea..91dbb8b 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -57,6 +57,9 @@ typedef struct QtrleEncContext {
  * Will contain at ith position the number of consecutive pixels equal to 
the previous
  * frame starting from pixel i */
 uint8_t* skip_table;
+
+/** Encoded frame is a key frame */
+int key_frame;
 } QtrleEncContext;
 
 static av_cold int qtrle_encode_end(AVCodecContext *avctx)
@@ -159,7 +162,7 @@ static void qtrle_encode_line(QtrleEncContext *s, const 
AVFrame *p, int line, ui
 
 for (i = width - 1; i = 0; i--) {
 
-if (!s-avctx-coded_frame-key_frame  !memcmp(this_line, prev_line, 
s-pixel_size))
+if (!s-key_frame  !memcmp(this_line, prev_line, s-pixel_size))
 skipcount = FFMIN(skipcount + 1, MAX_RLE_SKIP);
 else
 skipcount = 0;
@@ -263,7 +266,7 @@ static int encode_frame(QtrleEncContext *s, const AVFrame 
*p, uint8_t *buf)
 int end_line = s-avctx-height;
 uint8_t *orig_buf = buf;
 
-if (!s-avctx-coded_frame-key_frame) {
+if (!s-key_frame) {
 unsigned line_size = s-avctx-width * s-pixel_size;
 for (start_line = 0; start_line  s-avctx-height; start_line++)
 if (memcmp(p-data[0] + start_line*p-linesize[0],
@@ -313,11 +316,11 @@ static int qtrle_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 if (avctx-gop_size == 0 || (s-avctx-frame_number % avctx-gop_size) == 
0) {
 /* I-Frame */
 p-pict_type = AV_PICTURE_TYPE_I;
-p-key_frame = 1;
+s-key_frame = 1;
 } else {
 /* P-Frame */
 p-pict_type = AV_PICTURE_TYPE_P;
-p-key_frame = 0;
+s-key_frame = 0;
 }
 
 pkt-size = encode_frame(s, pict, pkt-data);
@@ -326,7 +329,7 @@ static int qtrle_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 av_picture_copy(s-previous_frame, (const AVPicture *)pict,
 avctx-pix_fmt, avctx-width, avctx-height);
 
-if (p-key_frame)
+if (s-key_frame)
 pkt-flags |= AV_PKT_FLAG_KEY;
 *got_packet = 1;
 
-- 
1.9.5 (Apple Git-50.3)

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


[libav-devel] [PATCH 12/13] avconv: Use the new AVPacketCodingParams API

2015-05-19 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
 avconv.c | 39 ---
 avconv.h |  4 
 avconv_opt.c |  9 +
 3 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/avconv.c b/avconv.c
index 0174854..64c2760 100644
--- a/avconv.c
+++ b/avconv.c
@@ -190,6 +190,7 @@ static void avconv_cleanup(int ret)
 av_freep(ost-forced_keyframes);
 av_freep(ost-avfilter);
 av_freep(ost-logfile_prefix);
+av_freep(ost-last_params);
 
 avcodec_free_context(ost-enc_ctx);
 
@@ -335,7 +336,15 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, 
OutputStream *ost)
 }
 ost-frame_number++;
 }
-
+if (avctx-codec_type == AVMEDIA_TYPE_VIDEO) {
+uint8_t *s = av_packet_get_side_data(pkt, AV_PKT_DATA_CODING_PARAMS,
+ NULL);
+if (s) {
+ost-params_recv = 1;
+memcpy(ost-last_params, s, sizeof(AVPacketCodingParams));
+} else
+ost-params_recv = 0;
+}
 while (bsfc) {
 AVPacket new_pkt = *pkt;
 int a = av_bitstream_filter_filter(bsfc, avctx, NULL,
@@ -620,10 +629,16 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 enc = ost-enc_ctx;
 if (enc-codec_type == AVMEDIA_TYPE_VIDEO) {
 frame_number = ost-frame_number;
-fprintf(vstats_file, frame= %5d q= %2.1f , frame_number, 
enc-coded_frame-quality / (float)FF_QP2LAMBDA);
-if (enc-flagsCODEC_FLAG_PSNR)
-fprintf(vstats_file, PSNR= %6.2f , 
psnr(enc-coded_frame-error[0] / (enc-width * enc-height * 255.0 * 255.0)));
-
+fprintf(vstats_file, frame= %5d, frame_number);
+if (ost-params_recv) {
+fprintf(vstats_file,  q= %2.1f ,
+ost-last_params-quality / (float)FF_QP2LAMBDA);
+if (enc-flags  CODEC_FLAG_PSNR) {
+double vpsnr = psnr(ost-last_params-error[0] /
+(enc-width * enc-height * 255.0 * 
255.0));
+fprintf(vstats_file, PSNR= %6.2f , vpsnr);
+}
+}
 fprintf(vstats_file,f_size= %6d , frame_size);
 /* compute pts value */
 ti1 = ost-sync_opts * av_q2d(enc-time_base);
@@ -634,7 +649,9 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 avg_bitrate = (double)(ost-data_size * 8) / ti1 / 1000.0;
 fprintf(vstats_file, s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s 
avg_br= %7.1fkbits/s ,
(double)ost-data_size / 1024, ti1, bitrate, avg_bitrate);
-fprintf(vstats_file, type= %c\n, 
av_get_picture_type_char(enc-coded_frame-pict_type));
+if (ost-params_recv)
+fprintf(vstats_file, type= %c\n,
+av_get_picture_type_char(ost-last_params-pict_type));
 }
 }
 
@@ -905,8 +922,8 @@ static void print_report(int is_last_report, int64_t 
timer_start)
 float q = -1;
 ost = output_streams[i];
 enc = ost-enc_ctx;
-if (!ost-stream_copy  enc-coded_frame)
-q = enc-coded_frame-quality / (float)FF_QP2LAMBDA;
+if (!ost-stream_copy  ost-params_recv)
+q = ost-last_params-quality / (float)FF_QP2LAMBDA;
 if (vid  enc-codec_type == AVMEDIA_TYPE_VIDEO) {
 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), q=%2.1f , 
q);
 }
@@ -926,7 +943,7 @@ static void print_report(int is_last_report, int64_t 
timer_start)
 for (j = 0; j  32; j++)
 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), 
%X, (int)lrintf(log2(qp_histogram[j] + 1)));
 }
-if (enc-flagsCODEC_FLAG_PSNR) {
+if ((enc-flags  CODEC_FLAG_PSNR)  ost-params_recv) {
 int j;
 double error, error_sum = 0;
 double scale, scale_sum = 0;
@@ -934,10 +951,10 @@ static void print_report(int is_last_report, int64_t 
timer_start)
 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), 
PSNR=);
 for (j = 0; j  3; j++) {
 if (is_last_report) {
-error = enc-error[j];
+error = ost-last_params-error[j];
 scale = enc-width * enc-height * 255.0 * 255.0 * 
frame_number;
 } else {
-error = enc-coded_frame-error[j];
+error = ost-last_params-error[j];
 scale = enc-width * enc-height * 255.0 * 255.0;
 }
 if (j)
diff --git a/avconv.h b/avconv.h
index 5fddf98..7c69a9c 100644
--- a/avconv.h
+++ b/avconv.h
@@ -361,6 +361,10 @@ typedef struct OutputStream {
 // number of frames/samples sent to the encoder
 uint64_t frames_encoded;
 uint64_t samples_encoded;
+
+/* last coding parameters received */
+int params_recv;
+

[libav-devel] [PATCH 01/13] Introduce AVPacketCodingParams to carry compression parameters

2015-05-19 Thread Vittorio Giovara
Add an helper function and a compatibility layer for exporting
information through coded_frame.

Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
 doc/APIchanges|  4 
 libavcodec/avcodec.h  | 23 +++
 libavcodec/internal.h |  5 +
 libavcodec/utils.c| 35 +++
 libavcodec/version.h  |  2 +-
 libavformat/dump.c| 23 +++
 6 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5d39ec6..08bd913 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxx - lavc 56.25.0 - avcodec.h
+  Add AV_PKT_DATA_CODING_PARAMS and to carry AVPacket compression parameters
+  in the form of an AVPacketCodingParams structure.
+
 2015-xx-xx - xxx - lavc 56.23.0
   Add av_vda_default_init2.
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3440126..eb28e7b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -853,6 +853,23 @@ typedef struct AVPanScan{
  */
 #define AV_GET_BUFFER_FLAG_REF (1  0)
 
+typedef struct AVPacketCodingParams {
+/**
+ * Picture type of the frame contained in the packet.
+ */
+enum AVPictureType pict_type;
+
+/**
+ * Quality after compression, between 1 (good) and FF_LAMBDA_MAX (bad).
+ */
+int quality;
+
+/**
+ * Compression error for each data pointer.
+ */
+uint64_t error[AV_NUM_DATA_POINTERS];
+} AVPacketCodingParams;
+
 /**
  * @defgroup lavc_packet AVPacket
  *
@@ -927,6 +944,12 @@ enum AVPacketSideDataType {
  * to enum AVAudioServiceType.
  */
 AV_PKT_DATA_AUDIO_SERVICE_TYPE,
+
+/**
+ * This side data should be associated with a video stream and corresponds
+ * to statistical data, as described in AVPacketCodingParams.
+ */
+AV_PKT_DATA_CODING_PARAMS,
 };
 
 typedef struct AVPacketSideData {
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 634400f..6afbbda 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -219,6 +219,11 @@ int ff_side_data_update_matrix_encoding(AVFrame *frame,
 enum AVMatrixEncoding matrix_encoding);
 
 /**
+ * Allocate and initialize an AV_PKT_DATA_CODING_PARAMS side data.
+ */
+int ff_packet_default_coding_params(AVPacket *pkt);
+
+/**
  * Select the (possibly hardware accelerated) pixel format.
  * This is a wrapper around AVCodecContext.get_format() and should be used
  * instead of calling get_format() directly.
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index c9ae19b..48b7ac1 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -177,6 +177,23 @@ int ff_side_data_update_matrix_encoding(AVFrame *frame,
 return 0;
 }
 
+int ff_packet_default_coding_params(AVPacket *pkt)
+{
+int i;
+AVPacketCodingParams *params = (AVPacketCodingParams *)
+av_packet_new_side_data(pkt, AV_PKT_DATA_CODING_PARAMS,
+sizeof(AVPacketCodingParams));
+if (!params)
+return AVERROR(ENOMEM);
+
+params-pict_type = AV_PICTURE_TYPE_I;
+params-quality = 0;
+for (i = 0; i  AV_NUM_DATA_POINTERS; i++)
+params-error[i] = 0;
+
+return 0;
+}
+
 #if HAVE_SIMD_ALIGN_16
 #   define STRIDE_ALIGN 16
 #else
@@ -1509,6 +1526,8 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
 
 ret = avctx-codec-encode2(avctx, avpkt, frame, got_packet_ptr);
 if (!ret) {
+AVPacketCodingParams *params;
+
 if (!*got_packet_ptr)
 avpkt-size = 0;
 else if (!(avctx-codec-capabilities  CODEC_CAP_DELAY))
@@ -1520,6 +1539,22 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
 avpkt-data = avpkt-buf-data;
 }
 
+params = (AVPacketCodingParams *)
+av_packet_get_side_data(avpkt, AV_PKT_DATA_CODING_PARAMS, NULL);
+if (params) {
+int i;
+AVFrame *cf = avctx-coded_frame;
+cf-key_frame = avpkt-flags  AV_PKT_FLAG_KEY;
+cf-pict_type = params-pict_type;
+cf-quality   = params-quality;
+for (i = 0; i  AV_NUM_DATA_POINTERS; i++)
+avctx-coded_frame-error[i] = params-error[i];
+cf-interlaced_frame= frame-interlaced_frame;
+cf-top_field_first = frame-top_field_first;
+cf-sample_aspect_ratio = frame-sample_aspect_ratio;
+cf-pts = frame-pts;
+}
+
 avctx-frame_number++;
 }
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index c478ca3..c57bd85 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 #include libavutil/version.h
 
 #define LIBAVCODEC_VERSION_MAJOR 56
-#define LIBAVCODEC_VERSION_MINOR 24
+#define LIBAVCODEC_VERSION_MINOR 25
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define 

Re: [libav-devel] [PATCH] libvpx: Support all pixel formats available

2015-05-19 Thread James Almer
On 19/05/15 7:49 AM, Vittorio Giovara wrote:
 ---
 Another set of eyes for the pixel format mapping would be welcome.
 Vittorio
 
  libavcodec/libvpx.c| 26 ++
  libavcodec/libvpx.h|  2 ++
  libavcodec/libvpxdec.c |  4 ++--
  3 files changed, 30 insertions(+), 2 deletions(-)
 
 diff --git a/libavcodec/libvpx.c b/libavcodec/libvpx.c
 index 20f4484..5adad66 100644
 --- a/libavcodec/libvpx.c
 +++ b/libavcodec/libvpx.c
 @@ -33,3 +33,29 @@ int ff_vp9_check_experimental(AVCodecContext *avctx)
  }
  return 0;
  }
 +
 +enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img)
 +{
 +switch(img) {
 +case VPX_IMG_FMT_RGB24: return AV_PIX_FMT_RGB24;
 +case VPX_IMG_FMT_RGB565:return AV_PIX_FMT_RGB565BE;
 +case VPX_IMG_FMT_RGB555:return AV_PIX_FMT_RGB555BE;
 +case VPX_IMG_FMT_UYVY:  return AV_PIX_FMT_UYVY422;
 +case VPX_IMG_FMT_YUY2:  return AV_PIX_FMT_YUYV422;
 +case VPX_IMG_FMT_YVYU:  return AV_PIX_FMT_YVYU422;
 +case VPX_IMG_FMT_BGR24: return AV_PIX_FMT_BGR24;
 +case VPX_IMG_FMT_ARGB:  return AV_PIX_FMT_ARGB;
 +case VPX_IMG_FMT_ARGB_LE:   return AV_PIX_FMT_BGRA;
 +case VPX_IMG_FMT_RGB565_LE: return AV_PIX_FMT_RGB565LE;
 +case VPX_IMG_FMT_RGB555_LE: return AV_PIX_FMT_RGB555LE;
 +case VPX_IMG_FMT_I420:  return AV_PIX_FMT_YUV420P;

vp8 supports only this one. Every other pix_fmt is vp9 only and should be 
guarded by a
CONFIG_LIBVPX_VP9_DECODER preprocessor check.

 +case VPX_IMG_FMT_I422:  return AV_PIX_FMT_YUV422P;
 +case VPX_IMG_FMT_I444:  return AV_PIX_FMT_YUV444P;
 +case VPX_IMG_FMT_I440:  return AV_PIX_FMT_YUV440P;

This was added starting with libvpx 1.4.0. It will fail to compile with any 
prior version.
A quick preprocessor check to make sure this define is available is 
VPX_IMAGE_ABI_VERSION = 3

 +case VPX_IMG_FMT_444A:  return AV_PIX_FMT_YUVA444P;
 +case VPX_IMG_FMT_I42016:return AV_PIX_FMT_YUV420P16BE;
 +case VPX_IMG_FMT_I42216:return AV_PIX_FMT_YUV422P16BE;
 +case VPX_IMG_FMT_I44416:return AV_PIX_FMT_YUV444P16BE;

Likewise, these three were added with libvpx 1.4.0. Checking for 
VPX_IMG_FMT_HIGHBITDEPTH should
suffice here, or alternatively, the same abi version check as above if git 
snapshots before 1.4.0
was tagged are not important.
And the value of img-bit_depth should probably be checked instead and these 
high bitdepth pix_fmts
set accordingly.

 +default:return AV_PIX_FMT_NONE;
 +}
 +}
 diff --git a/libavcodec/libvpx.h b/libavcodec/libvpx.h
 index cb1ed09..79a05f4 100644
 --- a/libavcodec/libvpx.h
 +++ b/libavcodec/libvpx.h
 @@ -25,4 +25,6 @@
  
  int ff_vp9_check_experimental(AVCodecContext *avctx);
  
 +enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img);
 +
  #endif /* AVCODEC_LIBVPX_H */
 diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
 index 6052207..a1f9c22 100644
 --- a/libavcodec/libvpxdec.c
 +++ b/libavcodec/libvpxdec.c
 @@ -56,7 +56,6 @@ static av_cold int vpx_init(AVCodecContext *avctx,
  return AVERROR(EINVAL);
  }
  
 -avctx-pix_fmt = AV_PIX_FMT_YUV420P;
  return 0;
  }
  
 @@ -82,7 +81,8 @@ static int vp8_decode(AVCodecContext *avctx,
  }
  
  if ((img = vpx_codec_get_frame(ctx-decoder, iter))) {
 -if (img-fmt != VPX_IMG_FMT_I420) {
 +avctx-pix_fmt = ff_vpx_imgfmt_to_pixfmt(img-fmt);
 +if (avctx-pix_fmt == AV_PIX_FMT_NONE) {
  av_log(avctx, AV_LOG_ERROR, Unsupported output colorspace 
 (%d)\n,
 img-fmt);
  return AVERROR_INVALIDDATA;
 

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


Re: [libav-devel] [PATCH 10/10] ppc: vsx: Implement diff_pixels and get_pixels

2015-05-19 Thread Diego Biurrun
On Wed, May 13, 2015 at 01:46:51PM +0200, Luca Barbato wrote:
 --- a/libavcodec/ppc/pixblockdsp.c
 +++ b/libavcodec/ppc/pixblockdsp.c
 @@ -133,6 +133,40 @@ static void diff_pixels_altivec(int16_t *restrict block, 
 const uint8_t *s1,
  
 +static void diff_pixels_vsx(int16_t *restrict block, const uint8_t *s1,
 +const uint8_t *s2, int stride)
 +{
 +int i;
 +vec_s16 shorts1, shorts2;
 +for (i = 0; i  8; i++) {
 +shorts1 = vsx_ld_u8_s16(0, s1);
 +shorts2 = vsx_ld_u8_s16(0, s2);
 +
 +shorts1 = vec_sub(shorts1, shorts2);
 +
 +vec_vsx_st(shorts1, 0, block);
 +
 +s1+= stride;
 +s2+= stride;
 +block += 8;
 +}
 +}

You could reduce the scope of shorts1 and shorts2 by moving the declarations
into the block.

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


Re: [libav-devel] [PATCH 07/10] ppc: Restrict altivec to Big Endian

2015-05-19 Thread Luca Barbato
On 19/05/15 15:59, Diego Biurrun wrote:
 On Wed, May 13, 2015 at 01:46:48PM +0200, Luca Barbato wrote:
 In Little Endian the vec_ld/vec_st operations work as
 expected only for byte-vectors.
 ---
  libavcodec/ppc/apedsp_altivec.c   | 4 ++--
  libavcodec/ppc/audiodsp.c | 4 ++--
  libavcodec/ppc/dct-test.c | 2 +-
  libavcodec/ppc/fdctdsp.c  | 4 ++--
  libavcodec/ppc/fft_init.c | 4 ++--
  libavcodec/ppc/fmtconvert_altivec.c   | 4 ++--
  libavcodec/ppc/h264chroma_init.c  | 4 ++--
  libavcodec/ppc/h264dsp.c  | 4 ++--
  libavcodec/ppc/h264qpel.c | 4 ++--
  libavcodec/ppc/hpeldsp_altivec.c  | 4 ++--
  libavcodec/ppc/huffyuvdsp_altivec.c   | 4 ++--
  libavcodec/ppc/idctdsp.c  | 4 ++--
  libavcodec/ppc/me_cmp.c   | 4 ++--
  libavcodec/ppc/mpegaudiodsp_altivec.c | 4 ++--
  libavcodec/ppc/mpegvideo_altivec.c| 4 ++--
  libavcodec/ppc/mpegvideodsp.c | 4 ++--
  libavcodec/ppc/mpegvideoencdsp.c  | 4 ++--
  libavcodec/ppc/pixblockdsp.c  | 4 ++--
  libavcodec/ppc/svq1enc_altivec.c  | 4 ++--
  libavcodec/ppc/vc1dsp_altivec.c   | 4 ++--
  libavcodec/ppc/vorbisdsp_altivec.c| 4 ++--
  libavcodec/ppc/vp3dsp_altivec.c   | 4 ++--
  libavcodec/ppc/vp8dsp_altivec.c   | 4 ++--
  libavutil/ppc/float_dsp_init.c| 3 ++-
  libswscale/ppc/swscale_altivec.c  | 2 +-
  25 files changed, 48 insertions(+), 47 deletions(-)
 
 This looks like all instances of HAVE_ALTIVEC.  If so, it would be
 simpler and cleaner to just disable AltiVec in configure for little-endian.
 

Not all otherwise I wouldn't do that =) There are some instructions that
do not use anything beside uint8_t arrays.

lu

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


Re: [libav-devel] [PATCH 08/10] ppc: cpu: Add support for VSX and POWER8 extensions

2015-05-19 Thread Luca Barbato
On 19/05/15 16:03, Diego Biurrun wrote:
 Are these ifdefs necessary?  I.e. do headers w/o these flag definitions exist?

Yes they do. depending on your kernel/libc combination.

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


Re: [libav-devel] [PATCH 07/10] ppc: Restrict altivec to Big Endian

2015-05-19 Thread Diego Biurrun
On Wed, May 13, 2015 at 01:46:48PM +0200, Luca Barbato wrote:
 In Little Endian the vec_ld/vec_st operations work as
 expected only for byte-vectors.
 ---
  libavcodec/ppc/apedsp_altivec.c   | 4 ++--
  libavcodec/ppc/audiodsp.c | 4 ++--
  libavcodec/ppc/dct-test.c | 2 +-
  libavcodec/ppc/fdctdsp.c  | 4 ++--
  libavcodec/ppc/fft_init.c | 4 ++--
  libavcodec/ppc/fmtconvert_altivec.c   | 4 ++--
  libavcodec/ppc/h264chroma_init.c  | 4 ++--
  libavcodec/ppc/h264dsp.c  | 4 ++--
  libavcodec/ppc/h264qpel.c | 4 ++--
  libavcodec/ppc/hpeldsp_altivec.c  | 4 ++--
  libavcodec/ppc/huffyuvdsp_altivec.c   | 4 ++--
  libavcodec/ppc/idctdsp.c  | 4 ++--
  libavcodec/ppc/me_cmp.c   | 4 ++--
  libavcodec/ppc/mpegaudiodsp_altivec.c | 4 ++--
  libavcodec/ppc/mpegvideo_altivec.c| 4 ++--
  libavcodec/ppc/mpegvideodsp.c | 4 ++--
  libavcodec/ppc/mpegvideoencdsp.c  | 4 ++--
  libavcodec/ppc/pixblockdsp.c  | 4 ++--
  libavcodec/ppc/svq1enc_altivec.c  | 4 ++--
  libavcodec/ppc/vc1dsp_altivec.c   | 4 ++--
  libavcodec/ppc/vorbisdsp_altivec.c| 4 ++--
  libavcodec/ppc/vp3dsp_altivec.c   | 4 ++--
  libavcodec/ppc/vp8dsp_altivec.c   | 4 ++--
  libavutil/ppc/float_dsp_init.c| 3 ++-
  libswscale/ppc/swscale_altivec.c  | 2 +-
  25 files changed, 48 insertions(+), 47 deletions(-)

This looks like all instances of HAVE_ALTIVEC.  If so, it would be
simpler and cleaner to just disable AltiVec in configure for little-endian.

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


Re: [libav-devel] [PATCH 08/10] ppc: cpu: Add support for VSX and POWER8 extensions

2015-05-19 Thread Diego Biurrun
On Wed, May 13, 2015 at 01:46:49PM +0200, Luca Barbato wrote:
 --- a/libavutil/ppc/cpu.c
 +++ b/libavutil/ppc/cpu.c
 @@ -85,6 +85,14 @@ int ff_get_cpu_flags_ppc(void)
  if (buf[i] == AT_HWCAP) {
  if (buf[i + 1]  PPC_FEATURE_HAS_ALTIVEC)
  ret = AV_CPU_FLAG_ALTIVEC;
 +#ifdef PPC_FEATURE_HAS_VSX
 +if (buf[i + 1]  PPC_FEATURE_HAS_VSX)
 +ret |= AV_CPU_FLAG_VSX;
 +#endif
 +#ifdef PPC_FEATURE_ARCH_2_07
 +if (buf[i + 1]  PPC_FEATURE_HAS_POWER8)
 +ret |= AV_CPU_FLAG_POWER8;
 +#endif
  goto out;

Are these ifdefs necessary?  I.e. do headers w/o these flag definitions exist?

 @@ -118,8 +126,14 @@ out:
  proc_ver == PVR_POWER7   ||
  proc_ver == PVR_POWER8   ||
  proc_ver == PVR_CELL_PPU)
 -return AV_CPU_FLAG_ALTIVEC;
 -return 0;
 +ret = AV_CPU_FLAG_ALTIVEC;
 +if (proc_ver == PVR_POWER7 ||
 +proc_ver == PVR_POWER8)
 +ret |= AV_CPU_FLAG_VSX;
 +if (proc_ver == PVR_POWER8)
 +ret |= AV_CPU_FLAG_POWER8;
 +
 +return ret;

Aren't you skipping the following bit here:

if (proc_ver   0x8000)

?

 --- a/libavutil/ppc/cpu.h
 +++ b/libavutil/ppc/cpu.h
 @@ -24,5 +24,7 @@
  #include libavutil/cpu_internal.h
  
  #define PPC_ALTIVEC(flags) CPUEXT(flags, ALTIVEC)
 +#define PPC_VSX(flags) CPUEXT(flags, VSX)
 +#define PPC_POWER8(flags) CPUEXT(flags, POWER8)

Maintain vertical alignment, like the other cpu.h headers.

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


Re: [libav-devel] [PATCH 09/10] ppc: vsx: Implement float_dsp

2015-05-19 Thread Luca Barbato
On 19/05/15 16:07, Diego Biurrun wrote:
 On Wed, May 13, 2015 at 01:46:50PM +0200, Luca Barbato wrote:
 --- a/arch.mak
 +++ b/arch.mak
 @@ -5,6 +5,7 @@ OBJS-$(HAVE_VFP) += $(VFP-OBJS) $(VFP-OBJS-yes)
  OBJS-$(HAVE_NEON)+= $(NEON-OBJS)$(NEON-OBJS-yes)
  
  OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes)
 +OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes)
 
 vertical alignment
 
  OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes)
  OBJS-$(HAVE_YASM)+= $(YASM-OBJS)$(YASM-OBJS-yes)
 --- a/libavutil/ppc/float_dsp_altivec.c
 +++ b/libavutil/ppc/float_dsp_altivec.c
 @@ -98,7 +98,7 @@ void ff_vector_fmul_reverse_altivec(float *dst, const 
 float *src0,
  const float *src1, int len)
  {
  int i;
 -vec_f d, s0, s1, h0, l0, s2, s3
 +vec_f d, s0, s1, h0, l0, s2, s3;
  vec_f zero = (vec_f)vec_splat_u32(0);
 
 Looks like an unrelated bug fix for a previous patch.
 
 --- a/libavutil/ppc/float_dsp_init.c
 +++ b/libavutil/ppc/float_dsp_init.c
 @@ -24,18 +24,26 @@
  av_cold void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int bit_exact)
  {
 -if (!PPC_ALTIVEC(av_get_cpu_flags()))
 -return;
 
 IIUC VSX implies AltiVec, so this check could remain.
 
 Diego
 
 +if (HAVE_BIGENDIAN  PPC_ALTIVEC(av_get_cpu_flags())) {
 +fdsp-vector_fmul = ff_vector_fmul_altivec;
 +fdsp-vector_fmul_add = ff_vector_fmul_add_altivec;
 +fdsp-vector_fmul_reverse = ff_vector_fmul_reverse_altivec;
  
 +if (!bit_exact) {
 +fdsp-vector_fmul_window = ff_vector_fmul_window_altivec;
 +}
 +}
 +if (PPC_VSX(av_get_cpu_flags())) {
 +fdsp-vector_fmul = ff_vector_fmul_vsx;
 +fdsp-vector_fmul_add = ff_vector_fmul_add_vsx;
 +fdsp-vector_fmul_reverse = ff_vector_fmul_reverse_vsx;
 +
 +if (!bit_exact) {
 +fdsp-vector_fmul_window = ff_vector_fmul_window_vsx;
 +}
 
 You could align the = while you're at it.
 

You are reviewing a superseded set.

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


Re: [libav-devel] [PATCH 06/10] ppc: configure: Add POWER8 support

2015-05-19 Thread Luca Barbato
On 19/05/15 16:53, Diego Biurrun wrote:
 On Thu, May 14, 2015 at 01:19:49AM +0200, Luca Barbato wrote:
 --- a/configure
 +++ b/configure
 @@ -3306,19 +3312,28 @@ elif enabled ppc; then
 -power[3-7]*)
 +power[3-6]*)
  cpuflags=-mcpu=$cpu
 +disable vsx
 +;;
 +power[7-8]*)
 +cpuflags=-mcpu=$cpu
 +enable ldbrx
  ;;
 
 Enabling ldbrx for power7 seems somewhat unrelated.

I can splice it out but is sort of related, power7 wasn't really
supported beside knowing it exists...

 
 @@ -3995,6 +4010,15 @@ EOF
  enabled altivec || warn Altivec disabled, possibly missing --cpu 
 flag
  fi
  
 +if enabled vsx; then
 +check_cflags -mvsx 
 +check_builtin vec_vsx_ld altivec.h __builtin_vec_vsx_ld || 
 disable vsx
 
 Indent the check_builtin call.

Sure.

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


Re: [libav-devel] [PATCH 06/10] ppc: configure: Add POWER8 support

2015-05-19 Thread Diego Biurrun
On Thu, May 14, 2015 at 01:19:49AM +0200, Luca Barbato wrote:
 --- a/configure
 +++ b/configure
 @@ -3306,19 +3312,28 @@ elif enabled ppc; then
 -power[3-7]*)
 +power[3-6]*)
  cpuflags=-mcpu=$cpu
 +disable vsx
 +;;
 +power[7-8]*)
 +cpuflags=-mcpu=$cpu
 +enable ldbrx
  ;;

Enabling ldbrx for power7 seems somewhat unrelated.

 @@ -3995,6 +4010,15 @@ EOF
  enabled altivec || warn Altivec disabled, possibly missing --cpu 
 flag
  fi
  
 +if enabled vsx; then
 +check_cflags -mvsx 
 +check_builtin vec_vsx_ld altivec.h __builtin_vec_vsx_ld || 
 disable vsx

Indent the check_builtin call.

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


Re: [libav-devel] [PATCH 1/3] lavf: add a mechanism for raising events through omission

2015-05-19 Thread Anton Khirnov
Quoting John Högberg (2015-05-19 00:14:02)
 Hi,
 
 Anton Khirnov wrote:
  maybe I'm not seeing something obvious, but why don't you flip the meaning 
  of
  the flag, thus avoiding the need for the new function?
 
 That's a good question. I implemented it that way at first, but I decided to 
 try
 this route since I wanted to avoid forcing the user to add special-cases in
 their event-handling code. Essentially, my line if thinking was;
 
 If you handle a no carrier event you know for certain that no carrier was
 present regardless of format because the demultiplexer would not raise the 
 event
 unless it was relevant. It also fits fairly well into an event since its
 opposite is the norm.
 
 If you handle the lack of a carrier present event, is the carrier actually 
 gone, or is the idea of a stream carrier not applicable for the format in
 question? This avoids the need for an explicit reset function, but we'd need 
 to
 provide a format has separate stream carriers flag which the user needs to
 honor before handling the event, and the idea of the norm being an event 
 feels a
 bit off.

Well, as you're saying elsewhere, the actual meaning of this flag is
very much format-dependent. So the caller has to make some
format-specifica assumptions anyway.

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

Re: [libav-devel] [PATCH 01/10] ppc: avutil: Drop a potentially dangerous workaround

2015-05-19 Thread Diego Biurrun
On Thu, May 14, 2015 at 01:19:44AM +0200, Luca Barbato wrote:
 The compiler is free to optimize in any sort of way such expression.

The compiler is free to optimize such expressions in any sort of way.

probably OK

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


Re: [libav-devel] [PATCH] vmnc: Delay pixel size check

2015-05-19 Thread Luca Barbato
On 19/05/15 17:57, Vittorio Giovara wrote:
 Some clients incorrectly set 24 as bits_per_coded_sample, while
 the actual value is preseved in one of the headers.
 In order to work around this, delay the check until decode_frame().
 
 Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
 ---
  libavcodec/vmnc.c | 19 +++
  1 file changed, 15 insertions(+), 4 deletions(-)
 

Possibly Ok.

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


Re: [libav-devel] [PATCH 06/10] ppc: configure: Add POWER8 support

2015-05-19 Thread Luca Barbato
On 19/05/15 18:00, Diego Biurrun wrote:
 On Tue, May 19, 2015 at 05:38:23PM +0200, Luca Barbato wrote:
 On 19/05/15 16:53, Diego Biurrun wrote:
 On Thu, May 14, 2015 at 01:19:49AM +0200, Luca Barbato wrote:
 --- a/configure
 +++ b/configure
 @@ -3306,19 +3312,28 @@ elif enabled ppc; then
 -power[3-7]*)
 +power[3-6]*)
  cpuflags=-mcpu=$cpu
 +disable vsx
 +;;
 +power[7-8]*)
 +cpuflags=-mcpu=$cpu
 +enable ldbrx
  ;;

 Enabling ldbrx for power7 seems somewhat unrelated.

 I can splice it out but is sort of related, power7 wasn't really
 supported beside knowing it exists...
 
 Please do, it's surprising to see both power7 and power8 support
 being added under the commit title.
 

I can change the topic to Add VSX support to make it more correct.

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


Re: [libav-devel] [PATCH 06/10] ppc: configure: Add POWER8 support

2015-05-19 Thread Diego Biurrun
On Tue, May 19, 2015 at 05:38:23PM +0200, Luca Barbato wrote:
 On 19/05/15 16:53, Diego Biurrun wrote:
  On Thu, May 14, 2015 at 01:19:49AM +0200, Luca Barbato wrote:
  --- a/configure
  +++ b/configure
  @@ -3306,19 +3312,28 @@ elif enabled ppc; then
  -power[3-7]*)
  +power[3-6]*)
   cpuflags=-mcpu=$cpu
  +disable vsx
  +;;
  +power[7-8]*)
  +cpuflags=-mcpu=$cpu
  +enable ldbrx
   ;;
  
  Enabling ldbrx for power7 seems somewhat unrelated.
 
 I can splice it out but is sort of related, power7 wasn't really
 supported beside knowing it exists...

Please do, it's surprising to see both power7 and power8 support
being added under the commit title.

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


Re: [libav-devel] [PATCH 09/10] ppc: vsx: Implement float_dsp

2015-05-19 Thread Diego Biurrun
On Wed, May 13, 2015 at 01:46:50PM +0200, Luca Barbato wrote:
 --- a/arch.mak
 +++ b/arch.mak
 @@ -5,6 +5,7 @@ OBJS-$(HAVE_VFP) += $(VFP-OBJS) $(VFP-OBJS-yes)
  OBJS-$(HAVE_NEON)+= $(NEON-OBJS)$(NEON-OBJS-yes)
  
  OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes)
 +OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes)

vertical alignment

  OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes)
  OBJS-$(HAVE_YASM)+= $(YASM-OBJS)$(YASM-OBJS-yes)
 --- a/libavutil/ppc/float_dsp_altivec.c
 +++ b/libavutil/ppc/float_dsp_altivec.c
 @@ -98,7 +98,7 @@ void ff_vector_fmul_reverse_altivec(float *dst, const float 
 *src0,
  const float *src1, int len)
  {
  int i;
 -vec_f d, s0, s1, h0, l0, s2, s3
 +vec_f d, s0, s1, h0, l0, s2, s3;
  vec_f zero = (vec_f)vec_splat_u32(0);

Looks like an unrelated bug fix for a previous patch.

 --- a/libavutil/ppc/float_dsp_init.c
 +++ b/libavutil/ppc/float_dsp_init.c
 @@ -24,18 +24,26 @@
  av_cold void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int bit_exact)
  {
 -if (!PPC_ALTIVEC(av_get_cpu_flags()))
 -return;

IIUC VSX implies AltiVec, so this check could remain.

Diego

 +if (HAVE_BIGENDIAN  PPC_ALTIVEC(av_get_cpu_flags())) {
 +fdsp-vector_fmul = ff_vector_fmul_altivec;
 +fdsp-vector_fmul_add = ff_vector_fmul_add_altivec;
 +fdsp-vector_fmul_reverse = ff_vector_fmul_reverse_altivec;
  
 +if (!bit_exact) {
 +fdsp-vector_fmul_window = ff_vector_fmul_window_altivec;
 +}
 +}
 +if (PPC_VSX(av_get_cpu_flags())) {
 +fdsp-vector_fmul = ff_vector_fmul_vsx;
 +fdsp-vector_fmul_add = ff_vector_fmul_add_vsx;
 +fdsp-vector_fmul_reverse = ff_vector_fmul_reverse_vsx;
 +
 +if (!bit_exact) {
 +fdsp-vector_fmul_window = ff_vector_fmul_window_vsx;
 +}

You could align the = 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] vmnc: Delay pixel size check

2015-05-19 Thread Diego Biurrun
On Tue, May 19, 2015 at 04:57:46PM +0100, Vittorio Giovara wrote:
 Some clients incorrectly set 24 as bits_per_coded_sample, while
 the actual value is preseved in one of the headers.

prese_R_ved

present in one of the file headers is probably more accurate.

 --- a/libavcodec/vmnc.c
 +++ b/libavcodec/vmnc.c
 @@ -419,10 +419,18 @@ static int decode_frame(AVCodecContext *avctx, void 
 *data, int *got_frame,
 +
 +/* reset values */
 +c-bpp = depth;
 +c-bpp2 = c-bpp / 8;

align =

 @@ -524,6 +532,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
  case 16:
  avctx-pix_fmt = AV_PIX_FMT_RGB555;
  break;
 +case 24:
 +/* 24 bits is not technically supported, but some clients might
 + * mistakenly set it -- delay the actual check in decode_frame() */

This expresses the opposite of what you seem to have in mind.  It should
be until decode_frame() instead of in decode_frame(), like you said
in the log message.

probably OK

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


[libav-devel] [PATCH 2/3] nutdec: stop skipping bytes at EOF

2015-05-19 Thread Andreas Cadhalpun
This can unnecessarily waste a lot of time.

Signed-off-by: Andreas Cadhalpun andreas.cadhal...@googlemail.com
---
 libavformat/nutdec.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index a75587f..e979ee6 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -47,6 +47,8 @@ static int get_str(AVIOContext *bc, char *string, unsigned 
int maxlen)
 while (len  maxlen) {
 avio_r8(bc);
 len--;
+if (bc-eof_reached)
+len = maxlen;
 }
 
 if (maxlen)
@@ -211,7 +213,7 @@ static int skip_reserved(AVIOContext *bc, int64_t pos)
 avio_seek(bc, pos, SEEK_CUR);
 return AVERROR_INVALIDDATA;
 } else {
-while (pos--)
+while (pos--  !bc-eof_reached)
 avio_r8(bc);
 return 0;
 }
@@ -291,7 +293,7 @@ static int decode_main_header(NUTContext *nut)
 if (tmp_fields  7)
 tmp_head_idx = ffio_read_varlen(bc);
 
-while (tmp_fields--  8)
+while (tmp_fields--  8  !bc-eof_reached)
 ffio_read_varlen(bc);
 
 if (count = 0 || count  256 - (i = 'N') - i) {
@@ -990,7 +992,7 @@ static int decode_frame_header(NUTContext *nut, int64_t 
*pts, int *stream_id,
 *header_idx = ffio_read_varlen(bc);
 if (flags  FLAG_RESERVED)
 reserved_count = ffio_read_varlen(bc);
-for (i = 0; i  reserved_count; i++)
+for (i = 0; i  reserved_count  !bc-eof_reached; i++)
 ffio_read_varlen(bc);
 
 if (*header_idx = (unsigned)nut-header_count) {
-- 
2.1.4
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/3] nutdec: fix infinite resync loops

2015-05-19 Thread Andreas Cadhalpun
nut-last_syncpoint_pos doesn't necessarily change between resync
attempts, so find_any_startcode can return the same startcode again.

Thus remember where the last resync happened and don't try to resync
before that.

This can't be done locally in nut_read_packet, because this wouldn't
prevent infinite resync loops, where after the resync a packet is
returned and while reading a following packet the resync happens again.

Signed-off-by: Andreas Cadhalpun andreas.cadhal...@googlemail.com
---
 libavformat/nut.h| 1 +
 libavformat/nutdec.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/nut.h b/libavformat/nut.h
index 943081c..0c678a5 100644
--- a/libavformat/nut.h
+++ b/libavformat/nut.h
@@ -102,6 +102,7 @@ typedef struct NUTContext {
 unsigned int max_distance;
 unsigned int time_base_count;
 int64_t last_syncpoint_pos;
+int64_t last_resync_pos;
 int header_count;
 AVRational *time_base;
 struct AVTreeNode *syncpoints;
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 2762db2..a75587f 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -1124,7 +1124,8 @@ static int nut_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 default:
 resync:
 av_log(s, AV_LOG_DEBUG, syncing from %PRId64\n, pos);
-tmp = find_any_startcode(bc, nut-last_syncpoint_pos + 1);
+tmp = find_any_startcode(bc, FFMAX(nut-last_syncpoint_pos, 
nut-last_resync_pos) + 1);
+nut-last_resync_pos = avio_tell(bc);
 if (tmp == 0)
 return AVERROR_INVALIDDATA;
 av_log(s, AV_LOG_DEBUG, sync\n);
-- 
2.1.4
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 3/3] nutdec: abort if EOF is reached in decode_info_header/read_sm_data

2015-05-19 Thread Andreas Cadhalpun
These loops can take a lot of time if count is very large.

Signed-off-by: Andreas Cadhalpun andreas.cadhal...@googlemail.com
---
 libavformat/nutdec.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index e979ee6..ad61d7e 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -524,6 +524,10 @@ static int decode_info_header(NUTContext *nut)
 }
 
 for (i = 0; i  count; i++) {
+if (bc-eof_reached) {
+av_log(s, AV_LOG_ERROR, reached EOF while decoding info 
header\n);
+return AVERROR_INVALIDDATA;
+}
 get_str(bc, name, sizeof(name));
 value = get_s(bc);
 str_value[0] = 0;
@@ -849,6 +853,10 @@ static int read_sm_data(AVFormatContext *s, AVIOContext 
*bc, AVPacket *pkt, int
 int value;
 if (avio_tell(bc) = maxpos)
 return AVERROR_INVALIDDATA;
+if (bc-eof_reached) {
+av_log(s, AV_LOG_ERROR, reached EOF while reading sm data\n);
+return AVERROR_INVALIDDATA;
+}
 get_str(bc, name, sizeof(name));
 value = get_s(bc);
 
-- 
2.1.4
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] vmnc: Delay pixel size check

2015-05-19 Thread Vittorio Giovara
Some clients incorrectly set 24 as bits_per_coded_sample, while
the actual value is preseved in one of the headers.
In order to work around this, delay the check until decode_frame().

Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
 libavcodec/vmnc.c | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c
index 16984fb..eb583a6 100644
--- a/libavcodec/vmnc.c
+++ b/libavcodec/vmnc.c
@@ -419,10 +419,18 @@ static int decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 c-pic-pict_type = AV_PICTURE_TYPE_I;
 depth = bytestream2_get_byte(gb);
 if (depth != c-bpp) {
-av_log(avctx, AV_LOG_INFO,
-   Depth mismatch. Container %i bpp, 
-   Frame data: %i bpp\n,
-   c-bpp, depth);
+av_log(avctx, AV_LOG_WARNING, Depth mismatch. 
+   Container %i bpp / Codec %i bpp\n, c-bpp, depth);
+
+if (depth != 8  depth != 16  depth != 32) {
+av_log(avctx, AV_LOG_ERROR,
+   Unsupported codec bitdepth %i\n, depth);
+return AVERROR_INVALIDDATA;
+}
+
+/* reset values */
+c-bpp = depth;
+c-bpp2 = c-bpp / 8;
 }
 bytestream2_skip(gb, 1);
 c-bigendian = bytestream2_get_byte(gb);
@@ -524,6 +532,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
 case 16:
 avctx-pix_fmt = AV_PIX_FMT_RGB555;
 break;
+case 24:
+/* 24 bits is not technically supported, but some clients might
+ * mistakenly set it -- delay the actual check in decode_frame() */
 case 32:
 avctx-pix_fmt = AV_PIX_FMT_RGB32;
 break;
-- 
1.9.5 (Apple Git-50.3)

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


Re: [libav-devel] [PATCH] vmnc: Delay pixel size check

2015-05-19 Thread Vittorio Giovara
On Tue, May 19, 2015 at 6:23 PM, Diego Biurrun di...@biurrun.de wrote:
 On Tue, May 19, 2015 at 04:57:46PM +0100, Vittorio Giovara wrote:
 Some clients incorrectly set 24 as bits_per_coded_sample, while
 the actual value is preseved in one of the headers.

 prese_R_ved

 present in one of the file headers is probably more accurate.

file is too generic, i'll use 'codec'
the rest is amended locally
thanks
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel