[FFmpeg-cvslog] avcodec/dnxhddata: remove dead code

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Nov 11 01:41:16 
2017 -0300| [1b6e52c68fd0ce24f0e5dbafe93146c7793c677b] | committer: James Almer

avcodec/dnxhddata: remove dead code

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b6e52c68fd0ce24f0e5dbafe93146c7793c677b
---

 libavcodec/dnxhddata.c | 7 ---
 libavcodec/dnxhddata.h | 5 +
 2 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
index e995449d63..d7d3331b4f 100644
--- a/libavcodec/dnxhddata.c
+++ b/libavcodec/dnxhddata.c
@@ -1100,13 +1100,6 @@ int avpriv_dnxhd_get_interlaced(int cid)
 return ff_dnxhd_cid_table[i].flags & DNXHD_INTERLACED ? 1 : 0;
 }
 
-#if LIBAVCODEC_VERSION_MAJOR < 58
-uint64_t avpriv_dnxhd_parse_header_prefix(const uint8_t *buf)
-{
-return ff_dnxhd_parse_header_prefix(buf);
-}
-#endif
-
 static int dnxhd_find_hr_cid(AVCodecContext *avctx)
 {
 switch (avctx->profile) {
diff --git a/libavcodec/dnxhddata.h b/libavcodec/dnxhddata.h
index 6de2c0918e..f80ce18f3c 100644
--- a/libavcodec/dnxhddata.h
+++ b/libavcodec/dnxhddata.h
@@ -105,8 +105,5 @@ static av_always_inline int ff_dnxhd_get_hr_frame_size(int 
cid, int w, int h)
 
 int avpriv_dnxhd_get_frame_size(int cid);
 int avpriv_dnxhd_get_interlaced(int cid);
-#if LIBAVCODEC_VERSION_MAJOR < 58
-attribute_deprecated
-uint64_t avpriv_dnxhd_parse_header_prefix(const uint8_t *buf);
-#endif
+
 #endif /* AVCODEC_DNXHDDATA_H */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/mpegaudiodecheader: remove dead code

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Nov 11 01:39:47 
2017 -0300| [006546c635f05444cd7dd241f9e65bef346771bd] | committer: James Almer

avcodec/mpegaudiodecheader: remove dead code

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=006546c635f05444cd7dd241f9e65bef346771bd
---

 libavcodec/mpegaudiodecheader.c | 12 
 libavcodec/mpegaudiodecheader.h |  5 -
 2 files changed, 17 deletions(-)

diff --git a/libavcodec/mpegaudiodecheader.c b/libavcodec/mpegaudiodecheader.c
index ae86b087f3..6cc79f18b5 100644
--- a/libavcodec/mpegaudiodecheader.c
+++ b/libavcodec/mpegaudiodecheader.c
@@ -152,15 +152,3 @@ int ff_mpa_decode_header(uint32_t head, int *sample_rate, 
int *channels, int *fr
 *bit_rate = s->bit_rate;
 return s->frame_size;
 }
-
-#if LIBAVCODEC_VERSION_MAJOR < 58
-int avpriv_mpa_decode_header2(uint32_t head, int *sample_rate, int *channels, 
int *frame_size, int *bit_rate, enum AVCodecID *codec_id)
-{
-return ff_mpa_decode_header(head, sample_rate, channels, frame_size, 
bit_rate, codec_id);
-}
-
-int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int 
*sample_rate, int *channels, int *frame_size, int *bit_rate)
-{
-return ff_mpa_decode_header(head, sample_rate, channels, frame_size, 
bit_rate, >codec_id);
-}
-#endif
diff --git a/libavcodec/mpegaudiodecheader.h b/libavcodec/mpegaudiodecheader.h
index 952ba17440..1cb9216461 100644
--- a/libavcodec/mpegaudiodecheader.h
+++ b/libavcodec/mpegaudiodecheader.h
@@ -57,11 +57,6 @@ int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, 
uint32_t header);
 int ff_mpa_decode_header(uint32_t head, int *sample_rate,
  int *channels, int *frame_size, int *bitrate, enum 
AVCodecID *codec_id);
 
-#if LIBAVCODEC_VERSION_MAJOR < 58
-int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int 
*sample_rate, int *channels, int *frame_size, int *bitrate);
-int avpriv_mpa_decode_header2(uint32_t head, int *sample_rate, int *channels, 
int *frame_size, int *bitrate, enum AVCodecID *codec_id);
-#endif
-
 /* fast header check for resync */
 static inline int ff_mpa_check_header(uint32_t header){
 /* header */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Merge commit '4c0588b4562abad5540f6a5435c62828de9e4fdf'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Nov 11 01:24:55 
2017 -0300| [700da852b58bf3354dec6652dc1500192ef63154] | committer: James Almer

Merge commit '4c0588b4562abad5540f6a5435c62828de9e4fdf'

* commit '4c0588b4562abad5540f6a5435c62828de9e4fdf':
  mpeg2enc: Don't mark all streams as component video

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=700da852b58bf3354dec6652dc1500192ef63154
---

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

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index f45598a087..0084f544f2 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -353,7 +353,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
 if (s->seq_disp_ext == 1 || (s->seq_disp_ext == -1 && 
use_seq_disp_ext)) {
 put_header(s, EXT_START_CODE);
 put_bits(>pb, 4, 2); // sequence 
display extension
-put_bits(>pb, 3, 0); // 
video_format: 0 is components
+put_bits(>pb, 3, 5); // 
video_format: 5 is unspecified
 put_bits(>pb, 1, 1); // 
colour_description
 put_bits(>pb, 8, s->avctx->color_primaries); // 
colour_primaries
 put_bits(>pb, 8, s->avctx->color_trc);   // 
transfer_characteristics


==

diff --cc libavcodec/mpeg12enc.c
index f45598a087,406950901e..0084f544f2
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@@ -332,37 -292,20 +332,37 @@@ static void mpeg1_encode_sequence_heade
  put_bits(>pb, 1, 1); // marker
  put_bits(>pb, 8, vbv_buffer_size >> 10); // vbv buffer ext
  put_bits(>pb, 1, s->low_delay);
 -put_bits(>pb, 2, 0); // frame_rate_ext_n
 -put_bits(>pb, 5, 0); // frame_rate_ext_d
 +put_bits(>pb, 2, s->mpeg2_frame_rate_ext.num-1); // 
frame_rate_ext_n
 +put_bits(>pb, 5, s->mpeg2_frame_rate_ext.den-1); // 
frame_rate_ext_d
 +
 +side_data = av_frame_get_side_data(s->current_picture_ptr->f, 
AV_FRAME_DATA_PANSCAN);
 +if (side_data) {
 +AVPanScan *pan_scan = (AVPanScan *)side_data->data;
 +if (pan_scan->width && pan_scan->height) {
 +width = pan_scan->width >> 4;
 +height = pan_scan->height >> 4;
 +}
 +}
  
 -put_header(s, EXT_START_CODE);
 -put_bits(>pb, 4, 2); // sequence 
display extension
 -put_bits(>pb, 3, 5); // video_format: 
5 is unspecified
 -put_bits(>pb, 1, 1); // 
colour_description
 -put_bits(>pb, 8, s->avctx->color_primaries); // 
colour_primaries
 -put_bits(>pb, 8, s->avctx->color_trc);   // 
transfer_characteristics
 -put_bits(>pb, 8, s->avctx->colorspace);  // 
matrix_coefficients
 -put_bits(>pb, 14, s->width); // 
display_horizontal_size
 -put_bits(>pb, 1, 1); // marker_bit
 -put_bits(>pb, 14, s->height);// 
display_vertical_size
 -put_bits(>pb, 3, 0); // remaining 3 
bits are zero padding
 +use_seq_disp_ext = (width != s->width ||
 +height != s->height ||
 +s->avctx->color_primaries != 
AVCOL_PRI_UNSPECIFIED ||
 +s->avctx->color_trc != AVCOL_TRC_UNSPECIFIED 
||
 +s->avctx->colorspace != 
AVCOL_SPC_UNSPECIFIED);
 +
 +if (s->seq_disp_ext == 1 || (s->seq_disp_ext == -1 && 
use_seq_disp_ext)) {
 +put_header(s, EXT_START_CODE);
 +put_bits(>pb, 4, 2); // sequence 
display extension
- put_bits(>pb, 3, 0); // 
video_format: 0 is components
++put_bits(>pb, 3, 5); // 
video_format: 5 is unspecified
 +put_bits(>pb, 1, 1); // 
colour_description
 +put_bits(>pb, 8, s->avctx->color_primaries); // 
colour_primaries
 +put_bits(>pb, 8, s->avctx->color_trc);   // 
transfer_characteristics
 +put_bits(>pb, 8, s->avctx->colorspace);  // 
matrix_coefficients
 +put_bits(>pb, 14, width);// 
display_horizontal_size
 +put_bits(>pb, 1, 1); // marker_bit
 +put_bits(>pb, 14, height);   // 
display_vertical_size
 +put_bits(>pb, 3, 0);  

[FFmpeg-cvslog] mpeg2enc: Don't mark all streams as component video

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sat Aug 12 22:16:13 
2017 +0100| [4c0588b4562abad5540f6a5435c62828de9e4fdf] | committer: Mark 
Thompson

mpeg2enc: Don't mark all streams as component video

Since there is no information about the source format, "unspecified"
is the correct value to write here.

All tests using the MPEG-2 encoder are updated, as this changes the
header on all outputs.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4c0588b4562abad5540f6a5435c62828de9e4fdf
---

 libavcodec/mpeg12enc.c | 2 +-
 tests/ref/lavf/gxf | 2 +-
 tests/ref/lavf/mxf | 2 +-
 tests/ref/lavf/mxf_d10 | 2 +-
 tests/ref/lavf/ts  | 2 +-
 tests/ref/vsynth/vsynth1-mpeg2 | 2 +-
 tests/ref/vsynth/vsynth1-mpeg2-422 | 2 +-
 tests/ref/vsynth/vsynth1-mpeg2-idct-int| 2 +-
 tests/ref/vsynth/vsynth1-mpeg2-ilace   | 2 +-
 tests/ref/vsynth/vsynth1-mpeg2-ivlc-qprd   | 2 +-
 tests/ref/vsynth/vsynth1-mpeg2-thread  | 2 +-
 tests/ref/vsynth/vsynth1-mpeg2-thread-ivlc | 2 +-
 tests/ref/vsynth/vsynth2-mpeg2 | 2 +-
 tests/ref/vsynth/vsynth2-mpeg2-422 | 2 +-
 tests/ref/vsynth/vsynth2-mpeg2-idct-int| 2 +-
 tests/ref/vsynth/vsynth2-mpeg2-ilace   | 2 +-
 tests/ref/vsynth/vsynth2-mpeg2-ivlc-qprd   | 2 +-
 tests/ref/vsynth/vsynth2-mpeg2-thread  | 2 +-
 tests/ref/vsynth/vsynth2-mpeg2-thread-ivlc | 2 +-
 19 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 103f3aaa77..406950901e 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -297,7 +297,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
 
 put_header(s, EXT_START_CODE);
 put_bits(>pb, 4, 2); // sequence 
display extension
-put_bits(>pb, 3, 0); // video_format: 0 
is components
+put_bits(>pb, 3, 5); // video_format: 5 
is unspecified
 put_bits(>pb, 1, 1); // 
colour_description
 put_bits(>pb, 8, s->avctx->color_primaries); // colour_primaries
 put_bits(>pb, 8, s->avctx->color_trc);   // 
transfer_characteristics
diff --git a/tests/ref/lavf/gxf b/tests/ref/lavf/gxf
index 8dfd63d646..a390a070fc 100644
--- a/tests/ref/lavf/gxf
+++ b/tests/ref/lavf/gxf
@@ -1,3 +1,3 @@
-a1cf0a335ad64ec526bb69bbca0656c2 *./tests/data/lavf/lavf.gxf
+bfc25e31136275aff0f9126610b8a7e4 *./tests/data/lavf/lavf.gxf
 796428 ./tests/data/lavf/lavf.gxf
 ./tests/data/lavf/lavf.gxf CRC=0xd04c769f
diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf
index 09e3c36bbc..105e33a3e2 100644
--- a/tests/ref/lavf/mxf
+++ b/tests/ref/lavf/mxf
@@ -1,3 +1,3 @@
-051b982c1b5799eb107339735a090c70 *./tests/data/lavf/lavf.mxf
+7c9efc1b6f5fc65bf39177887512fefd *./tests/data/lavf/lavf.mxf
 525881 ./tests/data/lavf/lavf.mxf
 ./tests/data/lavf/lavf.mxf CRC=0x773f059a
diff --git a/tests/ref/lavf/mxf_d10 b/tests/ref/lavf/mxf_d10
index 8a62bb092a..74991a5750 100644
--- a/tests/ref/lavf/mxf_d10
+++ b/tests/ref/lavf/mxf_d10
@@ -1,3 +1,3 @@
-96f933913835a439dd97144303dc8929 *./tests/data/lavf/lavf.mxf_d10
+5fbb6252f6b146cd36d1491ca96ad8a3 *./tests/data/lavf/lavf.mxf_d10
 5330989 ./tests/data/lavf/lavf.mxf_d10
 ./tests/data/lavf/lavf.mxf_d10 CRC=0x4474d480
diff --git a/tests/ref/lavf/ts b/tests/ref/lavf/ts
index caf08a85b7..6846f700cc 100644
--- a/tests/ref/lavf/ts
+++ b/tests/ref/lavf/ts
@@ -1,3 +1,3 @@
-f74d6f4d4073f4242cec3d5fee099779 *./tests/data/lavf/lavf.ts
+7a479525b7dc9264291cb2fc3e1d28e5 *./tests/data/lavf/lavf.ts
 406456 ./tests/data/lavf/lavf.ts
 ./tests/data/lavf/lavf.ts CRC=0xb4ca6cdc
diff --git a/tests/ref/vsynth/vsynth1-mpeg2 b/tests/ref/vsynth/vsynth1-mpeg2
index d0baa0ac81..15b27ea15d 100644
--- a/tests/ref/vsynth/vsynth1-mpeg2
+++ b/tests/ref/vsynth/vsynth1-mpeg2
@@ -1,4 +1,4 @@
-50c344f0e0e3c65001a68b2c899a283f *tests/data/fate/vsynth1-mpeg2.mpeg2video
+080866b0a4570c672ccc7cf3e6e7bec7 *tests/data/fate/vsynth1-mpeg2.mpeg2video
 728104 tests/data/fate/vsynth1-mpeg2.mpeg2video
 b41ca49c1a02e66ce64d262e2cdaec15 *tests/data/fate/vsynth1-mpeg2.out.rawvideo
 stddev:7.65 PSNR: 30.45 MAXDIFF:   84 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-mpeg2-422 
b/tests/ref/vsynth/vsynth1-mpeg2-422
index 1209e8879f..80acf6146a 100644
--- a/tests/ref/vsynth/vsynth1-mpeg2-422
+++ b/tests/ref/vsynth/vsynth1-mpeg2-422
@@ -1,4 +1,4 @@
-c2124749526d2d4d41398d52557fad1b *tests/data/fate/vsynth1-mpeg2-422.mpeg2video
+e59f232030cd0fb7e7839e3f8cd6a1b7 *tests/data/fate/vsynth1-mpeg2-422.mpeg2video
 728260 tests/data/fate/vsynth1-mpeg2-422.mpeg2video
 eb7fe83ce09af2d79ec16577c9d44e3c 
*tests/data/fate/vsynth1-mpeg2-422.out.rawvideo
 stddev:   10.29 PSNR: 27.88 MAXDIFF:  168 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-mpeg2-idct-int 

[FFmpeg-cvslog] Merge commit 'b78c30d7ec26af67c00ce2002709a189f6a87a7e'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Nov 11 01:05:13 
2017 -0300| [53fc4310f1ba74cd6f264f7263359440a2e5646a] | committer: James Almer

Merge commit 'b78c30d7ec26af67c00ce2002709a189f6a87a7e'

* commit 'b78c30d7ec26af67c00ce2002709a189f6a87a7e':
  lavc: Add mpeg2_metadata bitstream filter
  lavc: Add coded bitstream read/write support for MPEG-2
  cbs_h2645: Return error if writing fails
  h264dec: use a large enough field for reference list modification values
  xwddec: support 8bpp grayscale

This commit is a noop, see
b9c94e826e7551027754ecfa60e3e487e0c28fcb
2aff557c6acbce2b2b604c6c620c66c892260062
b4c915f4b3e15c3e787e319b961e4389762f6309
686e388bbb6aeef077095a83f84b53d143d44d63
569721ac8dee6b73cd68ea858f59c7d800a1686d

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=53fc4310f1ba74cd6f264f7263359440a2e5646a
---



___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] cbs_h2645: Return error if writing fails

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Mon Aug 14 16:46:32 
2017 +0100| [768eb9182e94a94bc2ef46f565a0dac7afef3b57] | committer: Mark 
Thompson

cbs_h2645: Return error if writing fails

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=768eb9182e94a94bc2ef46f565a0dac7afef3b57
---

 libavcodec/cbs_h2645.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 23556f47f8..4d8ba99b35 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1244,6 +1244,11 @@ static int 
cbs_h2645_write_nal_unit(CodedBitstreamContext *ctx,
 // Overflow but we didn't notice.
 av_assert0(put_bits_count() <= 8 * priv->write_buffer_size);
 
+if (err < 0) {
+// Write failed for some other reason.
+return err;
+}
+
 if (put_bits_count() % 8)
 unit->data_bit_padding = 8 - put_bits_count() % 8;
 else

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] xwddec: support 8bpp grayscale

2017-11-10 Thread Piotr Bandurski
ffmpeg | branch: master | Piotr Bandurski  | Sun Jun 24 
11:34:02 2012 +| [a05c6e8c11b1a17b7c4529294751b917cf0d8e04] | committer: 
Diego Biurrun

xwddec: support 8bpp grayscale

(cherry picked from commit b9c94e826e7551027754ecfa60e3e487e0c28fcb)
Signed-off-by: Diego Biurrun 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a05c6e8c11b1a17b7c4529294751b917cf0d8e04
---

 libavcodec/xwddec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/xwddec.c b/libavcodec/xwddec.c
index 387b697491..c43724e538 100644
--- a/libavcodec/xwddec.c
+++ b/libavcodec/xwddec.c
@@ -155,10 +155,12 @@ static int xwd_decode_frame(AVCodecContext *avctx, void 
*data,
 switch (vclass) {
 case XWD_STATIC_GRAY:
 case XWD_GRAY_SCALE:
-if (bpp != 1)
+if (bpp != 1 && bpp != 8 || bpp != pixdepth)
 return AVERROR_INVALIDDATA;
 if (pixdepth == 1)
 avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
+else if (pixdepth == 8)
+avctx->pix_fmt = AV_PIX_FMT_GRAY8;
 break;
 case XWD_STATIC_COLOR:
 case XWD_PSEUDO_COLOR:

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] h264dec: use a large enough field for reference list modification values

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Aug 17 
12:15:58 2017 +0200| [f70f71d60c7ae88c19078a48dc6e0789b78c7300] | committer: 
Anton Khirnov

h264dec: use a large enough field for reference list modification values

pic_num can be at most 17-bit, so uint8_t is not sufficient.

Found-By: Bradley Sepos 
CC: libav-sta...@libav.org

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f70f71d60c7ae88c19078a48dc6e0789b78c7300
---

 libavcodec/h264dec.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index ddfe224e93..cce5e198d9 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -268,7 +268,7 @@ typedef struct H264SliceContext {
  *   according to picture reordering 
in slice header */
 struct {
 uint8_t op;
-uint8_t val;
+uint32_t val;
 } ref_modifications[2][32];
 int nb_ref_modifications[2];
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavc: Add coded bitstream read/write support for MPEG-2

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Thu May  4 23:03:03 
2017 +0100| [2bc9ba8d3c41f3a8e56484bd67b05040c7909a01] | committer: Mark 
Thompson

lavc: Add coded bitstream read/write support for MPEG-2

Also enable MPEG-2 support in the trace_headers filter.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2bc9ba8d3c41f3a8e56484bd67b05040c7909a01
---

 configure  |   4 +-
 doc/bitstream_filters.texi |   2 +-
 libavcodec/Makefile|   1 +
 libavcodec/cbs.c   |   3 +
 libavcodec/cbs_internal.h  |   1 +
 libavcodec/cbs_mpeg2.c | 409 +
 libavcodec/cbs_mpeg2.h | 216 +
 libavcodec/cbs_mpeg2_syntax_template.c | 340 +++
 libavcodec/trace_headers_bsf.c |   1 +
 9 files changed, 975 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 9704b9316a..1e33ded01e 100755
--- a/configure
+++ b/configure
@@ -1742,6 +1742,7 @@ CONFIG_EXTRA="
 cbs
 cbs_h264
 cbs_h265
+cbs_mpeg2
 dirac_parse
 dvprofile
 faandct
@@ -1970,6 +1971,7 @@ threads_if_any="$THREADS_LIST"
 # subsystems
 cbs_h264_select="cbs golomb"
 cbs_h265_select="cbs golomb"
+cbs_mpeg2_select="cbs"
 dct_select="rdft"
 dirac_parse_select="golomb"
 error_resilience_select="me_cmp"
@@ -2327,7 +2329,7 @@ h264_metadata_bsf_select="cbs_h264"
 h264_redundant_pps_bsf_select="cbs_h264"
 hevc_metadata_bsf_select="cbs_h265"
 mjpeg2jpeg_bsf_select="jpegtables"
-trace_headers_bsf_select="cbs_h264 cbs_h265"
+trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"
 
 # external libraries
 avisynth_deps="LoadLibrary"
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 21371ea9a6..cacc0fc4a3 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -227,7 +227,7 @@ Log trace output containing all syntax elements in the 
coded stream
 headers (everything above the level of individual coded blocks).
 This can be useful for debugging low-level stream issues.
 
-Supports H.264 and H.265.
+Supports H.264, H.265 and MPEG-2.
 
 @section vp9_superframe
 
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ffd17c9cf0..e5a54c9b66 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -56,6 +56,7 @@ OBJS-$(CONFIG_CABAC)   += cabac.o
 OBJS-$(CONFIG_CBS) += cbs.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o h2645_parse.o
 OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o
+OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
 OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
 OBJS-$(CONFIG_ERROR_RESILIENCE)+= error_resilience.o
 OBJS-$(CONFIG_FAANDCT) += faandct.o
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index b5d5dfd2fd..10943164da 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -34,6 +34,9 @@ static const CodedBitstreamType *cbs_type_table[] = {
 #if CONFIG_CBS_H265
 _cbs_type_h265,
 #endif
+#if CONFIG_CBS_MPEG2
+_cbs_type_mpeg2,
+#endif
 };
 
 int ff_cbs_init(CodedBitstreamContext *ctx,
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index 0457f4ab9e..dddeae9d5b 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -82,6 +82,7 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, 
PutBitContext *pbc,
 
 extern const CodedBitstreamType ff_cbs_type_h264;
 extern const CodedBitstreamType ff_cbs_type_h265;
+extern const CodedBitstreamType ff_cbs_type_mpeg2;
 
 
 #endif /* AVCODEC_CBS_INTERNAL_H */
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
new file mode 100644
index 00..fede3ff471
--- /dev/null
+++ b/libavcodec/cbs_mpeg2.c
@@ -0,0 +1,409 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avassert.h"
+
+#include "cbs.h"
+#include "cbs_internal.h"
+#include "cbs_mpeg2.h"
+#include "internal.h"
+
+
+#define HEADER(name) do { \
+ff_cbs_trace_header(ctx, name); \
+} while (0)
+
+#define CHECK(call) do { \
+err = (call); \
+if (err < 0) \
+return err; \
+} while (0)
+
+#define FUNC_NAME(rw, 

[FFmpeg-cvslog] lavc: Add mpeg2_metadata bitstream filter

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Tue Aug  1 15:35:14 
2017 +0100| [b78c30d7ec26af67c00ce2002709a189f6a87a7e] | committer: Mark 
Thompson

lavc: Add mpeg2_metadata bitstream filter

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b78c30d7ec26af67c00ce2002709a189f6a87a7e
---

 configure   |   1 +
 doc/bitstream_filters.texi  |  36 
 libavcodec/Makefile |   1 +
 libavcodec/bitstream_filters.c  |   1 +
 libavcodec/mpeg2_metadata_bsf.c | 360 
 5 files changed, 399 insertions(+)

diff --git a/configure b/configure
index 1e33ded01e..3e5784f851 100755
--- a/configure
+++ b/configure
@@ -2329,6 +2329,7 @@ h264_metadata_bsf_select="cbs_h264"
 h264_redundant_pps_bsf_select="cbs_h264"
 hevc_metadata_bsf_select="cbs_h265"
 mjpeg2jpeg_bsf_select="jpegtables"
+mpeg2_metadata_bsf_select="cbs_mpeg2"
 trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"
 
 # external libraries
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index cacc0fc4a3..23ac294957 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -210,6 +210,42 @@ avconv -i frame_%d.jpg -c:v copy rotated.avi
 
 @section movsub
 
+@section mpeg2_metadata
+
+Modify metadata embedded in an MPEG-2 stream.
+
+@table @option
+@item display_aspect_ratio
+Set the display aspect ratio in the stream.
+
+The following fixed values are supported:
+@table @option
+@item 4/3
+@item 16/9
+@item 221/100
+@end table
+Any other value will result in square pixels being signalled instead
+(see H.262 section 6.3.3 and table 6-3).
+
+@item frame_rate
+Set the frame rate in the stream.  This is constructed from a table
+of known values combined with a small multiplier and divisor - if
+the supplied value is not exactly representable, the nearest
+representable value will be used instead (see H.262 section 6.3.3
+and table 6-4).
+
+@item video_format
+Set the video format in the stream (see H.262 section 6.3.6 and
+table 6-6).
+
+@item colour_primaries
+@item transfer_characteristics
+@item matrix_coefficients
+Set the colour description in the stream (see H.262 section 6.3.6
+and tables 6-7, 6-8 and 6-9).
+
+@end table
+
 @section mp3_header_compress
 
 @section mp3_header_decompress
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e5a54c9b66..9c485b222e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -786,6 +786,7 @@ OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF)+= 
imx_dump_header_bsf.o
 OBJS-$(CONFIG_MJPEG2JPEG_BSF) += mjpeg2jpeg_bsf.o
 OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += mjpega_dump_header_bsf.o
 OBJS-$(CONFIG_MOV2TEXTSUB_BSF)+= movsub_bsf.o
+OBJS-$(CONFIG_MPEG2_METADATA_BSF) += mpeg2_metadata_bsf.o
 OBJS-$(CONFIG_NOISE_BSF)  += noise_bsf.o
 OBJS-$(CONFIG_NULL_BSF)   += null_bsf.o
 OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF)   += remove_extradata_bsf.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index e90919f602..784170543f 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -37,6 +37,7 @@ extern const AVBitStreamFilter ff_imx_dump_header_bsf;
 extern const AVBitStreamFilter ff_mjpeg2jpeg_bsf;
 extern const AVBitStreamFilter ff_mjpega_dump_header_bsf;
 extern const AVBitStreamFilter ff_mov2textsub_bsf;
+extern const AVBitStreamFilter ff_mpeg2_metadata_bsf;
 extern const AVBitStreamFilter ff_null_bsf;
 extern const AVBitStreamFilter ff_text2movsub_bsf;
 extern const AVBitStreamFilter ff_noise_bsf;
diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c
new file mode 100644
index 00..80e946f58e
--- /dev/null
+++ b/libavcodec/mpeg2_metadata_bsf.c
@@ -0,0 +1,360 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+
+#include "bsf.h"
+#include "cbs.h"
+#include "cbs_mpeg2.h"
+
+typedef struct MPEG2MetadataContext {
+const AVClass *class;
+
+CodedBitstreamContext cbc;
+CodedBitstreamFragment fragment;
+
+MPEG2RawExtensionData sequence_display_extension;
+
+AVRational display_aspect_ratio;
+
+AVRational frame_rate;
+

[FFmpeg-cvslog] dfa: Disallow odd width/height and add proper bounds check for DDS1 chunks

2017-11-10 Thread Diego Biurrun
ffmpeg | branch: master | Diego Biurrun  | Fri Aug 11 
19:15:20 2017 +0200| [d34a133b78afe2793cd8537f3c7f42437f441e94] | committer: 
Diego Biurrun

dfa: Disallow odd width/height and add proper bounds check for DDS1 chunks

DDS1 chunks are decoded in 2x2 blocks, odd chunk width or height is not
allowed in that case. Also ensure that the decode buffer is big enough
for all blocks being processed.

Bug-Id: CVE-2017-9992
CC: libav-sta...@libav.org

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d34a133b78afe2793cd8537f3c7f42437f441e94
---

 libavcodec/dfa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c
index 2654118fad..1682eb08cd 100644
--- a/libavcodec/dfa.c
+++ b/libavcodec/dfa.c
@@ -144,6 +144,8 @@ static int decode_dds1(GetByteContext *gb, uint8_t *frame, 
int width, int height
 int mask = 0x1, bitbuf = 0;
 int i, v, offset, count, segments;
 
+if ((width | height) & 1)
+return AVERROR_INVALIDDATA;
 segments = bytestream2_get_le16(gb);
 while (segments--) {
 if (bytestream2_get_bytes_left(gb) < 2)
@@ -171,7 +173,7 @@ static int decode_dds1(GetByteContext *gb, uint8_t *frame, 
int width, int height
 return AVERROR_INVALIDDATA;
 frame += v;
 } else {
-if (frame_end - frame < width + 3)
+if (width < 4 || frame_end - frame < width + 4)
 return AVERROR_INVALIDDATA;
 frame[0] = frame[1] =
 frame[width] = frame[width + 1] =  bytestream2_get_byte(gb);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Merge commit 'd34a133b78afe2793cd8537f3c7f42437f441e94'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Nov 11 00:54:19 
2017 -0300| [ecf4e6b7205f6021fbdcf3d419733edae28d8bdd] | committer: James Almer

Merge commit 'd34a133b78afe2793cd8537f3c7f42437f441e94'

* commit 'd34a133b78afe2793cd8537f3c7f42437f441e94':
  dfa: Disallow odd width/height and add proper bounds check for DDS1 chunks

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ecf4e6b7205f6021fbdcf3d419733edae28d8bdd
---

 libavcodec/dfa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c
index 43dba2c8e9..536040d65c 100644
--- a/libavcodec/dfa.c
+++ b/libavcodec/dfa.c
@@ -149,6 +149,8 @@ static int decode_dds1(GetByteContext *gb, uint8_t *frame, 
int width, int height
 int mask = 0x1, bitbuf = 0;
 int i, v, offset, count, segments;
 
+if ((width | height) & 1)
+return AVERROR_INVALIDDATA;
 segments = bytestream2_get_le16(gb);
 while (segments--) {
 if (bytestream2_get_bytes_left(gb) < 2)
@@ -176,7 +178,7 @@ static int decode_dds1(GetByteContext *gb, uint8_t *frame, 
int width, int height
 return AVERROR_INVALIDDATA;
 frame += v;
 } else {
-if (frame_end - frame < width + 4)
+if (width < 4 || frame_end - frame < width + 4)
 return AVERROR_INVALIDDATA;
 frame[0] = frame[1] =
 frame[width] = frame[width + 1] =  bytestream2_get_byte(gb);


==


___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] vaapi_h265: Reduce the amount of padding in the stream

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sat Aug 12 21:32:29 
2017 +0100| [a14a12ca137bf1526452b97bedfc9f7b301d4e04] | committer: Mark 
Thompson

vaapi_h265: Reduce the amount of padding in the stream

It is not necessary to pad to the CTU size.  The CB size of 8x8 should be
sufficient, but due to constraints in the Intel driver (the one usable
implementation of this) it has to be padded to 16x16 like in H.264.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a14a12ca137bf1526452b97bedfc9f7b301d4e04
---

 libavcodec/vaapi_encode_h265.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 477065e2ce..165b6ffde4 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -815,8 +815,11 @@ static av_cold int 
vaapi_encode_h265_configure(AVCodecContext *avctx)
 if (err < 0)
 return err;
 
-priv->ctu_width = FFALIGN(ctx->surface_width,  32) / 32;
-priv->ctu_height= FFALIGN(ctx->surface_height, 32) / 32;
+// This is an Intel driver constraint.  Despite MinCbSizeY being 8,
+// we are still required to encode at 16-pixel alignment and then
+// crop back (so 1080 lines is still encoded as 1088 + cropping).
+priv->ctu_width = FFALIGN(ctx->surface_width,  16) / 16;
+priv->ctu_height= FFALIGN(ctx->surface_height, 16) / 16;
 
 av_log(avctx, AV_LOG_VERBOSE, "Input %ux%u -> Surface %ux%u -> CTU 
%ux%u.\n",
avctx->width, avctx->height, ctx->surface_width,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavc: Add h264_redundant_pps bitstream filter

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Thu May  4 23:10:19 
2017 +0100| [e6874bc3af2f09af39b5d91b9c5f9ded67459696] | committer: Mark 
Thompson

lavc: Add h264_redundant_pps bitstream filter

This applies a specific fixup to some Bluray streams which contain
redundant PPSs modifying irrelevant parameters of the stream which
confuse other transformations which require correct extradata.

A new single global PPS is created, and all of the redundant PPSs
within the stream are removed.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e6874bc3af2f09af39b5d91b9c5f9ded67459696
---

 configure   |   1 +
 doc/bitstream_filters.texi  |   9 ++
 libavcodec/Makefile |   1 +
 libavcodec/bitstream_filters.c  |   1 +
 libavcodec/h264_redundant_pps_bsf.c | 178 
 5 files changed, 190 insertions(+)

diff --git a/configure b/configure
index f3d616800a..bd4555dc87 100755
--- a/configure
+++ b/configure
@@ -2324,6 +2324,7 @@ vc1_parser_select="vc1dsp"
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header"
 h264_metadata_bsf_select="cbs_h264"
+h264_redundant_pps_bsf_select="cbs_h264"
 mjpeg2jpeg_bsf_select="jpegtables"
 trace_headers_bsf_select="cbs_h264 cbs_h265"
 
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 08f2f390cb..e1de3035ef 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -104,6 +104,15 @@ insert the string ``hello'' associated with the given UUID.
 
 @section h264_mp4toannexb
 
+@section h264_redundant_pps
+
+This applies a specific fixup to some Bluray streams which contain
+redundant PPSs modifying irrelevant parameters of the stream which
+confuse other transformations which require correct extradata.
+
+A new single global PPS is created, and all of the redundant PPSs
+within the stream are removed.
+
 @section imx_dump_header
 
 @section mjpeg2jpeg
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c76dffe058..b37a3aa091 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -778,6 +778,7 @@ OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF)  += 
extract_extradata_bsf.o\
  h2645_parse.o
 OBJS-$(CONFIG_H264_METADATA_BSF)  += h264_metadata_bsf.o
 OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
+OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o
 OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF)   += hevc_mp4toannexb_bsf.o
 OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF)+= imx_dump_header_bsf.o
 OBJS-$(CONFIG_MJPEG2JPEG_BSF) += mjpeg2jpeg_bsf.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 4ad50508cb..8fd46a734c 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -30,6 +30,7 @@ extern const AVBitStreamFilter ff_dump_extradata_bsf;
 extern const AVBitStreamFilter ff_extract_extradata_bsf;
 extern const AVBitStreamFilter ff_h264_metadata_bsf;
 extern const AVBitStreamFilter ff_h264_mp4toannexb_bsf;
+extern const AVBitStreamFilter ff_h264_redundant_pps_bsf;
 extern const AVBitStreamFilter ff_hevc_mp4toannexb_bsf;
 extern const AVBitStreamFilter ff_imx_dump_header_bsf;
 extern const AVBitStreamFilter ff_mjpeg2jpeg_bsf;
diff --git a/libavcodec/h264_redundant_pps_bsf.c 
b/libavcodec/h264_redundant_pps_bsf.c
new file mode 100644
index 00..abc7af788a
--- /dev/null
+++ b/libavcodec/h264_redundant_pps_bsf.c
@@ -0,0 +1,178 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavutil/common.h"
+#include "libavutil/mem.h"
+
+#include "bsf.h"
+#include "cbs.h"
+#include "cbs_h264.h"
+#include "h264.h"
+
+
+typedef struct H264RedundantPPSContext {
+CodedBitstreamContext input;
+CodedBitstreamContext output;
+
+CodedBitstreamFragment access_unit;
+
+int global_pic_init_qp;
+int current_pic_init_qp;
+} H264RedundantPPSContext;
+
+
+static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx,
+H264RawPPS *pps)
+{
+// Record the current value of pic_init_qp in order to fix up
+// following slices, then overwrite with the global value.
+ctx->current_pic_init_qp = 

[FFmpeg-cvslog] lavc: Add trace_headers bitstream filter

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Thu May  4 23:06:20 
2017 +0100| [f11d8a5e8b185340cc50fcbc8a1437b0fbe7e931] | committer: Mark 
Thompson

lavc: Add trace_headers bitstream filter

Supports all streams that the coded bitstream infrastructure does
(currently H.264 and H.265).

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f11d8a5e8b185340cc50fcbc8a1437b0fbe7e931
---

 configure  |   1 +
 doc/bitstream_filters.texi |   8 +++
 libavcodec/Makefile|   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/trace_headers_bsf.c | 125 +
 5 files changed, 136 insertions(+)

diff --git a/configure b/configure
index 535862fcaf..13dd7f54e2 100755
--- a/configure
+++ b/configure
@@ -2324,6 +2324,7 @@ vc1_parser_select="vc1dsp"
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header"
 mjpeg2jpeg_bsf_select="jpegtables"
+trace_headers_bsf_select="cbs_h264 cbs_h265"
 
 # external libraries
 avisynth_deps="LoadLibrary"
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 64f91f4b54..119a2267af 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -95,6 +95,14 @@ This bitstream filter passes the packets through unchanged.
 
 @section remove_extradata
 
+@section trace_headers
+
+Log trace output containing all syntax elements in the coded stream
+headers (everything above the level of individual coded blocks).
+This can be useful for debugging low-level stream issues.
+
+Supports H.264 and H.265.
+
 @section vp9_superframe
 
 Combine VP9 frames into superframes.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9791fb342e..09772a85f7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -786,6 +786,7 @@ OBJS-$(CONFIG_NOISE_BSF)  += noise_bsf.o
 OBJS-$(CONFIG_NULL_BSF)   += null_bsf.o
 OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF)   += remove_extradata_bsf.o
 OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o
+OBJS-$(CONFIG_TRACE_HEADERS_BSF)  += trace_headers_bsf.o
 OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF)   += vp9_superframe_split_bsf.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 79ce40f9ed..2e423acaf0 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -38,6 +38,7 @@ extern const AVBitStreamFilter ff_null_bsf;
 extern const AVBitStreamFilter ff_text2movsub_bsf;
 extern const AVBitStreamFilter ff_noise_bsf;
 extern const AVBitStreamFilter ff_remove_extradata_bsf;
+extern const AVBitStreamFilter ff_trace_headers_bsf;
 extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf;
 extern const AVBitStreamFilter ff_vp9_superframe_bsf;
 extern const AVBitStreamFilter ff_vp9_superframe_split_bsf;
diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
new file mode 100644
index 00..2d1fe636c2
--- /dev/null
+++ b/libavcodec/trace_headers_bsf.c
@@ -0,0 +1,125 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavutil/avstring.h"
+#include "libavutil/common.h"
+#include "libavutil/log.h"
+
+#include "bsf.h"
+#include "cbs.h"
+
+
+typedef struct TraceHeadersContext {
+CodedBitstreamContext cbc;
+} TraceHeadersContext;
+
+
+static int trace_headers_init(AVBSFContext *bsf)
+{
+TraceHeadersContext *ctx = bsf->priv_data;
+int err;
+
+err = ff_cbs_init(>cbc, bsf->par_in->codec_id, bsf);
+if (err < 0)
+return err;
+
+ctx->cbc.trace_enable = 1;
+ctx->cbc.trace_level  = AV_LOG_INFO;
+
+if (bsf->par_in->extradata) {
+CodedBitstreamFragment ps;
+
+av_log(bsf, AV_LOG_INFO, "Extradata\n");
+
+err = ff_cbs_read_extradata(>cbc, , bsf->par_in);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
+return err;
+}
+
+ff_cbs_fragment_uninit(>cbc, );
+}
+
+return 0;
+}
+
+static void trace_headers_close(AVBSFContext *bsf)
+{
+TraceHeadersContext *ctx = bsf->priv_data;
+
+ff_cbs_close(>cbc);
+}
+
+static int 

[FFmpeg-cvslog] vaapi_h265: Add support for AUD NAL units

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sun Jul 23 23:22:54 
2017 +0100| [e3e8eab359238486dc233f7aa89b7bb3cb19ec38] | committer: Mark 
Thompson

vaapi_h265: Add support for AUD NAL units

Matching the H.264 encoder.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e3e8eab359238486dc233f7aa89b7bb3cb19ec38
---

 libavcodec/vaapi_encode_h265.c | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index f61dfaa1a9..477065e2ce 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -42,6 +42,7 @@ typedef struct VAAPIEncodeH265Context {
 int fixed_qp_p;
 int fixed_qp_b;
 
+H265RawAUD aud;
 H265RawVPS vps;
 H265RawSPS sps;
 H265RawPPS pps;
@@ -52,13 +53,16 @@ typedef struct VAAPIEncodeH265Context {
 
 int slice_nal_unit;
 int slice_type;
+int pic_type;
 
 CodedBitstreamContext cbc;
 CodedBitstreamFragment current_access_unit;
+int aud_needed;
 } VAAPIEncodeH265Context;
 
 typedef struct VAAPIEncodeH265Options {
 int qp;
+int aud;
 } VAAPIEncodeH265Options;
 
 
@@ -117,6 +121,13 @@ static int 
vaapi_encode_h265_write_sequence_header(AVCodecContext *avctx,
 CodedBitstreamFragment   *au = >current_access_unit;
 int err;
 
+if (priv->aud_needed) {
+err = vaapi_encode_h265_add_nal(avctx, au, >aud);
+if (err < 0)
+goto fail;
+priv->aud_needed = 0;
+}
+
 err = vaapi_encode_h265_add_nal(avctx, au, >vps);
 if (err < 0)
 goto fail;
@@ -145,6 +156,13 @@ static int 
vaapi_encode_h265_write_slice_header(AVCodecContext *avctx,
 CodedBitstreamFragment   *au = >current_access_unit;
 int err;
 
+if (priv->aud_needed) {
+err = vaapi_encode_h265_add_nal(avctx, au, >aud);
+if (err < 0)
+goto fail;
+priv->aud_needed = 0;
+}
+
 err = vaapi_encode_h265_add_nal(avctx, au, >slice);
 if (err < 0)
 goto fail;
@@ -519,6 +537,7 @@ static int 
vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
 {
 VAAPIEncodeContext   *ctx = avctx->priv_data;
 VAAPIEncodeH265Context  *priv = ctx->priv_data;
+VAAPIEncodeH265Options   *opt = ctx->codec_options;
 VAEncPictureParameterBufferHEVC *vpic = pic->codec_picture_params;
 int i;
 
@@ -529,16 +548,19 @@ static int 
vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
 
 priv->slice_nal_unit = HEVC_NAL_IDR_W_RADL;
 priv->slice_type = HEVC_SLICE_I;
+priv->pic_type   = 0;
 } else {
 av_assert0(pic->encode_order > priv->last_idr_frame);
 
 if (pic->type == PICTURE_TYPE_I) {
 priv->slice_nal_unit = HEVC_NAL_CRA_NUT;
 priv->slice_type = HEVC_SLICE_I;
+priv->pic_type   = 0;
 } else if (pic->type == PICTURE_TYPE_P) {
 av_assert0(pic->refs[0]);
 priv->slice_nal_unit = HEVC_NAL_TRAIL_R;
 priv->slice_type = HEVC_SLICE_P;
+priv->pic_type   = 1;
 } else {
 av_assert0(pic->refs[0] && pic->refs[1]);
 if (pic->refs[1]->type == PICTURE_TYPE_I)
@@ -546,10 +568,23 @@ static int 
vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
 else
 priv->slice_nal_unit = HEVC_NAL_TRAIL_N;
 priv->slice_type = HEVC_SLICE_B;
+priv->pic_type   = 2;
 }
 }
 priv->pic_order_cnt = pic->display_order - priv->last_idr_frame;
 
+if (opt->aud) {
+priv->aud_needed = 1;
+priv->aud.nal_unit_header = (H265RawNALUnitHeader) {
+.nal_unit_type = HEVC_NAL_AUD,
+.nuh_layer_id  = 0,
+.nuh_temporal_id_plus1 = 1,
+};
+priv->aud.pic_type = priv->pic_type;
+} else {
+priv->aud_needed = 0;
+}
+
 vpic->decoded_curr_pic = (VAPictureHEVC) {
 .picture_id= pic->recon_surface,
 .pic_order_cnt = priv->pic_order_cnt,
@@ -902,6 +937,10 @@ static av_cold int vaapi_encode_h265_close(AVCodecContext 
*avctx)
 static const AVOption vaapi_encode_h265_options[] = {
 { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
   OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, 52, FLAGS },
+
+{ "aud", "Include AUD",
+  OFFSET(aud), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
+
 { NULL },
 };
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavc: Add hevc_metadata bitstream filter

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sun Jul 23 16:23:51 
2017 +0100| [b31a9eae0233325c4b382c657f4b687d5d8b0812] | committer: Mark 
Thompson

lavc: Add hevc_metadata bitstream filter

This is able to modify some header metadata found in the VPS/SPS/VUI,
and can also add/remove AUDs.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b31a9eae0233325c4b382c657f4b687d5d8b0812
---

 configure  |   1 +
 doc/bitstream_filters.texi |  54 +
 libavcodec/Makefile|   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/h265_metadata_bsf.c | 458 +
 5 files changed, 515 insertions(+)

diff --git a/configure b/configure
index bd4555dc87..dfa3867ac0 100755
--- a/configure
+++ b/configure
@@ -2325,6 +2325,7 @@ vc1_parser_select="vc1dsp"
 aac_adtstoasc_bsf_select="adts_header"
 h264_metadata_bsf_select="cbs_h264"
 h264_redundant_pps_bsf_select="cbs_h264"
+hevc_metadata_bsf_select="cbs_h265"
 mjpeg2jpeg_bsf_select="jpegtables"
 trace_headers_bsf_select="cbs_h264 cbs_h265"
 
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index e1de3035ef..21371ea9a6 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -113,6 +113,60 @@ confuse other transformations which require correct 
extradata.
 A new single global PPS is created, and all of the redundant PPSs
 within the stream are removed.
 
+@section hevc_metadata
+
+Modify metadata embedded in an HEVC stream.
+
+@table @option
+@item aud
+Insert or remove AUD NAL units in all access units of the stream.
+
+@table @samp
+@item insert
+@item remove
+@end table
+
+@item sample_aspect_ratio
+Set the sample aspect ratio in the stream in the VUI parameters.
+
+@item video_format
+@item video_full_range_flag
+Set the video format in the stream (see H.265 section E.3.1 and
+table E.2).
+
+@item colour_primaries
+@item transfer_characteristics
+@item matrix_coefficients
+Set the colour description in the stream (see H.265 section E.3.1
+and tables E.3, E.4 and E.5).
+
+@item chroma_sample_loc_type
+Set the chroma sample location in the stream (see H.265 section
+E.3.1 and figure E.1).
+
+@item tick_rate
+Set the tick rate in the VPS and VUI parameters (num_units_in_tick /
+time_scale).  Combined with @option{num_ticks_poc_diff_one}, this can
+set a constant framerate in the stream.  Note that it is likely to be
+overridden by container parameters when the stream is in a container.
+
+@item num_ticks_poc_diff_one
+Set poc_proportional_to_timing_flag in VPS and VUI and use this value
+to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
+E.3.1).  Ignored if @option{tick_rate} is not also set.
+
+@item crop_left
+@item crop_right
+@item crop_top
+@item crop_bottom
+Set the conformance window cropping offsets in the SPS.  These values
+will replace the current ones if the stream is already cropped.
+
+These fields are set in pixels.  Note that some sizes may not be
+representable if the chroma is subsampled (H.265 section 7.4.3.2.1).
+
+@end table
+
 @section imx_dump_header
 
 @section mjpeg2jpeg
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b37a3aa091..e1ae1e4519 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -779,6 +779,7 @@ OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF)  += 
extract_extradata_bsf.o\
 OBJS-$(CONFIG_H264_METADATA_BSF)  += h264_metadata_bsf.o
 OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
 OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o
+OBJS-$(CONFIG_HEVC_METADATA_BSF)  += h265_metadata_bsf.o
 OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF)   += hevc_mp4toannexb_bsf.o
 OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF)+= imx_dump_header_bsf.o
 OBJS-$(CONFIG_MJPEG2JPEG_BSF) += mjpeg2jpeg_bsf.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 8fd46a734c..e90919f602 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -31,6 +31,7 @@ extern const AVBitStreamFilter ff_extract_extradata_bsf;
 extern const AVBitStreamFilter ff_h264_metadata_bsf;
 extern const AVBitStreamFilter ff_h264_mp4toannexb_bsf;
 extern const AVBitStreamFilter ff_h264_redundant_pps_bsf;
+extern const AVBitStreamFilter ff_hevc_metadata_bsf;
 extern const AVBitStreamFilter ff_hevc_mp4toannexb_bsf;
 extern const AVBitStreamFilter ff_imx_dump_header_bsf;
 extern const AVBitStreamFilter ff_mjpeg2jpeg_bsf;
diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
new file mode 100644
index 00..aef4a55fb7
--- /dev/null
+++ b/libavcodec/h265_metadata_bsf.c
@@ -0,0 +1,458 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 

[FFmpeg-cvslog] lavc: Add coded bitstream read/write support for H.265

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sun May 14 16:32:00 
2017 +0100| [867381b8b51fa21fa2b8f071f508f3d39cc9c1f0] | committer: Mark 
Thompson

lavc: Add coded bitstream read/write support for H.265

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=867381b8b51fa21fa2b8f071f508f3d39cc9c1f0
---

 configure |2 +
 libavcodec/Makefile   |1 +
 libavcodec/cbs.c  |3 +
 libavcodec/cbs_h2645.c|  410 -
 libavcodec/cbs_h265.h |  537 
 libavcodec/cbs_h265_syntax_template.c | 1502 +
 libavcodec/cbs_internal.h |1 +
 7 files changed, 2453 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 54af2e0cb5..535862fcaf 100755
--- a/configure
+++ b/configure
@@ -1741,6 +1741,7 @@ CONFIG_EXTRA="
 cabac
 cbs
 cbs_h264
+cbs_h265
 dirac_parse
 dvprofile
 faandct
@@ -1968,6 +1969,7 @@ threads_if_any="$THREADS_LIST"
 
 # subsystems
 cbs_h264_select="cbs golomb"
+cbs_h265_select="cbs golomb"
 dct_select="rdft"
 dirac_parse_select="golomb"
 error_resilience_select="me_cmp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 30fc388f8c..9791fb342e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -55,6 +55,7 @@ OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o
 OBJS-$(CONFIG_CABAC)   += cabac.o
 OBJS-$(CONFIG_CBS) += cbs.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o
 OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
 OBJS-$(CONFIG_ERROR_RESILIENCE)+= error_resilience.o
 OBJS-$(CONFIG_FAANDCT) += faandct.o
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 9352b535b2..b5d5dfd2fd 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -31,6 +31,9 @@ static const CodedBitstreamType *cbs_type_table[] = {
 #if CONFIG_CBS_H264
 _cbs_type_h264,
 #endif
+#if CONFIG_CBS_H265
+_cbs_type_h265,
+#endif
 };
 
 int ff_cbs_init(CodedBitstreamContext *ctx,
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 2350f039fa..23556f47f8 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -23,10 +23,12 @@
 #include "cbs.h"
 #include "cbs_internal.h"
 #include "cbs_h264.h"
+#include "cbs_h265.h"
 #include "golomb.h"
 #include "h264.h"
 #include "h264_sei.h"
 #include "h2645_parse.h"
+#include "hevc.h"
 
 
 static int cbs_read_ue_golomb(CodedBitstreamContext *ctx, BitstreamContext *bc,
@@ -237,6 +239,7 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, 
PutBitContext *pbc,
 
 #define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
 #define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name)
+#define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name)
 
 
 #define READ
@@ -299,6 +302,10 @@ static int cbs_h2645_read_more_rbsp_data(BitstreamContext 
*bc)
 #include "cbs_h264_syntax_template.c"
 #undef FUNC
 
+#define FUNC(name) FUNC_H265(READWRITE, name)
+#include "cbs_h265_syntax_template.c"
+#undef FUNC
+
 #undef READ
 #undef READWRITE
 #undef RWContext
@@ -368,6 +375,10 @@ static int cbs_h2645_read_more_rbsp_data(BitstreamContext 
*bc)
 #include "cbs_h264_syntax_template.c"
 #undef FUNC
 
+#define FUNC(name) FUNC_H265(READWRITE, name)
+#include "cbs_h265_syntax_template.c"
+#undef FUNC
+
 #undef WRITE
 #undef READWRITE
 #undef RWContext
@@ -428,6 +439,40 @@ static void cbs_h264_free_nal_unit(CodedBitstreamUnit 
*unit)
 av_freep(>content);
 }
 
+static void cbs_h265_free_nal_unit(CodedBitstreamUnit *unit)
+{
+switch (unit->type) {
+case HEVC_NAL_VPS:
+av_freep(&((H265RawVPS*)unit->content)->extension_data.data);
+break;
+case HEVC_NAL_SPS:
+av_freep(&((H265RawSPS*)unit->content)->extension_data.data);
+break;
+case HEVC_NAL_PPS:
+av_freep(&((H265RawPPS*)unit->content)->extension_data.data);
+break;
+case HEVC_NAL_TRAIL_N:
+case HEVC_NAL_TRAIL_R:
+case HEVC_NAL_TSA_N:
+case HEVC_NAL_TSA_R:
+case HEVC_NAL_STSA_N:
+case HEVC_NAL_STSA_R:
+case HEVC_NAL_RADL_N:
+case HEVC_NAL_RADL_R:
+case HEVC_NAL_RASL_N:
+case HEVC_NAL_RASL_R:
+case HEVC_NAL_BLA_W_LP:
+case HEVC_NAL_BLA_W_RADL:
+case HEVC_NAL_BLA_N_LP:
+case HEVC_NAL_IDR_W_RADL:
+case HEVC_NAL_IDR_N_LP:
+case HEVC_NAL_CRA_NUT:
+av_freep(&((H265RawSlice*)unit->content)->data);
+break;
+}
+av_freep(>content);
+}
+
 static int cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx,
CodedBitstreamFragment *frag,
const H2645Packet *packet)
@@ -542,6 +587,58 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
"header.\n", 

[FFmpeg-cvslog] vaapi_h264: Add support for SEI recovery points

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sun May  7 23:02:09 
2017 +0100| [a49ee60d5fdbdae1706a44cfbb814abb9793815f] | committer: Mark 
Thompson

vaapi_h264: Add support for SEI recovery points

Included by default with non-IDR intra frames.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a49ee60d5fdbdae1706a44cfbb814abb9793815f
---

 libavcodec/vaapi_encode_h264.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 4f0e879e9b..271644ebbe 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -37,6 +37,7 @@
 enum {
 SEI_TIMING = 0x01,
 SEI_IDENTIFIER = 0x02,
+SEI_RECOVERY_POINT = 0x04,
 };
 
 // Random (version 4) ISO 11578 UUID.
@@ -61,6 +62,7 @@ typedef struct VAAPIEncodeH264Context {
 
 H264RawSEIBufferingPeriod buffering_period;
 H264RawSEIPicTiming pic_timing;
+H264RawSEIRecoveryPoint recovery_point;
 H264RawSEIUserDataUnregistered identifier;
 char *identifier_string;
 
@@ -230,6 +232,11 @@ static int 
vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
 priv->sei.payload[i].payload.pic_timing = priv->pic_timing;
 ++i;
 }
+if (opt->sei & SEI_RECOVERY_POINT && pic->type == PICTURE_TYPE_I) {
+priv->sei.payload[i].payload_type = H264_SEI_TYPE_RECOVERY_POINT;
+priv->sei.payload[i].payload.recovery_point = priv->recovery_point;
+++i;
+}
 
 priv->sei.payload_count = i;
 av_assert0(priv->sei.payload_count > 0);
@@ -613,6 +620,14 @@ static int 
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
 priv->sei_needed = 1;
 }
 
+if (opt->sei & SEI_RECOVERY_POINT && pic->type == PICTURE_TYPE_I) {
+priv->recovery_point.recovery_frame_cnt = 0;
+priv->recovery_point.exact_match_flag   = 1;
+priv->recovery_point.broken_link_flag   = ctx->b_per_p > 0;
+
+priv->sei_needed = 1;
+}
+
 vpic->CurrPic = (VAPictureH264) {
 .picture_id  = pic->recon_surface,
 .frame_idx   = priv->frame_num,
@@ -950,7 +965,7 @@ static const AVOption vaapi_encode_h264_options[] = {
 
 { "sei", "Set SEI to include",
   OFFSET(sei), AV_OPT_TYPE_FLAGS,
-  { .i64 = SEI_IDENTIFIER | SEI_TIMING },
+  { .i64 = SEI_IDENTIFIER | SEI_TIMING | SEI_RECOVERY_POINT },
   0, INT_MAX, FLAGS, "sei" },
 { "identifier", "Include encoder version identifier",
   0, AV_OPT_TYPE_CONST, { .i64 = SEI_IDENTIFIER },
@@ -958,6 +973,9 @@ static const AVOption vaapi_encode_h264_options[] = {
 { "timing", "Include timing parameters (buffering_period and pic_timing)",
   0, AV_OPT_TYPE_CONST, { .i64 = SEI_TIMING },
   INT_MIN, INT_MAX, FLAGS, "sei" },
+{ "recovery_point", "Include recovery points where appropriate",
+  0, AV_OPT_TYPE_CONST, { .i64 = SEI_RECOVERY_POINT },
+  INT_MIN, INT_MAX, FLAGS, "sei" },
 { NULL },
 };
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] h264: Add support for alternative transfer characterics SEI

2017-11-10 Thread Vittorio Giovara
ffmpeg | branch: master | Vittorio Giovara  | Tue 
Aug  8 16:06:29 2017 +0200| [ebf3b9e8a875eb12312460aee505118791ef805f] | 
committer: Vittorio Giovara

h264: Add support for alternative transfer characterics SEI

The use of this SEI is for backward compatibility in HLG HDR systems:
older devices that cannot interpret the "arib-std-b67" transfer will
get the compatible transfer (usually bt709 or bt2020) from the VUI,
while newer devices that can interpret HDR will read the SEI and use
its value instead.

Signed-off-by: Vittorio Giovara 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ebf3b9e8a875eb12312460aee505118791ef805f
---

 libavcodec/h264_sei.c   | 11 +++
 libavcodec/h264_sei.h   |  7 +++
 libavcodec/h264_slice.c |  6 ++
 3 files changed, 24 insertions(+)

diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 3ca2b7a6cd..03fca9017f 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -346,6 +346,14 @@ static int 
decode_display_orientation(H264SEIDisplayOrientation *h,
 return 0;
 }
 
+static int decode_alternative_transfer(H264SEIAlternativeTransfer *h,
+   GetBitContext *gb)
+{
+h->present = 1;
+h->preferred_transfer_characteristics = get_bits(gb, 8);
+return 0;
+}
+
 int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
const H264ParamSets *ps, void *logctx)
 {
@@ -396,6 +404,9 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
 case H264_SEI_TYPE_DISPLAY_ORIENTATION:
 ret = decode_display_orientation(>display_orientation, gb);
 break;
+case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
+ret = decode_alternative_transfer(>alternative_transfer, gb);
+break;
 default:
 av_log(logctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
 skip_bits(gb, 8 * size);
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index ce9768ec3d..f6ac6034da 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -33,6 +33,7 @@ typedef enum {
 H264_SEI_TYPE_RECOVERY_POINT = 6,   ///< recovery point (frame # 
to decoder sync)
 H264_SEI_TYPE_FRAME_PACKING  = 45,  ///< frame packing arrangement
 H264_SEI_TYPE_DISPLAY_ORIENTATION= 47,  ///< display orientation
+H264_SEI_TYPE_ALTERNATIVE_TRANSFER   = 147, ///< alternative transfer
 } H264_SEI_Type;
 
 /**
@@ -115,6 +116,11 @@ typedef struct H264SEIDisplayOrientation {
 int hflip, vflip;
 } H264SEIDisplayOrientation;
 
+typedef struct H264SEIAlternativeTransfer {
+int present;
+int preferred_transfer_characteristics;
+} H264SEIAlternativeTransfer;
+
 typedef struct H264SEIContext {
 H264SEIPictureTiming picture_timing;
 H264SEIAFD afd;
@@ -124,6 +130,7 @@ typedef struct H264SEIContext {
 H264SEIBufferingPeriod buffering_period;
 H264SEIFramePacking frame_packing;
 H264SEIDisplayOrientation display_orientation;
+H264SEIAlternativeTransfer alternative_transfer;
 } H264SEIContext;
 
 struct H264ParamSets;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index c6309b298c..5dd01d836e 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1154,6 +1154,12 @@ static int h264_export_frame_props(H264Context *h)
 a53->a53_caption_size = 0;
 }
 
+if (h->sei.alternative_transfer.present &&
+
av_color_transfer_name(h->sei.alternative_transfer.preferred_transfer_characteristics)
 &&
+h->sei.alternative_transfer.preferred_transfer_characteristics != 
AVCOL_TRC_UNSPECIFIED) {
+h->avctx->color_trc = cur->f->color_trc = 
h->sei.alternative_transfer.preferred_transfer_characteristics;
+}
+
 return 0;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] vaapi_h264: Convert to use coded bitstream infrastructure

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sun May  7 15:01:42 
2017 +0100| [7a4fac5e91789b73e07bd4ad20493cfde028df76] | committer: Mark 
Thompson

vaapi_h264: Convert to use coded bitstream infrastructure

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7a4fac5e91789b73e07bd4ad20493cfde028df76
---

 configure  |2 +-
 libavcodec/Makefile|2 +-
 libavcodec/vaapi_encode_h264.c | 1421 
 3 files changed, 549 insertions(+), 876 deletions(-)

diff --git a/configure b/configure
index dfa3867ac0..b6fa8f6827 100755
--- a/configure
+++ b/configure
@@ -2285,7 +2285,7 @@ h264_omx_encoder_deps="omx"
 h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec 
h264_qsv_hwaccel"
 h264_qsv_encoder_select="qsvenc"
 h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264"
-h264_vaapi_encoder_select="vaapi_encode golomb"
+h264_vaapi_encoder_select="cbs_h264 vaapi_encode"
 hevc_nvenc_encoder_deps="nvenc"
 hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser hevc_qsv_hwaccel 
qsvdec"
 hevc_qsv_encoder_select="hevc_ps qsvenc"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e1ae1e4519..456ee9bb03 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -275,7 +275,7 @@ OBJS-$(CONFIG_H264_NVENC_ENCODER)  += nvenc_h264.o
 OBJS-$(CONFIG_H264_OMX_ENCODER)+= omx.o
 OBJS-$(CONFIG_H264_QSV_DECODER)+= qsvdec_h2645.o
 OBJS-$(CONFIG_H264_QSV_ENCODER)+= qsvenc_h264.o
-OBJS-$(CONFIG_H264_VAAPI_ENCODER)  += vaapi_encode_h264.o 
vaapi_encode_h26x.o
+OBJS-$(CONFIG_H264_VAAPI_ENCODER)  += vaapi_encode_h264.o
 OBJS-$(CONFIG_HAP_DECODER) += hapdec.o hap.o
 OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o hap.o
 OBJS-$(CONFIG_HEVC_DECODER)+= hevcdec.o hevc_mvs.o hevc_sei.o \
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index e08cf61167..b48070c950 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -16,128 +16,36 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include 
+
 #include 
 #include 
 
 #include "libavutil/avassert.h"
+#include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
-#include "libavutil/pixfmt.h"
 
 #include "avcodec.h"
+#include "cbs.h"
+#include "cbs_h264.h"
 #include "h264.h"
 #include "h264_sei.h"
 #include "internal.h"
 #include "vaapi_encode.h"
-#include "vaapi_encode_h26x.h"
 
 enum {
-SLICE_TYPE_P  = 0,
-SLICE_TYPE_B  = 1,
-SLICE_TYPE_I  = 2,
-SLICE_TYPE_SP = 3,
-SLICE_TYPE_SI = 4,
+SEI_TIMING = 0x01,
+SEI_IDENTIFIER = 0x02,
 };
 
-// This structure contains all possibly-useful per-sequence syntax elements
-// which are not already contained in the various VAAPI structures.
-typedef struct VAAPIEncodeH264MiscSequenceParams {
-unsigned int profile_idc;
-char constraint_set0_flag;
-char constraint_set1_flag;
-char constraint_set2_flag;
-char constraint_set3_flag;
-char constraint_set4_flag;
-char constraint_set5_flag;
-
-char separate_colour_plane_flag;
-char qpprime_y_zero_transform_bypass_flag;
-
-char gaps_in_frame_num_allowed_flag;
-char delta_pic_order_always_zero_flag;
-char bottom_field_pic_order_in_frame_present_flag;
-
-unsigned int num_slice_groups_minus1;
-unsigned int slice_group_map_type;
-
-int pic_init_qs_minus26;
-
-char overscan_info_present_flag;
-char overscan_appropriate_flag;
-
-char video_signal_type_present_flag;
-unsigned int video_format;
-char video_full_range_flag;
-char colour_description_present_flag;
-unsigned int colour_primaries;
-unsigned int transfer_characteristics;
-unsigned int matrix_coefficients;
-
-char chroma_loc_info_present_flag;
-unsigned int chroma_sample_loc_type_top_field;
-unsigned int chroma_sample_loc_type_bottom_field;
-
-// Some timing elements are in VAEncSequenceParameterBufferH264.
-char fixed_frame_rate_flag;
-
-char nal_hrd_parameters_present_flag;
-char vcl_hrd_parameters_present_flag;
-char low_delay_hrd_flag;
-char pic_struct_present_flag;
-
-char motion_vectors_over_pic_boundaries_flag;
-unsigned int max_bytes_per_pic_denom;
-unsigned int max_bits_per_mb_denom;
-unsigned int max_num_reorder_frames;
-unsigned int max_dec_pic_buffering;
-
-unsigned int cpb_cnt_minus1;
-unsigned int bit_rate_scale;
-unsigned int cpb_size_scale;
-unsigned int bit_rate_value_minus1[32];
-unsigned int cpb_size_value_minus1[32];
-char cbr_flag[32];
-unsigned int initial_cpb_removal_delay_length_minus1;
-unsigned int cpb_removal_delay_length_minus1;
-unsigned int dpb_output_delay_length_minus1;
-unsigned int time_offset_length;
-
-unsigned int initial_cpb_removal_delay;
-unsigned int initial_cpb_removal_delay_offset;

[FFmpeg-cvslog] vaapi_h264: Add support for AUD NAL units

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sun May  7 22:58:56 
2017 +0100| [820a4483af13cf6fd51f13638e57bcd1c3f629d4] | committer: Mark 
Thompson

vaapi_h264: Add support for AUD NAL units

Adds a new private option to enable them (off by default).

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=820a4483af13cf6fd51f13638e57bcd1c3f629d4
---

 libavcodec/vaapi_encode_h264.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index b48070c950..4f0e879e9b 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -53,6 +53,7 @@ typedef struct VAAPIEncodeH264Context {
 int fixed_qp_p;
 int fixed_qp_b;
 
+H264RawAUD aud;
 H264RawSPS sps;
 H264RawPPS pps;
 H264RawSEI sei;
@@ -77,6 +78,7 @@ typedef struct VAAPIEncodeH264Context {
 
 CodedBitstreamContext cbc;
 CodedBitstreamFragment current_access_unit;
+int aud_needed;
 int sei_needed;
 } VAAPIEncodeH264Context;
 
@@ -84,6 +86,7 @@ typedef struct VAAPIEncodeH264Options {
 int qp;
 int quality;
 int low_power;
+int aud;
 int sei;
 } VAAPIEncodeH264Options;
 
@@ -143,6 +146,13 @@ static int 
vaapi_encode_h264_write_sequence_header(AVCodecContext *avctx,
 CodedBitstreamFragment   *au = >current_access_unit;
 int err;
 
+if (priv->aud_needed) {
+err = vaapi_encode_h264_add_nal(avctx, au, >aud);
+if (err < 0)
+goto fail;
+priv->aud_needed = 0;
+}
+
 err = vaapi_encode_h264_add_nal(avctx, au, >sps);
 if (err < 0)
 goto fail;
@@ -167,6 +177,13 @@ static int 
vaapi_encode_h264_write_slice_header(AVCodecContext *avctx,
 CodedBitstreamFragment   *au = >current_access_unit;
 int err;
 
+if (priv->aud_needed) {
+err = vaapi_encode_h264_add_nal(avctx, au, >aud);
+if (err < 0)
+goto fail;
+priv->aud_needed = 0;
+}
+
 err = vaapi_encode_h264_add_nal(avctx, au, >slice);
 if (err < 0)
 goto fail;
@@ -189,6 +206,11 @@ static int 
vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
 int err, i;
 
 if (priv->sei_needed) {
+if (priv->aud_needed) {
+vaapi_encode_h264_add_nal(avctx, au, >aud);
+priv->aud_needed = 0;
+}
+
 memset(>sei, 0, sizeof(priv->sei));
 priv->sei.nal_unit_header.nal_unit_type = H264_NAL_SEI;
 
@@ -569,6 +591,14 @@ static int 
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
 priv->pic_order_cnt = pic->display_order - priv->last_idr_frame;
 priv->dpb_delay = pic->display_order - pic->encode_order + 1;
 
+if (opt->aud) {
+priv->aud_needed = 1;
+priv->aud.nal_unit_header.nal_unit_type = H264_NAL_AUD;
+priv->aud.primary_pic_type = priv->primary_pic_type;
+} else {
+priv->aud_needed = 0;
+}
+
 if (opt->sei & SEI_IDENTIFIER && pic->encode_order == 0)
 priv->sei_needed = 1;
 
@@ -915,6 +945,9 @@ static const AVOption vaapi_encode_h264_options[] = {
   "on some platforms, does not support all features)",
   OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
 
+{ "aud", "Include AUD",
+  OFFSET(aud), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
+
 { "sei", "Set SEI to include",
   OFFSET(sei), AV_OPT_TYPE_FLAGS,
   { .i64 = SEI_IDENTIFIER | SEI_TIMING },

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Merge commit 'e3e8eab359238486dc233f7aa89b7bb3cb19ec38'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Nov 11 00:47:22 
2017 -0300| [924978341516fc234a78ff5bad89d6bd6b36de23] | committer: James Almer

Merge commit 'e3e8eab359238486dc233f7aa89b7bb3cb19ec38'

* commit 'e3e8eab359238486dc233f7aa89b7bb3cb19ec38':
  vaapi_h265: Add support for AUD NAL units
  vaapi_h265: Convert to use coded bitstream infrastructure
  vaapi_h264: Add support for SEI recovery points
  vaapi_h264: Add support for AUD NAL units
  vaapi_h264: Convert to use coded bitstream infrastructure
  lavc: Add hevc_metadata bitstream filter
  lavc: Add h264_redundant_pps bitstream filter
  lavc: Add h264_metadata bitstream filter
  lavc: Add trace_headers bitstream filter
  lavc: Add coded bitstream read/write support for H.265
  lavc: Add coded bitstream read/write support for H.264
  lavc: Add coded bitstream read/write API
  pixfmt: Support chroma-derived and ictcp color matrices
  h264: Add support for alternative transfer characterics SEI
  vaapi_encode: Move quality option to common code

This commit is a noop, see
9c878651dbc8c795894740af74670b591551f619
8c34a2024da77b50470e62789e4859b45959932e
f3571048669bf876681499f49e9df492f05f73c6
6734eef6b8b464139fdc140ec9bc9e8d74173869
b4c915f4b3e15c3e787e319b961e4389762f6309
9b0c7aa0e446eceec96ba8f4009e004fad29fba3
9c7d70b49b64aa5571772a7cdb9bc426174261e0
a308872b049e33f69f4b629a06f47e3681906b93
8b26306294ffe78cc73357e2ddd56dd463db50ab
03f982bbca4211108477e772db9a339517ecde37
2e29ca2a9f19ba9a5b189f322f38497d2e2e3db0
281b68b0265953ab2623a39484d927a0e921c405
0bc7575ced65bf4aa4678ac12d550aaf87890d0e
00179664bccd1dd6fa0d1c40db453528757bf6f7
038a51258c4c5d8b77f4f9efcce6f397e5755c24

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=924978341516fc234a78ff5bad89d6bd6b36de23
---



___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavc: Add h264_metadata bitstream filter

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Thu May  4 23:09:02 
2017 +0100| [9e93001b6135a23fe4e200196c08fb4fbffed6fc] | committer: Mark 
Thompson

lavc: Add h264_metadata bitstream filter

This is able to modify some header metadata found in the SPS/VUI,
and can also add/remove AUDs and insert user data in SEI NAL units.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e93001b6135a23fe4e200196c08fb4fbffed6fc
---

 configure  |   1 +
 doc/bitstream_filters.texi |  63 +
 libavcodec/Makefile|   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/h264_metadata_bsf.c | 512 +
 5 files changed, 578 insertions(+)

diff --git a/configure b/configure
index 13dd7f54e2..f3d616800a 100755
--- a/configure
+++ b/configure
@@ -2323,6 +2323,7 @@ vc1_parser_select="vc1dsp"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header"
+h264_metadata_bsf_select="cbs_h264"
 mjpeg2jpeg_bsf_select="jpegtables"
 trace_headers_bsf_select="cbs_h264 cbs_h265"
 
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 119a2267af..08f2f390cb 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -39,6 +39,69 @@ When this option is enabled, the long-term headers are 
removed from the
 bitstream after extraction.
 @end table
 
+@section h264_metadata
+
+Modify metadata embedded in an H.264 stream.
+
+@table @option
+@item aud
+Insert or remove AUD NAL units in all access units of the stream.
+
+@table @samp
+@item insert
+@item remove
+@end table
+
+@item sample_aspect_ratio
+Set the sample aspect ratio of the stream in the VUI parameters.
+
+@item video_format
+@item video_full_range_flag
+Set the video format in the stream (see H.264 section E.2.1 and
+table E-2).
+
+@item colour_primaries
+@item transfer_characteristics
+@item matrix_coefficients
+Set the colour description in the stream (see H.264 section E.2.1
+and tables E-3, E-4 and E-5).
+
+@item chroma_sample_loc_type
+Set the chroma sample location in the stream (see H.264 section
+E.2.1 and figure E-1).
+
+@item tick_rate
+Set the tick rate (num_units_in_tick / time_scale) in the VUI
+parameters.  This is the smallest time unit representable in the
+stream, and in many cases represents the field rate of the stream
+(double the frame rate).
+@item fixed_frame_rate_flag
+Set whether the stream has fixed framerate - typically this indicates
+that the framerate is exactly half the tick rate, but the exact
+meaning is dependent on interlacing and the picture structure (see
+H.264 section E.2.1 and table E-6).
+
+@item crop_left
+@item crop_right
+@item crop_top
+@item crop_bottom
+Set the frame cropping offsets in the SPS.  These values will replace
+the current ones if the stream is already cropped.
+
+These fields are set in pixels.  Note that some sizes may not be
+representable if the chroma is subsampled or the stream is interlaced
+(see H.264 section 7.4.2.1.1).
+
+@item sei_user_data
+Insert a string as SEI unregistered user data.  The argument must
+be of the form @emph{UUID+string}, where the UUID is as hex digits
+possibly separated by hyphens, and the string can be anything.
+
+For example, @samp{086f3693-b7b3-4f2c-9653-21492feee5b8+hello} will
+insert the string ``hello'' associated with the given UUID.
+
+@end table
+
 @section h264_mp4toannexb
 
 @section imx_dump_header
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 09772a85f7..c76dffe058 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -776,6 +776,7 @@ OBJS-$(CONFIG_CHOMP_BSF)  += chomp_bsf.o
 OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
 OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF)  += extract_extradata_bsf.o\
  h2645_parse.o
+OBJS-$(CONFIG_H264_METADATA_BSF)  += h264_metadata_bsf.o
 OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
 OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF)   += hevc_mp4toannexb_bsf.o
 OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF)+= imx_dump_header_bsf.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 2e423acaf0..4ad50508cb 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -28,6 +28,7 @@ extern const AVBitStreamFilter ff_aac_adtstoasc_bsf;
 extern const AVBitStreamFilter ff_chomp_bsf;
 extern const AVBitStreamFilter ff_dump_extradata_bsf;
 extern const AVBitStreamFilter ff_extract_extradata_bsf;
+extern const AVBitStreamFilter ff_h264_metadata_bsf;
 extern const AVBitStreamFilter ff_h264_mp4toannexb_bsf;
 extern const AVBitStreamFilter ff_hevc_mp4toannexb_bsf;
 extern const AVBitStreamFilter ff_imx_dump_header_bsf;
diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
new file mode 100644
index 00..9bf96b397d
--- /dev/null
+++ b/libavcodec/h264_metadata_bsf.c
@@ -0,0 +1,512 @@
+/*
+ * This file is part of Libav.
+ *
+ * 

[FFmpeg-cvslog] lavc: Add coded bitstream read/write support for H.264

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sun May 14 16:18:25 
2017 +0100| [acf06f45441be24c5cbae0920579cd69427326a1] | committer: Mark 
Thompson

lavc: Add coded bitstream read/write support for H.264

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=acf06f45441be24c5cbae0920579cd69427326a1
---

 configure |2 +
 libavcodec/Makefile   |1 +
 libavcodec/cbs.c  |3 +
 libavcodec/cbs_h264.h |  427 
 libavcodec/cbs_h2645.c|  997 ++
 libavcodec/cbs_h2645.h|   43 ++
 libavcodec/cbs_h264_syntax_template.c | 1230 +
 libavcodec/cbs_internal.h |3 +
 8 files changed, 2706 insertions(+)

diff --git a/configure b/configure
index befaed1e58..54af2e0cb5 100755
--- a/configure
+++ b/configure
@@ -1740,6 +1740,7 @@ CONFIG_EXTRA="
 bswapdsp
 cabac
 cbs
+cbs_h264
 dirac_parse
 dvprofile
 faandct
@@ -1966,6 +1967,7 @@ w32threads_deps="atomics_native"
 threads_if_any="$THREADS_LIST"
 
 # subsystems
+cbs_h264_select="cbs golomb"
 dct_select="rdft"
 dirac_parse_select="golomb"
 error_resilience_select="me_cmp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 41da3ca7ba..30fc388f8c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -54,6 +54,7 @@ OBJS-$(CONFIG_BLOCKDSP)+= blockdsp.o
 OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o
 OBJS-$(CONFIG_CABAC)   += cabac.o
 OBJS-$(CONFIG_CBS) += cbs.o
+OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o h2645_parse.o
 OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
 OBJS-$(CONFIG_ERROR_RESILIENCE)+= error_resilience.o
 OBJS-$(CONFIG_FAANDCT) += faandct.o
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 3a205c393d..9352b535b2 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -28,6 +28,9 @@
 
 
 static const CodedBitstreamType *cbs_type_table[] = {
+#if CONFIG_CBS_H264
+_cbs_type_h264,
+#endif
 };
 
 int ff_cbs_init(CodedBitstreamContext *ctx,
diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
new file mode 100644
index 00..b58f19f17e
--- /dev/null
+++ b/libavcodec/cbs_h264.h
@@ -0,0 +1,427 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_CBS_H264_H
+#define AVCODEC_CBS_H264_H
+
+#include 
+#include 
+
+#include "cbs_h2645.h"
+#include "h264.h"
+
+
+enum {
+// This limit is arbitrary - it is sufficient for one message of each
+// type plus some repeats, and will therefore easily cover all sane
+// streams.  However, it is possible to make technically-valid streams
+// for which it will fail (for example, by including a large number of
+// user-data-unregistered messages).
+H264_MAX_SEI_PAYLOADS = 64,
+};
+
+
+typedef struct H264RawNALUnitHeader {
+uint8_t forbidden_zero_bit;
+uint8_t nal_ref_idc;
+uint8_t nal_unit_type;
+
+uint8_t svc_extension_flag;
+uint8_t avc_3d_extension_flag;
+} H264RawNALUnitHeader;
+
+typedef struct H264RawScalingList {
+int8_t delta_scale[64];
+} H264RawScalingList;
+
+typedef struct H264RawHRD {
+uint8_t cpb_cnt_minus1;
+uint8_t bit_rate_scale;
+uint8_t cpb_size_scale;
+
+uint32_t bit_rate_value_minus1[H264_MAX_CPB_CNT];
+uint32_t cpb_size_value_minus1[H264_MAX_CPB_CNT];
+uint8_t cbr_flag[H264_MAX_CPB_CNT];
+
+uint8_t initial_cpb_removal_delay_length_minus1;
+uint8_t cpb_removal_delay_length_minus1;
+uint8_t dpb_output_delay_length_minus1;
+uint8_t time_offset_length;
+} H264RawHRD;
+
+typedef struct H264RawVUI {
+uint8_t aspect_ratio_info_present_flag;
+uint8_t aspect_ratio_idc;
+uint16_t sar_width;
+uint16_t sar_height;
+
+uint8_t overscan_info_present_flag;
+uint8_t overscan_appropriate_flag;
+
+uint8_t video_signal_type_present_flag;
+uint8_t video_format;
+uint8_t video_full_range_flag;
+uint8_t colour_description_present_flag;
+uint8_t colour_primaries;
+uint8_t transfer_characteristics;
+uint8_t matrix_coefficients;
+
+uint8_t chroma_loc_info_present_flag;
+   

[FFmpeg-cvslog] vaapi_encode: Move quality option to common code

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sun Apr 30 19:27:54 
2017 +0100| [19388a7200e5d99c703271f05dba1c806720e808] | committer: Mark 
Thompson

vaapi_encode: Move quality option to common code

Use AVCodecContext.compression_level rather than a private option,
replacing the H.264-specific quality option (which stays only for
compatibility).

This now works with the H.265 encoder in the i965 driver, as well as
the existing cases with the H.264 encoder.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=19388a7200e5d99c703271f05dba1c806720e808
---

 doc/encoders.texi  |  9 ++---
 libavcodec/vaapi_encode.c  | 35 +++
 libavcodec/vaapi_encode.h  |  6 ++
 libavcodec/vaapi_encode_h264.c | 25 ++---
 4 files changed, 49 insertions(+), 26 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 7cebe39c18..c369e03bfd 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -948,7 +948,13 @@ The following standard libavcodec options are used:
 @item
 @option{rc_init_occupancy} / @option{rc_initial_buffer_occupancy}
 @item
+@option{compression_level}
+
+Speed / quality tradeoff: higher values are faster / worse quality.
+@item
 @option{q} / @option{global_quality}
+
+Size / quality tradeoff: higher values are smaller / worse quality.
 @item
 @option{qmin}
 (only: @option{qmax} is not supported)
@@ -969,9 +975,6 @@ The following standard libavcodec options are used:
 @option{level} sets the value of @emph{level_idc}.
 
 @table @option
-@item quality
-Set the local encoding quality/speed tradeoff (range 1-8, higher values are 
faster; not all
-systems implement all levels).
 @item low_power
 Use low-power encoding mode.
 @end table
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 6205184190..462ec7a8e7 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1423,6 +1423,41 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
 goto fail;
 }
 
+if (avctx->compression_level >= 0) {
+#if VA_CHECK_VERSION(0, 36, 0)
+VAConfigAttrib attr = { VAConfigAttribEncQualityRange };
+
+vas = vaGetConfigAttributes(ctx->hwctx->display,
+ctx->va_profile,
+ctx->va_entrypoint,
+, 1);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_WARNING, "Failed to query quality "
+   "attribute: will use default compression level.\n");
+} else {
+if (avctx->compression_level > attr.value) {
+av_log(avctx, AV_LOG_WARNING, "Invalid compression "
+   "level: valid range is 0-%d, using %d.\n",
+   attr.value, attr.value);
+avctx->compression_level = attr.value;
+}
+
+ctx->quality_params.misc.type =
+VAEncMiscParameterTypeQualityLevel;
+ctx->quality_params.quality.quality_level =
+avctx->compression_level;
+
+ctx->global_params[ctx->nb_global_params] =
+>quality_params.misc;
+ctx->global_params_size[ctx->nb_global_params++] =
+sizeof(ctx->quality_params);
+}
+#else
+av_log(avctx, AV_LOG_WARNING, "The encode compression level "
+   "option is not supported with this VAAPI version.\n");
+#endif
+}
+
 ctx->input_order  = 0;
 ctx->output_delay = avctx->max_b_frames;
 ctx->decode_delay = 1;
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index fc62365148..1b0fed80e4 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -159,6 +159,12 @@ typedef struct VAAPIEncodeContext {
 VAEncMiscParameterBuffer misc;
 VAEncMiscParameterFrameRate fr;
 } fr_params;
+#if VA_CHECK_VERSION(0, 36, 0)
+struct {
+VAEncMiscParameterBuffer misc;
+VAEncMiscParameterBufferQualityLevel quality;
+} quality_params;
+#endif
 
 // Per-sequence parameter structure (VAEncSequenceParameterBuffer*).
 void   *codec_sequence_params;
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 7583a20c14..e08cf61167 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -154,14 +154,6 @@ typedef struct VAAPIEncodeH264Context {
 
 // Rate control configuration.
 int send_timing_sei;
-
-#if VA_CHECK_VERSION(0, 36, 0)
-// Speed-quality tradeoff setting.
-struct {
-VAEncMiscParameterBuffer misc;
-VAEncMiscParameterBufferQualityLevel quality;
-} quality_params;
-#endif
 } VAAPIEncodeH264Context;
 
 typedef struct VAAPIEncodeH264Options {
@@ -1141,21 +1133,8 @@ static av_cold int 
vaapi_encode_h264_configure(AVCodecContext *avctx)
 av_assert0(0 && "Invalid RC mode.");
 }
 
-if (opt->quality > 0) {

[FFmpeg-cvslog] lavc: Add coded bitstream read/write API

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Thu May  4 23:01:51 
2017 +0100| [18f1706f331bf5dd565774eae680508c8d3a97ad] | committer: Mark 
Thompson

lavc: Add coded bitstream read/write API

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=18f1706f331bf5dd565774eae680508c8d3a97ad
---

 configure |   1 +
 libavcodec/Makefile   |   1 +
 libavcodec/cbs.c  | 460 ++
 libavcodec/cbs.h  | 274 +++
 libavcodec/cbs_internal.h |  83 +
 5 files changed, 819 insertions(+)

diff --git a/configure b/configure
index 4510100f38..befaed1e58 100755
--- a/configure
+++ b/configure
@@ -1739,6 +1739,7 @@ CONFIG_EXTRA="
 blockdsp
 bswapdsp
 cabac
+cbs
 dirac_parse
 dvprofile
 faandct
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index bb568ddbe4..41da3ca7ba 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -53,6 +53,7 @@ OBJS-$(CONFIG_AUDIODSP)+= audiodsp.o
 OBJS-$(CONFIG_BLOCKDSP)+= blockdsp.o
 OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o
 OBJS-$(CONFIG_CABAC)   += cabac.o
+OBJS-$(CONFIG_CBS) += cbs.o
 OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
 OBJS-$(CONFIG_ERROR_RESILIENCE)+= error_resilience.o
 OBJS-$(CONFIG_FAANDCT) += faandct.o
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
new file mode 100644
index 00..3a205c393d
--- /dev/null
+++ b/libavcodec/cbs.c
@@ -0,0 +1,460 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "config.h"
+
+#include "libavutil/avassert.h"
+#include "libavutil/common.h"
+
+#include "cbs.h"
+#include "cbs_internal.h"
+
+
+static const CodedBitstreamType *cbs_type_table[] = {
+};
+
+int ff_cbs_init(CodedBitstreamContext *ctx,
+enum AVCodecID codec_id, void *log_ctx)
+{
+const CodedBitstreamType *type;
+int i;
+
+type = NULL;
+for (i = 0; i < FF_ARRAY_ELEMS(cbs_type_table); i++) {
+if (cbs_type_table[i]->codec_id == codec_id) {
+type = cbs_type_table[i];
+break;
+}
+}
+if (!type)
+return AVERROR(EINVAL);
+
+ctx->log_ctx = log_ctx;
+ctx->codec   = type;
+
+ctx->priv_data = av_mallocz(ctx->codec->priv_data_size);
+if (!ctx->priv_data)
+return AVERROR(ENOMEM);
+
+ctx->decompose_unit_types = NULL;
+
+ctx->trace_enable = 0;
+ctx->trace_level  = AV_LOG_TRACE;
+
+return 0;
+}
+
+void ff_cbs_close(CodedBitstreamContext *ctx)
+{
+if (ctx->codec && ctx->codec->close)
+ctx->codec->close(ctx);
+
+av_freep(>priv_data);
+}
+
+static void cbs_unit_uninit(CodedBitstreamContext *ctx,
+CodedBitstreamUnit *unit)
+{
+if (ctx->codec->free_unit && unit->content && !unit->content_external)
+ctx->codec->free_unit(unit);
+
+av_freep(>data);
+unit->data_size = 0;
+unit->data_bit_padding = 0;
+}
+
+void ff_cbs_fragment_uninit(CodedBitstreamContext *ctx,
+CodedBitstreamFragment *frag)
+{
+int i;
+
+for (i = 0; i < frag->nb_units; i++)
+cbs_unit_uninit(ctx, >units[i]);
+av_freep(>units);
+frag->nb_units = 0;
+
+av_freep(>data);
+frag->data_size= 0;
+frag->data_bit_padding = 0;
+}
+
+static int cbs_read_fragment_content(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *frag)
+{
+int err, i, j;
+
+for (i = 0; i < frag->nb_units; i++) {
+if (ctx->decompose_unit_types) {
+for (j = 0; j < ctx->nb_decompose_unit_types; j++) {
+if (ctx->decompose_unit_types[j] == frag->units[i].type)
+break;
+}
+if (j >= ctx->nb_decompose_unit_types)
+continue;
+}
+
+err = ctx->codec->read_unit(ctx, >units[i]);
+if (err == AVERROR(ENOSYS)) {
+av_log(ctx->log_ctx, AV_LOG_WARNING,
+   "Decomposition unimplemented for unit %d "
+   "(type %d).\n", i, frag->units[i].type);
+} else if (err < 0) {
+

[FFmpeg-cvslog] pixfmt: Support chroma-derived and ictcp color matrices

2017-11-10 Thread Vittorio Giovara
ffmpeg | branch: master | Vittorio Giovara  | Tue 
Aug  8 16:30:32 2017 +0200| [538e50875105c9d4a04bc4ed4a217e87f422137e] | 
committer: Vittorio Giovara

pixfmt: Support chroma-derived and ictcp color matrices

Signed-off-by: Vittorio Giovara 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=538e50875105c9d4a04bc4ed4a217e87f422137e
---

 libavutil/pixdesc.c | 3 +++
 libavutil/pixfmt.h  | 3 +++
 libavutil/version.h | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 7fa6dd7c0b..b168ac7d0b 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -1806,6 +1806,9 @@ static const char * const color_space_names[] = {
 [AVCOL_SPC_BT2020_NCL] = "bt2020nc",
 [AVCOL_SPC_BT2020_CL] = "bt2020c",
 [AVCOL_SPC_SMPTE2085] = "smpte2085",
+[AVCOL_SPC_CHROMA_DERIVED_NCL] = "chroma-derived-nc",
+[AVCOL_SPC_CHROMA_DERIVED_CL] = "chroma-derived-c",
+[AVCOL_SPC_ICTCP] = "ictcp",
 };
 
 static const char * const chroma_location_names[] = {
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 2ba7ad1c88..bcbb378378 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -384,6 +384,9 @@ enum AVColorSpace {
 AVCOL_SPC_BT2020_NCL  = 9,  ///< ITU-R BT2020 non-constant luminance system
 AVCOL_SPC_BT2020_CL   = 10, ///< ITU-R BT2020 constant luminance system
 AVCOL_SPC_SMPTE2085   = 11, ///< SMPTE 2085, Y'D'zD'x
+AVCOL_SPC_CHROMA_DERIVED_NCL = 12, ///< Chromaticity-derived non-constant 
luminance system
+AVCOL_SPC_CHROMA_DERIVED_CL = 13, ///< Chromaticity-derived constant 
luminance system
+AVCOL_SPC_ICTCP   = 14, ///< ITU-R BT.2100-0, ICtCp
 AVCOL_SPC_NB,   ///< Not part of ABI
 };
 
diff --git a/libavutil/version.h b/libavutil/version.h
index 62fb38a27a..5d0bb61124 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR  4
+#define LIBAVUTIL_VERSION_MINOR  5
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] hevc: Validate the number of long term reference pictures

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sat Jun 24 00:29:14 
2017 +0100| [1329c08ad6d2ddb304858f2972c67b508e8b0f0e] | committer: Mark 
Thompson

hevc: Validate the number of long term reference pictures

This would overflow if the stream contained a value greater than the
maximum allowed by the standard (32).

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1329c08ad6d2ddb304858f2972c67b508e8b0f0e
---

 libavcodec/hevc_ps.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 74906fd71b..2603e6d99f 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -883,6 +883,12 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 sps->long_term_ref_pics_present_flag = get_bits1(gb);
 if (sps->long_term_ref_pics_present_flag) {
 sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb);
+if (sps->num_long_term_ref_pics_sps > HEVC_MAX_LONG_TERM_REF_PICS) {
+av_log(avctx, AV_LOG_ERROR, "Too many long term ref pics: %d.\n",
+   sps->num_long_term_ref_pics_sps);
+ret = AVERROR_INVALIDDATA;
+goto err;
+}
 for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
 sps->lt_ref_pic_poc_lsb_sps[i]   = get_bits(gb, 
sps->log2_max_poc_lsb);
 sps->used_by_curr_pic_lt_sps_flag[i] = get_bits1(gb);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Merge commit '1329c08ad6d2ddb304858f2972c67b508e8b0f0e'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Nov 11 00:36:22 
2017 -0300| [36e0093dd91fa75ded475f2430852a6b0e86b59a] | committer: James Almer

Merge commit '1329c08ad6d2ddb304858f2972c67b508e8b0f0e'

* commit '1329c08ad6d2ddb304858f2972c67b508e8b0f0e':
  hevc: Validate the number of long term reference pictures

See ea38e5a6b75706477898eb1e6582d667dbb9946c

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=36e0093dd91fa75ded475f2430852a6b0e86b59a
---

 libavcodec/hevc_ps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 72d02c8372..a4f7ed60f7 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1075,8 +1075,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 sps->long_term_ref_pics_present_flag = get_bits1(gb);
 if (sps->long_term_ref_pics_present_flag) {
 sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb);
-if (sps->num_long_term_ref_pics_sps > 31U) {
-av_log(avctx, AV_LOG_ERROR, "num_long_term_ref_pics_sps %d is out 
of range.\n",
+if (sps->num_long_term_ref_pics_sps > HEVC_MAX_LONG_TERM_REF_PICS) {
+av_log(avctx, AV_LOG_ERROR, "Too many long term ref pics: %d.\n",
sps->num_long_term_ref_pics_sps);
 return AVERROR_INVALIDDATA;
 }


==

diff --cc libavcodec/hevc_ps.c
index 72d02c8372,2603e6d99f..a4f7ed60f7
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@@ -1075,10 -883,11 +1075,10 @@@ int ff_hevc_parse_sps(HEVCSPS *sps, Get
  sps->long_term_ref_pics_present_flag = get_bits1(gb);
  if (sps->long_term_ref_pics_present_flag) {
  sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb);
- if (sps->num_long_term_ref_pics_sps > 31U) {
- av_log(avctx, AV_LOG_ERROR, "num_long_term_ref_pics_sps %d is out 
of range.\n",
+ if (sps->num_long_term_ref_pics_sps > HEVC_MAX_LONG_TERM_REF_PICS) {
+ av_log(avctx, AV_LOG_ERROR, "Too many long term ref pics: %d.\n",
 sps->num_long_term_ref_pics_sps);
 -ret = AVERROR_INVALIDDATA;
 -goto err;
 +return AVERROR_INVALIDDATA;
  }
  for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
  sps->lt_ref_pic_poc_lsb_sps[i]   = get_bits(gb, 
sps->log2_max_poc_lsb);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Merge commit 'b88da98b34809dedf8882d43ed543632ed233538'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Nov 11 00:34:18 
2017 -0300| [95a52ca884ce7d7e0a0653c558bd56039ffdc8c4] | committer: James Almer

Merge commit 'b88da98b34809dedf8882d43ed543632ed233538'

* commit 'b88da98b34809dedf8882d43ed543632ed233538':
  hevc: Improve stream constraint values in common header
  h264: Add stream constraint values to the common header

This commit is a noop, see
d05444d2c6d99767547b1f0761e8459fb07b305d
b1374e925c1cf3af5c8482119f3f2630d66213de

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=95a52ca884ce7d7e0a0653c558bd56039ffdc8c4
---



___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] hevc: Improve stream constraint values in common header

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sat Jun 24 00:29:02 
2017 +0100| [b88da98b34809dedf8882d43ed543632ed233538] | committer: Mark 
Thompson

hevc: Improve stream constraint values in common header

Add comments to describe the sources of the constraint values expressed here,
and add some more related values which will be used in following patches.

Fix the incorrect values for SPS and PPS count (they are not the same as those
used for H.264), and remove HEVC_MAX_CU_SIZE because it is not used anywhere.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b88da98b34809dedf8882d43ed543632ed233538
---

 libavcodec/hevc.h| 65 ++--
 libavcodec/hevc_ps.c |  2 +-
 libavcodec/hevc_ps.h |  6 ++---
 libavformat/hevc.c   |  6 ++---
 4 files changed, 60 insertions(+), 19 deletions(-)

diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 9d956d0838..77bd6a6373 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -74,19 +74,60 @@ enum HEVCSliceType {
 HEVC_SLICE_I = 2,
 };
 
-/**
- * 7.4.2.1
- */
-#define HEVC_MAX_SUB_LAYERS 7
-#define HEVC_MAX_VPS_COUNT 16
-#define HEVC_MAX_SPS_COUNT 32
-#define HEVC_MAX_PPS_COUNT 256
-#define HEVC_MAX_SHORT_TERM_RPS_COUNT 64
-#define HEVC_MAX_CU_SIZE 128
+enum {
+// 7.4.3.1: vps_max_layers_minus1 is in [0, 62].
+HEVC_MAX_LAYERS = 63,
+// 7.4.3.1: vps_max_sub_layers_minus1 is in [0, 6].
+HEVC_MAX_SUB_LAYERS = 7,
+// 7.4.3.1: vps_num_layer_sets_minus1 is in [0, 1023].
+HEVC_MAX_LAYER_SETS = 1024,
+
+// 7.4.2.1: vps_video_parameter_set_id is u(4).
+HEVC_MAX_VPS_COUNT = 16,
+// 7.4.3.2.1: sps_seq_parameter_set_id is in [0, 15].
+HEVC_MAX_SPS_COUNT = 16,
+// 7.4.3.3.1: pps_pic_parameter_set_id is in [0, 63].
+HEVC_MAX_PPS_COUNT = 64,
+
+// A.4.2: MaxDpbSize is bounded above by 16.
+HEVC_MAX_DPB_SIZE = 16,
+// 7.4.3.1: vps_max_dec_pic_buffering_minus1[i] is in [0, MaxDpbSize - 1].
+HEVC_MAX_REFS = HEVC_MAX_DPB_SIZE,
+
+// 7.4.3.2.1: num_short_term_ref_pic_sets is in [0, 64].
+HEVC_MAX_SHORT_TERM_REF_PIC_SETS = 64,
+// 7.4.3.2.1: num_long_term_ref_pics_sps is in [0, 32].
+HEVC_MAX_LONG_TERM_REF_PICS  = 32,
 
-#define HEVC_MAX_REFS 16
-#define HEVC_MAX_DPB_SIZE 16 // A.4.1
+// A.3: all profiles require that CtbLog2SizeY is in [4, 6].
+HEVC_MIN_LOG2_CTB_SIZE = 4,
+HEVC_MAX_LOG2_CTB_SIZE = 6,
+
+// E.3.2: cpb_cnt_minus1[i] is in [0, 31].
+HEVC_MAX_CPB_CNT = 32,
+
+// A.4.1: in table A.6 the highest level allows a MaxLumaPs of 35 651 584.
+HEVC_MAX_LUMA_PS = 35651584,
+// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
+// constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence height/
+// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
+HEVC_MAX_WIDTH  = 16888,
+HEVC_MAX_HEIGHT = 16888,
+
+// A.4.1: table A.6 allows at most 22 tile rows for any level.
+HEVC_MAX_TILE_ROWS= 22,
+// A.4.1: table A.6 allows at most 20 tile columns for any level.
+HEVC_MAX_TILE_COLUMNS = 20,
+
+// 7.4.7.1: in the worst case (tiles_enabled_flag and
+// entropy_coding_sync_enabled_flag are both set), entry points can be
+// placed at the beginning of every Ctb row in every tile, giving an
+// upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY - 1.
+// Only a stream with very high resolution and perverse parameters could
+// get near that, though, so set a lower limit here with the maximum
+// possible value for 4K video (at most 135 16x16 Ctb rows).
+HEVC_MAX_ENTRY_POINT_OFFSETS = HEVC_MAX_TILE_COLUMNS * 135,
+};
 
-#define HEVC_MAX_LOG2_CTB_SIZE 6
 
 #endif /* AVCODEC_HEVC_H */
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 3c98e4ce44..74906fd71b 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -868,7 +868,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 }
 
 sps->nb_st_rps = get_ue_golomb_long(gb);
-if (sps->nb_st_rps > HEVC_MAX_SHORT_TERM_RPS_COUNT) {
+if (sps->nb_st_rps > HEVC_MAX_SHORT_TERM_REF_PIC_SETS) {
 av_log(avctx, AV_LOG_ERROR, "Too many short term RPS: %d.\n",
sps->nb_st_rps);
 ret = AVERROR_INVALIDDATA;
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 89a481ba8e..6e2b527773 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -166,14 +166,14 @@ typedef struct HEVCSPS {
 ScalingList scaling_list;
 
 unsigned int nb_st_rps;
-ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_RPS_COUNT];
+ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_REF_PIC_SETS];
 
 uint8_t amp_enabled_flag;
 uint8_t sao_enabled;
 
 uint8_t long_term_ref_pics_present_flag;
-uint16_t lt_ref_pic_poc_lsb_sps[32];
-uint8_t used_by_curr_pic_lt_sps_flag[32];
+uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS];
+uint8_t 

[FFmpeg-cvslog] h264: Add stream constraint values to the common header

2017-11-10 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Sat Jun 24 00:30:20 
2017 +0100| [aaf441465080b9bc57f5ca8dea656f9b2c5dc821] | committer: Mark 
Thompson

h264: Add stream constraint values to the common header

With comments describing the derivation of each value.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aaf441465080b9bc57f5ca8dea656f9b2c5dc821
---

 libavcodec/h264.h | 45 +
 1 file changed, 45 insertions(+)

diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index eb3805c067..aa137b5b54 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -44,4 +44,49 @@ enum {
 H264_NAL_AUXILIARY_SLICE = 19,
 };
 
+
+enum {
+// 7.4.2.1.1: seq_parameter_set_id is in [0, 31].
+H264_MAX_SPS_COUNT = 32,
+// 7.4.2.2: pic_parameter_set_id is in [0, 255].
+H264_MAX_PPS_COUNT = 256,
+
+// A.3: MaxDpbFrames is bounded above by 16.
+H264_MAX_DPB_FRAMES = 16,
+// 7.4.2.1.1: max_num_ref_frames is in [0, MaxDpbFrames], and
+// each reference frame can have two fields.
+H264_MAX_REFS   = 2 * H264_MAX_DPB_FRAMES,
+
+// 7.4.3.1: modification_of_pic_nums_idc is not equal to 3 at most
+// num_ref_idx_lN_active_minus1 + 1 times (that is, once for each
+// possible reference), then equal to 3 once.
+H264_MAX_RPLM_COUNT = H264_MAX_REFS + 1,
+
+// 7.4.3.3: in the worst case, we begin with a full short-term
+// reference picture list.  Each picture in turn is moved to the
+// long-term list (type 3) and then discarded from there (type 2).
+// Then, we set the length of the long-term list (type 4), mark
+// the current picture as long-term (type 6) and terminate the
+// process (type 0).
+H264_MAX_MMCO_COUNT = H264_MAX_REFS * 2 + 3,
+
+// A.2.1, A.2.3: profiles supporting FMO constrain
+// num_slice_groups_minus1 to be in [0, 7].
+H264_MAX_SLICE_GROUPS = 8,
+
+// E.2.2: cpb_cnt_minus1 is in [0, 31].
+H264_MAX_CPB_CNT = 32,
+
+// A.3: in table A-1 the highest level allows a MaxFS of 139264.
+H264_MAX_MB_PIC_SIZE = 139264,
+// A.3.1, A.3.2: PicWidthInMbs and PicHeightInMbs are constrained
+// to be not greater than sqrt(MaxFS * 8).  Hence height/width are
+// bounded above by sqrt(139264 * 8) = 1055.5 macroblocks.
+H264_MAX_MB_WIDTH= 1055,
+H264_MAX_MB_HEIGHT   = 1055,
+H264_MAX_WIDTH   = H264_MAX_MB_WIDTH  * 16,
+H264_MAX_HEIGHT  = H264_MAX_MB_HEIGHT * 16,
+};
+
+
 #endif /* AVCODEC_H264_H */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Merge commit 'defe307fb22beca60a632e976ab97e5edd4aee25'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Nov 11 00:28:53 
2017 -0300| [73198aca2c27712e45f29dec769f4c343ee40c20] | committer: James Almer

Merge commit 'defe307fb22beca60a632e976ab97e5edd4aee25'

* commit 'defe307fb22beca60a632e976ab97e5edd4aee25':
  mov: move stsd finalization to an appropriate place
  mov: Do not set stsd_count if mov_read_stsd() fails
  mov: log and return early on non-positive stsd entry counts

See 8b43ee4054af799e388d380b379a13a60849c1b5
656feb641de3cd5b9cb4e33ffd3f0ad4664c36d2

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=73198aca2c27712e45f29dec769f4c343ee40c20
---

 libavformat/mov.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 7954db6e47..5fc597ee26 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2548,15 +2548,18 @@ static int mov_read_stsd(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 
 /* Prepare space for hosting multiple extradata. */
 sc->extradata = av_mallocz_array(entries, sizeof(*sc->extradata));
+if (!sc->extradata)
+return AVERROR(ENOMEM);
+
 sc->extradata_size = av_mallocz_array(entries, 
sizeof(*sc->extradata_size));
-if (!sc->extradata_size || !sc->extradata) {
+if (!sc->extradata_size) {
 ret = AVERROR(ENOMEM);
 goto fail;
 }
 
 ret = ff_mov_read_stsd_entries(c, pb, entries);
 if (ret < 0)
-return ret;
+goto fail;
 
 sc->stsd_count = entries;
 


==


___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] mov: move stsd finalization to an appropriate place

2017-11-10 Thread Sean McGovern
ffmpeg | branch: master | Sean McGovern  | Sat Jul 29 
19:17:16 2017 -0400| [defe307fb22beca60a632e976ab97e5edd4aee25] | committer: 
Sean McGovern

mov: move stsd finalization to an appropriate place

mov_finalize_stsd_codec() parses stream information from the ALAC extradata,
so run it after the extradata processing is completed in mov_read_stsd().

Fixes playback of 96kHz ALAC streams muxed by qaac or the reference alac 
encoder.

Adapted from an FFmpeg patch by Hendrik Leppkes 

Bug-Id: 1072

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=defe307fb22beca60a632e976ab97e5edd4aee25
---

 libavformat/mov.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2134bd1743..6711d8e11e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1857,7 +1857,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext 
*pb, int entries)
 if (pb->eof_reached)
 return AVERROR_EOF;
 
-return mov_finalize_stsd_codec(c, pb, st, sc);
+return 0;
 }
 
 static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@@ -1913,7 +1913,7 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 }
 memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]);
 
-return 0;
+return mov_finalize_stsd_codec(c, pb, st, sc);
 fail:
 av_freep(>extradata);
 av_freep(>extradata_size);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] mov: log and return early on non-positive stsd entry counts

2017-11-10 Thread Sean McGovern
ffmpeg | branch: master | Sean McGovern  | Fri Jul 28 
16:17:33 2017 -0400| [d7bdab1ad78ef582ba8c96dc7b79ec9fdbeeb94f] | committer: 
Sean McGovern

mov: log and return early on non-positive stsd entry counts

Based on an FFmpeg patch by Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d7bdab1ad78ef582ba8c96dc7b79ec9fdbeeb94f
---

 libavformat/mov.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index bf68fbd46a..8ff60222ef 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1875,6 +1875,11 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 avio_rb24(pb); /* flags */
 entries = avio_rb32(pb);
 
+if (entries <= 0) {
+av_log(c->fc, AV_LOG_ERROR, "invalid STSD entries %d\n", entries);
+return AVERROR_INVALIDDATA;
+}
+
 if (sc->extradata) {
 av_log(c->fc, AV_LOG_ERROR,
"Duplicate stsd found in this track.\n");

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] mov: Do not set stsd_count if mov_read_stsd() fails

2017-11-10 Thread Sean McGovern
ffmpeg | branch: master | Sean McGovern  | Fri Jul 28 
16:29:35 2017 -0400| [3050dabaa9a337ad077ec60bba664ad9861e1aa6] | committer: 
Sean McGovern

mov: Do not set stsd_count if mov_read_stsd() fails

Based on an FFmpeg patch by Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3050dabaa9a337ad077ec60bba664ad9861e1aa6
---

 libavformat/mov.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8ff60222ef..2134bd1743 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1891,24 +1891,33 @@ static int mov_read_stsd(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 if (!sc->extradata)
 return AVERROR(ENOMEM);
 
-sc->stsd_count = entries;
-sc->extradata_size = av_mallocz_array(sc->stsd_count, 
sizeof(*sc->extradata_size));
-if (!sc->extradata_size)
-return AVERROR(ENOMEM);
+sc->extradata_size = av_mallocz_array(entries, 
sizeof(*sc->extradata_size));
+if (!sc->extradata_size) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 
-ret = ff_mov_read_stsd_entries(c, pb, sc->stsd_count);
+ret = ff_mov_read_stsd_entries(c, pb, entries);
 if (ret < 0)
-return ret;
+goto fail;
+
+sc->stsd_count = entries;
 
 /* Restore back the primary extradata. */
 av_free(st->codecpar->extradata);
 st->codecpar->extradata_size = sc->extradata_size[0];
 st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!st->codecpar->extradata)
-return AVERROR(ENOMEM);
+if (!st->codecpar->extradata) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]);
 
 return 0;
+fail:
+av_freep(>extradata);
+av_freep(>extradata_size);
+return ret;
 }
 
 static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Merge commit '770cf1dbc2c8fe9b84300439ad0cd85036480388'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Nov 10 20:36:39 
2017 -0300| [ec54df7dcd5935cc5efa6a25293b255a5d9a67f5] | committer: James Almer

Merge commit '770cf1dbc2c8fe9b84300439ad0cd85036480388'

* commit '770cf1dbc2c8fe9b84300439ad0cd85036480388':
  fate/hevc: specify output pixel format explicitly

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ec54df7dcd5935cc5efa6a25293b255a5d9a67f5
---

 tests/fate/hevc.mak | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 2e798eca60..5a3c156ee6 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -187,7 +187,7 @@ HEVC_SAMPLES_444_12BIT =\
 
 define FATE_HEVC_TEST
 FATE_HEVC += fate-hevc-conformance-$(1)
-fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -vsync drop -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit
+fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -vsync drop -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv420p
 endef
 
 define FATE_HEVC_TEST_10BIT
@@ -207,7 +207,7 @@ endef
 
 define FATE_HEVC_TEST_444_8BIT
 FATE_HEVC += fate-hevc-conformance-$(1)
-fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit
+fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv444p
 endef
 
 define FATE_HEVC_TEST_444_12BIT


==

diff --cc tests/fate/hevc.mak
index 2e798eca60,fe3ef26c77..5a3c156ee6
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@@ -187,32 -144,12 +187,32 @@@ HEVC_SAMPLES_444_12BIT =
  
  define FATE_HEVC_TEST
  FATE_HEVC += fate-hevc-conformance-$(1)
- fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -vsync drop -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit
 -fate-hevc-conformance-$(1): CMD = framecrc -vsync 0 -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv420p
++fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -vsync drop -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv420p
  endef
  
  define FATE_HEVC_TEST_10BIT
  FATE_HEVC += fate-hevc-conformance-$(1)
 -fate-hevc-conformance-$(1): CMD = framecrc -vsync 0 -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv420p10le
 +fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv420p10le
 +endef
 +
 +define FATE_HEVC_TEST_422_10BIT
 +FATE_HEVC += fate-hevc-conformance-$(1)
 +fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv422p10le
 +endef
 +
 +define FATE_HEVC_TEST_422_10BIN
 +FATE_HEVC += fate-hevc-conformance-$(1)
 +fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bin -pix_fmt yuv422p10le
 +endef
 +
 +define FATE_HEVC_TEST_444_8BIT
 +FATE_HEVC += fate-hevc-conformance-$(1)
- fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit
++fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv444p
 +endef
 +
 +define FATE_HEVC_TEST_444_12BIT
 +FATE_HEVC += fate-hevc-conformance-$(1)
 +fate-hevc-conformance-$(1): CMD = framecrc -flags unaligned -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv444p12le
  endef
  
  $(foreach N,$(HEVC_SAMPLES),$(eval $(call FATE_HEVC_TEST,$(N

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Merge commit '004ea63714e31ed43326ad00d7420d104f0dab38'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Nov 10 20:16:15 
2017 -0300| [fd352fadbbdf850e22c2bf87d8634cbc981976ef] | committer: James Almer

Merge commit '004ea63714e31ed43326ad00d7420d104f0dab38'

* commit '004ea63714e31ed43326ad00d7420d104f0dab38':
  cuvid: add cuvid.h to SKIPHEADERS

This commit is a noop, nvdec.h compiles just fine since it doesn't
depend on external headers.

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fd352fadbbdf850e22c2bf87d8634cbc981976ef
---



___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/nvdec: fix copyright headers

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Nov 10 21:06:58 
2017 -0300| [27604549456282102eadbcb920b9a64775c683e1] | committer: James Almer

avcodec/nvdec: fix copyright headers

Fixes fate-source.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=27604549456282102eadbcb920b9a64775c683e1
---

 libavcodec/nvdec.c  | 10 +-
 libavcodec/nvdec.h  | 10 +-
 libavcodec/nvdec_h264.c | 10 +-
 libavcodec/nvdec_hevc.c | 10 +-
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index ab66b91a92..db338accfa 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -3,21 +3,21 @@
  *
  * Copyright (c) 2016 Anton Khirnov
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include "config.h"
diff --git a/libavcodec/nvdec.h b/libavcodec/nvdec.h
index 75ed5d492d..18a64cd445 100644
--- a/libavcodec/nvdec.h
+++ b/libavcodec/nvdec.h
@@ -3,21 +3,21 @@
  *
  * Copyright (c) 2016 Anton Khirnov
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #ifndef AVCODEC_NVDEC_H
diff --git a/libavcodec/nvdec_h264.c b/libavcodec/nvdec_h264.c
index 4a6054089b..75dd4b2eb8 100644
--- a/libavcodec/nvdec_h264.c
+++ b/libavcodec/nvdec_h264.c
@@ -3,21 +3,21 @@
  *
  * Copyright (c) 2016 Anton Khirnov
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include 
diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c
index 3c40ab2bea..89c1be5f7c 100644
--- a/libavcodec/nvdec_hevc.c
+++ b/libavcodec/nvdec_hevc.c
@@ -3,21 +3,21 @@
  *
  * Copyright (c) 2017 Anton Khirnov
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as 

[FFmpeg-cvslog] fate/hevc: specify output pixel format explicitly

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Jul 24 
11:42:09 2017 +0200| [770cf1dbc2c8fe9b84300439ad0cd85036480388] | committer: 
Anton Khirnov

fate/hevc: specify output pixel format explicitly

This allows running those tests with hwaccel.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=770cf1dbc2c8fe9b84300439ad0cd85036480388
---

 tests/fate/hevc.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 5446969a7d..fe3ef26c77 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -144,7 +144,7 @@ HEVC_SAMPLES_10BIT =\
 
 define FATE_HEVC_TEST
 FATE_HEVC += fate-hevc-conformance-$(1)
-fate-hevc-conformance-$(1): CMD = framecrc -vsync 0 -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit
+fate-hevc-conformance-$(1): CMD = framecrc -vsync 0 -i 
$(TARGET_SAMPLES)/hevc-conformance/$(1).bit -pix_fmt yuv420p
 endef
 
 define FATE_HEVC_TEST_10BIT

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Merge commit 'b90fdb2c7199cc8b0e8d994fafba1fb4dc181d88'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Nov 10 20:38:36 
2017 -0300| [1178babacaaad4e65fcb28af447afd586429c51a] | committer: James Almer

Merge commit 'b90fdb2c7199cc8b0e8d994fafba1fb4dc181d88'

* commit 'b90fdb2c7199cc8b0e8d994fafba1fb4dc181d88':
  hevcdec: add a CUVID hwaccel

Adapted for ffmpeg by Timo Rothenpieler.

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1178babacaaad4e65fcb28af447afd586429c51a
---

 Changelog   |   2 +-
 configure   |   2 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/hevcdec.c|   7 ++
 libavcodec/nvdec.c  |   1 +
 libavcodec/nvdec_hevc.c | 279 
 7 files changed, 292 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index ba2951db25..cd4a841619 100644
--- a/Changelog
+++ b/Changelog
@@ -13,7 +13,7 @@ version :
 - PCE support for extended channel layouts in the AAC encoder
 - native aptX encoder and decoder
 - Raw aptX muxer and demuxer
-- NVIDIA NVDEC-accelerated H.264 hwaccel decoding
+- NVIDIA NVDEC-accelerated H.264 and HEVC hwaccel decoding
 
 
 version 3.4:
diff --git a/configure b/configure
index 1b90d8e9a1..2cf18ecc12 100755
--- a/configure
+++ b/configure
@@ -2692,6 +2692,8 @@ hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
 hevc_d3d11va2_hwaccel_select="hevc_decoder"
 hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
 hevc_dxva2_hwaccel_select="hevc_decoder"
+hevc_nvdec_hwaccel_deps="cuda nvdec"
+hevc_nvdec_hwaccel_select="hevc_decoder"
 hevc_qsv_hwaccel_deps="libmfx"
 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
 hevc_vaapi_hwaccel_select="hevc_decoder"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index db1f70784a..7ac4e13a06 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -846,6 +846,7 @@ OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o
 OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL)  += videotoolbox.o
 OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)   += dxva2_hevc.o
 OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
+OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
 OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
 OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
 OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index c58f99c176..c817003693 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -79,6 +79,7 @@ static void register_all(void)
 REGISTER_HWACCEL(HEVC_D3D11VA,  hevc_d3d11va);
 REGISTER_HWACCEL(HEVC_D3D11VA2, hevc_d3d11va2);
 REGISTER_HWACCEL(HEVC_DXVA2,hevc_dxva2);
+REGISTER_HWACCEL(HEVC_NVDEC,hevc_nvdec);
 REGISTER_HWACCEL(HEVC_MEDIACODEC,   hevc_mediacodec);
 REGISTER_HWACCEL(HEVC_QSV,  hevc_qsv);
 REGISTER_HWACCEL(HEVC_VAAPI,hevc_vaapi);
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 403a8cf454..6dd6d0c53c 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -354,6 +354,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, const 
HEVCSPS *sps)
 {
 #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \
  CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \
+ CONFIG_HEVC_NVDEC_HWACCEL + \
  CONFIG_HEVC_VAAPI_HWACCEL + \
  CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \
  CONFIG_HEVC_VDPAU_HWACCEL)
@@ -375,6 +376,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const 
HEVCSPS *sps)
 #if CONFIG_HEVC_VDPAU_HWACCEL
 *fmt++ = AV_PIX_FMT_VDPAU;
 #endif
+#if CONFIG_HEVC_NVDEC_HWACCEL
+*fmt++ = AV_PIX_FMT_CUDA;
+#endif
 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
 *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX;
 #endif
@@ -393,6 +397,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const 
HEVCSPS *sps)
 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
 *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX;
 #endif
+#if CONFIG_HEVC_NVDEC_HWACCEL
+*fmt++ = AV_PIX_FMT_CUDA;
+#endif
 break;
 }
 
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 9ca9faa378..ab66b91a92 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -53,6 +53,7 @@ static int map_avcodec_id(enum AVCodecID id)
 {
 switch (id) {
 case AV_CODEC_ID_H264: return cudaVideoCodec_H264;
+case AV_CODEC_ID_HEVC: return cudaVideoCodec_HEVC;
 }
 return -1;
 }
diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c
new file mode 100644
index 00..3c40ab2bea
--- /dev/null
+++ b/libavcodec/nvdec_hevc.c
@@ -0,0 +1,279 @@
+/*
+ * HEVC HW decode acceleration through NVDEC
+ *
+ * Copyright (c) 2017 Anton Khirnov
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software 

[FFmpeg-cvslog] hevcdec: set the active SPS before calling get_format()

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Jul 24 
11:41:31 2017 +0200| [00fd914d4912322212e924c15f325cebf2fde8d3] | committer: 
Anton Khirnov

hevcdec: set the active SPS before calling get_format()

This way the SPS is available to the hwaccel init code.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=00fd914d4912322212e924c15f325cebf2fde8d3
---

 libavcodec/hevcdec.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index f6bbb7051e..664e4ac14b 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -490,13 +490,14 @@ static int hls_slice_header(HEVCContext *s)
 
 ff_hevc_clear_refs(s);
 
+ret = set_sps(s, sps, sps->pix_fmt);
+if (ret < 0)
+return ret;
+
 pix_fmt = get_format(s, sps);
 if (pix_fmt < 0)
 return pix_fmt;
-
-ret = set_sps(s, sps, pix_fmt);
-if (ret < 0)
-return ret;
+s->avctx->pix_fmt = pix_fmt;
 
 s->seq_decode = (s->seq_decode + 1) & 0xff;
 s->max_ra = INT_MAX;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Merge commit '00fd914d4912322212e924c15f325cebf2fde8d3'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Nov 10 20:31:55 
2017 -0300| [7762942045a05170de8bbe9d707c2344b445907f] | committer: James Almer

Merge commit '00fd914d4912322212e924c15f325cebf2fde8d3'

* commit '00fd914d4912322212e924c15f325cebf2fde8d3':
  hevcdec: set the active SPS before calling get_format()

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7762942045a05170de8bbe9d707c2344b445907f
---

 libavcodec/hevcdec.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 675025b211..403a8cf454 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -503,13 +503,14 @@ static int hls_slice_header(HEVCContext *s)
 }
 ff_hevc_clear_refs(s);
 
+ret = set_sps(s, sps, sps->pix_fmt);
+if (ret < 0)
+return ret;
+
 pix_fmt = get_format(s, sps);
 if (pix_fmt < 0)
 return pix_fmt;
-
-ret = set_sps(s, sps, pix_fmt);
-if (ret < 0)
-return ret;
+s->avctx->pix_fmt = pix_fmt;
 
 s->seq_decode = (s->seq_decode + 1) & 0xff;
 s->max_ra = INT_MAX;


==

diff --cc libavcodec/hevcdec.c
index 675025b211,664e4ac14b..403a8cf454
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@@ -492,17 -486,14 +492,21 @@@ static int hls_slice_header(HEVCContex
  
  if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) {
  const HEVCSPS *sps = 
(HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data;
 +const HEVCSPS *last_sps = s->ps.sps;
  enum AVPixelFormat pix_fmt;
  
 +if (last_sps && IS_IRAP(s) && s->nal_unit_type != HEVC_NAL_CRA_NUT) {
 +if (sps->width != last_sps->width || sps->height != 
last_sps->height ||
 +sps->temporal_layer[sps->max_sub_layers - 
1].max_dec_pic_buffering !=
 +last_sps->temporal_layer[last_sps->max_sub_layers - 
1].max_dec_pic_buffering)
 +sh->no_output_of_prior_pics_flag = 0;
 +}
  ff_hevc_clear_refs(s);
  
+ ret = set_sps(s, sps, sps->pix_fmt);
+ if (ret < 0)
+ return ret;
+ 
  pix_fmt = get_format(s, sps);
  if (pix_fmt < 0)
  return pix_fmt;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avconv: when using -loop option bail out if seek to start fails

2017-11-10 Thread Peter Große
ffmpeg | branch: master | Peter Große  | Fri Jun 30 17:28:53 
2017 +0200| [a58873b11198d04670b7f98f5a8a749d742db7c5] | committer: Anton 
Khirnov

avconv: when using -loop option bail out if seek to start fails

Fixes an infinite loop when a demuxer fails to seek to the start of the input.

Signed-off-by: Peter Große 
Signed-off-by: Anton Khirnov 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a58873b11198d04670b7f98f5a8a749d742db7c5
---

 avtools/avconv.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/avtools/avconv.c b/avtools/avconv.c
index 8dd11bb5fc..4e3ffecdef 100644
--- a/avtools/avconv.c
+++ b/avtools/avconv.c
@@ -2615,9 +2615,11 @@ static int process_input(void)
 return ret;
 }
 if (ret < 0 && ifile->loop) {
-if ((ret = seek_to_start(ifile, is)) < 0)
-return ret;
-ret = get_input_packet(ifile, );
+ret = seek_to_start(ifile, is);
+if(ret < 0)
+av_log(NULL, AV_LOG_WARNING, "Seek to start failed.\n");
+else
+ret = get_input_packet(ifile, );
 }
 if (ret < 0) {
 if (ret != AVERROR_EOF) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] hevcdec: add a CUVID hwaccel

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Feb 11 
16:49:34 2017 +0100| [b90fdb2c7199cc8b0e8d994fafba1fb4dc181d88] | committer: 
Anton Khirnov

hevcdec: add a CUVID hwaccel

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b90fdb2c7199cc8b0e8d994fafba1fb4dc181d88
---

 Changelog   |   2 +-
 configure   |   3 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/cuvid.c  |   1 +
 libavcodec/cuvid_hevc.c | 280 
 libavcodec/hevcdec.c|   9 +-
 7 files changed, 295 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 711506624f..92a72490a9 100644
--- a/Changelog
+++ b/Changelog
@@ -18,7 +18,7 @@ version :
 - support for decoding through D3D11VA in avconv
 - Cinepak encoder
 - Intel QSV-accelerated MJPEG encoding
-- NVIDIA CUVID-accelerated H.264 decoding
+- NVIDIA CUVID-accelerated H.264 and HEVC decoding
 
 
 version 12:
diff --git a/configure b/configure
index 7a7fbb2906..4510100f38 100755
--- a/configure
+++ b/configure
@@ -2210,6 +2210,8 @@ h264_vda_old_hwaccel_deps="vda"
 h264_vda_old_hwaccel_select="h264_decoder"
 h264_vdpau_hwaccel_deps="vdpau"
 h264_vdpau_hwaccel_select="h264_decoder"
+hevc_cuvid_hwaccel_deps="cuvid CUVIDHEVCPICPARAMS"
+hevc_cuvid_hwaccel_select="hevc_decoder"
 hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
 hevc_d3d11va_hwaccel_select="hevc_decoder"
 hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
@@ -4700,6 +4702,7 @@ check_lib psapi"windows.h psapi.h"
GetProcessMemoryInfo -lpsapi
 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
 
 check_type "cuviddec.h" "CUVIDH264PICPARAMS"
+check_type "cuviddec.h" "CUVIDHEVCPICPARAMS"
 check_struct "cuviddec.h" "CUVIDDECODECREATEINFO" bitDepthMinus8
 
 check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" 
-DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index eba651fc24..bb568ddbe4 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -641,6 +641,7 @@ OBJS-$(CONFIG_H264_QSV_HWACCEL)   += qsvdec_h2645.o
 OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
 OBJS-$(CONFIG_H264_VDA_HWACCEL)   += vda_h264.o
 OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o
+OBJS-$(CONFIG_HEVC_CUVID_HWACCEL) += cuvid_hevc.o
 OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)   += dxva2_hevc.o
 OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
 OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ea3a6b9702..4ece4307a0 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -78,6 +78,7 @@ void avcodec_register_all(void)
 REGISTER_HWACCEL(H264_VDA,  h264_vda);
 REGISTER_HWACCEL(H264_VDA_OLD,  h264_vda_old);
 REGISTER_HWACCEL(H264_VDPAU,h264_vdpau);
+REGISTER_HWACCEL(HEVC_CUVID,hevc_cuvid);
 REGISTER_HWACCEL(HEVC_D3D11VA,  hevc_d3d11va);
 REGISTER_HWACCEL(HEVC_D3D11VA2, hevc_d3d11va2);
 REGISTER_HWACCEL(HEVC_DXVA2,hevc_dxva2);
diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index 69f624c373..2d35e92a61 100644
--- a/libavcodec/cuvid.c
+++ b/libavcodec/cuvid.c
@@ -53,6 +53,7 @@ static int map_avcodec_id(enum AVCodecID id)
 {
 switch (id) {
 case AV_CODEC_ID_H264: return cudaVideoCodec_H264;
+case AV_CODEC_ID_HEVC: return cudaVideoCodec_HEVC;
 }
 return -1;
 }
diff --git a/libavcodec/cuvid_hevc.c b/libavcodec/cuvid_hevc.c
new file mode 100644
index 00..5de9bca483
--- /dev/null
+++ b/libavcodec/cuvid_hevc.c
@@ -0,0 +1,280 @@
+/*
+ * HEVC HW decode acceleration through CUVID
+ *
+ * Copyright (c) 2017 Anton Khirnov
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#include "avcodec.h"
+#include "cuvid.h"
+#include "decode.h"
+#include "internal.h"
+#include "hevcdec.h"
+#include "hevc_data.h"
+
+static void dpb_add(CUVIDHEVCPICPARAMS *pp, int idx, const HEVCFrame *src)
+{
+FrameDecodeData *fdd = (FrameDecodeData*)src->frame->opaque_ref->data;
+const CUVIDFrame *cf = fdd->hwaccel_priv;
+
+pp->RefPicIdx[idx]  = 

[FFmpeg-cvslog] cuvid: add cuvid.h to SKIPHEADERS

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Jul 27 
12:42:03 2017 +0200| [004ea63714e31ed43326ad00d7420d104f0dab38] | committer: 
Anton Khirnov

cuvid: add cuvid.h to SKIPHEADERS

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=004ea63714e31ed43326ad00d7420d104f0dab38
---

 libavcodec/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ac13166891..eba651fc24 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -797,6 +797,7 @@ SKIPHEADERS+= %_tablegen.h  
\
   tableprint.h  \
   $(ARCH)/vp56_arith.h  \
 
+SKIPHEADERS-$(CONFIG_CUVID)+= cuvid.h
 SKIPHEADERS-$(CONFIG_D3D11VA)  += d3d11va.h dxva2_internal.h
 SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h
 SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER)  += libschroedinger.h

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] h264dec: add a CUVID hwaccel

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Feb 11 
16:49:34 2017 +0100| [b9129ec4668c511e0a79e25c6f25d748cee172c9] | committer: 
Anton Khirnov

h264dec: add a CUVID hwaccel

Some parts of the code are based on a patch by
Timo Rothenpieler 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b9129ec4668c511e0a79e25c6f25d748cee172c9
---

 Changelog   |   1 +
 avtools/avconv.h|   1 +
 avtools/avconv_opt.c|   4 +
 configure   |  11 +-
 libavcodec/Makefile |   2 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/cuvid.c  | 425 
 libavcodec/cuvid.h  |  61 +++
 libavcodec/cuvid_h264.c | 177 
 libavcodec/h264_slice.c |   6 +-
 10 files changed, 687 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 82e3e3a0ef..711506624f 100644
--- a/Changelog
+++ b/Changelog
@@ -18,6 +18,7 @@ version :
 - support for decoding through D3D11VA in avconv
 - Cinepak encoder
 - Intel QSV-accelerated MJPEG encoding
+- NVIDIA CUVID-accelerated H.264 decoding
 
 
 version 12:
diff --git a/avtools/avconv.h b/avtools/avconv.h
index 4c699333a5..b5843fbc03 100644
--- a/avtools/avconv.h
+++ b/avtools/avconv.h
@@ -58,6 +58,7 @@ enum HWAccelID {
 HWACCEL_QSV,
 HWACCEL_VAAPI,
 HWACCEL_D3D11VA,
+HWACCEL_CUVID,
 };
 
 typedef struct HWAccel {
diff --git a/avtools/avconv_opt.c b/avtools/avconv_opt.c
index 575ce120dd..df693360a7 100644
--- a/avtools/avconv_opt.c
+++ b/avtools/avconv_opt.c
@@ -80,6 +80,10 @@ const HWAccel hwaccels[] = {
 { "vaapi", hwaccel_decode_init, HWACCEL_VAAPI, AV_PIX_FMT_VAAPI,
   AV_HWDEVICE_TYPE_VAAPI },
 #endif
+#if CONFIG_CUVID
+{ "cuvid", hwaccel_decode_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA,
+   AV_HWDEVICE_TYPE_CUDA },
+#endif
 { 0 },
 };
 int hwaccel_lax_profile_check = 0;
diff --git a/configure b/configure
index 35ae03182a..7a7fbb2906 100755
--- a/configure
+++ b/configure
@@ -237,6 +237,7 @@ External library support:
 
   The following libraries provide various hardware acceleration features:
   --enable-cudaNvidia CUDA (dynamically linked)
+  --enable-cuvid   Nvidia CUVID video decode acceleration
   --enable-d3d11va Microsoft Direct3D 11 video acceleration [auto]
   --enable-dxva2   Microsoft DirectX 9 video acceleration [auto]
   --enable-libmfx  Intel MediaSDK (AKA Quick Sync Video)
@@ -1266,6 +1267,7 @@ EXTRALIBS_LIST="
 
 HWACCEL_LIBRARY_NONFREE_LIST="
 cuda
+cuvid
 libnpp
 "
 HWACCEL_LIBRARY_LIST="
@@ -1686,6 +1688,7 @@ TOOLCHAIN_FEATURES="
 
 TYPES_LIST="
 CONDITION_VARIABLE_Ptr
+CUVIDDECODECREATEINFO_bitDepthMinus8
 socklen_t
 struct_addrinfo
 struct_group_source_req
@@ -2189,6 +2192,8 @@ vda_extralibs="-framework CoreFoundation -framework 
VideoDecodeAcceleration -fra
 
 h263_vaapi_hwaccel_deps="vaapi"
 h263_vaapi_hwaccel_select="h263_decoder"
+h264_cuvid_hwaccel_deps="cuvid CUVIDH264PICPARAMS"
+h264_cuvid_hwaccel_select="h264_decoder"
 h264_d3d11va_hwaccel_deps="d3d11va"
 h264_d3d11va_hwaccel_select="h264_decoder"
 h264_d3d11va2_hwaccel_deps="d3d11va"
@@ -2556,7 +2561,7 @@ avdevice_extralibs="libm_extralibs"
 avformat_extralibs="libm_extralibs"
 avfilter_extralibs="pthreads_extralibs libm_extralibs"
 avresample_extralibs="libm_extralibs"
-avutil_extralibs="clock_gettime_extralibs cuda_extralibs libm_extralibs 
libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs 
vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs 
wincrypt_extralibs"
+avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs 
libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs 
user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs 
vdpau_x11_extralibs wincrypt_extralibs"
 swscale_extralibs="libm_extralibs"
 
 # programs
@@ -4694,6 +4699,9 @@ check_lib psapi"windows.h psapi.h"
GetProcessMemoryInfo -lpsapi
 
 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
 
+check_type "cuviddec.h" "CUVIDH264PICPARAMS"
+check_struct "cuviddec.h" "CUVIDDECODECREATEINFO" bitDepthMinus8
+
 check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" 
-DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
 check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
@@ -4753,6 +4761,7 @@ done
 enabled avisynth  && require_header avisynth/avisynth_c.h
 enabled avxsynth  && require_header avxsynth/avxsynth_c.h
 enabled cuda  && require cuda cuda.h cuInit -lcuda
+enabled cuvid && require cuvid cuviddec.h cuvidCreateDecoder 
-lnvcuvid
 enabled frei0r&& require_header frei0r.h
 enabled gnutls&& require_pkg_config gnutls gnutls gnutls/gnutls.h 
gnutls_global_init
 enabled libbs2b   && require_pkg_config libbs2b libbs2b bs2b.h 
bs2b_open
diff 

[FFmpeg-cvslog] Merge commit 'b9129ec4668c511e0a79e25c6f25d748cee172c9'

2017-11-10 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Nov 10 19:43:46 
2017 -0300| [ae644cee1f421af1abe36e16c07dae3ac4c406ba] | committer: James Almer

Merge commit 'b9129ec4668c511e0a79e25c6f25d748cee172c9'

* commit 'b9129ec4668c511e0a79e25c6f25d748cee172c9':
  h264dec: add a CUVID hwaccel
  decode: add a per-frame private data for hwaccel use
  decode: add a mechanism for performing delayed processing on the decoded 
frames
  decode: add a method for attaching lavc-internal data to frames
  decode: avoid leaks on failure in ff_get_buffer()

This commit is a noop, see
4776c61424fa32394e251e9769e1ad2c2fa55598
9f1cfd88af88a7d7d5c56a368a46639dfdfdef75
7fa64514c8d2ec4d3dcb5f194511609ddcc288e6
81c021c6a2d7848c31984d65f225ba54bdd6f560
0e00624389955bc559d75855d5c4876266d9575f

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae644cee1f421af1abe36e16c07dae3ac4c406ba
---



___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] decode: add a per-frame private data for hwaccel use

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jul  1 
12:09:58 2017 +0200| [704311b2946d74a80f65906961cd9baaa18683a3] | committer: 
Anton Khirnov

decode: add a per-frame private data for hwaccel use

This will be useful in the CUVID hwaccel. It should also eventually
replace current decoder-specific mechanisms used by various other
hwaccels.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=704311b2946d74a80f65906961cd9baaa18683a3
---

 libavcodec/decode.c | 3 +++
 libavcodec/decode.h | 6 ++
 2 files changed, 9 insertions(+)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 9050b57b0b..c76ee6696a 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1025,6 +1025,9 @@ static void decode_data_free(void *opaque, uint8_t *data)
 if (fdd->post_process_opaque_free)
 fdd->post_process_opaque_free(fdd->post_process_opaque);
 
+if (fdd->hwaccel_priv_free)
+fdd->hwaccel_priv_free(fdd->hwaccel_priv);
+
 av_freep();
 }
 
diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index 72052f1de5..235f355f82 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -49,6 +49,12 @@ typedef struct FrameDecodeData {
 int (*post_process)(void *logctx, AVFrame *frame);
 void *post_process_opaque;
 void (*post_process_opaque_free)(void *opaque);
+
+/**
+ * Per-frame private data for hwaccels.
+ */
+void *hwaccel_priv;
+void (*hwaccel_priv_free)(void *priv);
 } FrameDecodeData;
 
 /**

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] decode: add a mechanism for performing delayed processing on the decoded frames

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jul  1 
12:09:58 2017 +0200| [badf0951f54c1332e77455dc40398f3512540c1b] | committer: 
Anton Khirnov

decode: add a mechanism for performing delayed processing on the decoded frames

This will be useful in the CUVID hwaccel.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=badf0951f54c1332e77455dc40398f3512540c1b
---

 libavcodec/decode.c | 11 +++
 libavcodec/decode.h | 15 +++
 2 files changed, 26 insertions(+)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index bcc119c829..9050b57b0b 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -419,6 +419,14 @@ static int decode_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 
 fdd = (FrameDecodeData*)frame->opaque_ref->data;
 
+if (fdd->post_process) {
+ret = fdd->post_process(avctx, frame);
+if (ret < 0) {
+av_frame_unref(frame);
+return ret;
+}
+}
+
 user_opaque_ref = fdd->user_opaque_ref;
 fdd->user_opaque_ref = NULL;
 av_buffer_unref(>opaque_ref);
@@ -1014,6 +1022,9 @@ static void decode_data_free(void *opaque, uint8_t *data)
 
 av_buffer_unref(>user_opaque_ref);
 
+if (fdd->post_process_opaque_free)
+fdd->post_process_opaque_free(fdd->post_process_opaque);
+
 av_freep();
 }
 
diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index 61b53b2445..72052f1de5 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -22,6 +22,7 @@
 #define AVCODEC_DECODE_H
 
 #include "libavutil/buffer.h"
+#include "libavutil/frame.h"
 
 #include "avcodec.h"
 
@@ -34,6 +35,20 @@ typedef struct FrameDecodeData {
  * The original user-set opaque_ref.
  */
 AVBufferRef *user_opaque_ref;
+
+/**
+ * The callback to perform some delayed processing on the frame right
+ * before it is returned to the caller.
+ *
+ * @note This code is called at some unspecified point after the frame is
+ * returned from the decoder's decode/receive_frame call. Therefore it 
cannot rely
+ * on AVCodecContext being in any specific state, so it does not get to
+ * access AVCodecContext directly at all. All the state it needs must be
+ * stored in the post_process_opaque object.
+ */
+int (*post_process)(void *logctx, AVFrame *frame);
+void *post_process_opaque;
+void (*post_process_opaque_free)(void *opaque);
 } FrameDecodeData;
 
 /**

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] decode: avoid leaks on failure in ff_get_buffer()

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jul  1 
11:32:56 2017 +0200| [de77671438c24ffea93398c8dc885d4dd04477de] | committer: 
Anton Khirnov

decode: avoid leaks on failure in ff_get_buffer()

If the get_buffer() call fails, the frame might have some side data
already set. Make sure it gets freed.

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

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de77671438c24ffea93398c8dc885d4dd04477de
---

 libavcodec/decode.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 9644e89f48..f7cd7f6870 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1069,6 +1069,9 @@ end:
 frame->height = avctx->height;
 }
 
+if (ret < 0)
+av_frame_unref(frame);
+
 return ret;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] decode: add a method for attaching lavc-internal data to frames

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jul  1 
11:12:44 2017 +0200| [359a8a3e2d1194b52b6c386f94fd0929567dfb67] | committer: 
Anton Khirnov

decode: add a method for attaching lavc-internal data to frames

Use the AVFrame.opaque_ref field. The original user's opaque_ref is
wrapped in the lavc struct and then unwrapped before the frame is
returned to the caller.

This new struct will be useful in the following commits.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=359a8a3e2d1194b52b6c386f94fd0929567dfb67
---

 libavcodec/decode.c | 57 +
 libavcodec/decode.h | 13 
 2 files changed, 70 insertions(+)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index f7cd7f6870..bcc119c829 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -406,6 +406,26 @@ static int decode_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 if (ret == AVERROR_EOF)
 avci->draining_done = 1;
 
+/* unwrap the per-frame decode data and restore the original opaque_ref*/
+if (!ret) {
+/* the only case where decode data is not set should be decoders
+ * that do not call ff_get_buffer() */
+av_assert0((frame->opaque_ref && frame->opaque_ref->size == 
sizeof(FrameDecodeData)) ||
+   !(avctx->codec->capabilities & AV_CODEC_CAP_DR1));
+
+if (frame->opaque_ref) {
+FrameDecodeData *fdd;
+AVBufferRef *user_opaque_ref;
+
+fdd = (FrameDecodeData*)frame->opaque_ref->data;
+
+user_opaque_ref = fdd->user_opaque_ref;
+fdd->user_opaque_ref = NULL;
+av_buffer_unref(>opaque_ref);
+frame->opaque_ref = user_opaque_ref;
+}
+}
+
 return ret;
 }
 
@@ -988,6 +1008,37 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return 0;
 }
 
+static void decode_data_free(void *opaque, uint8_t *data)
+{
+FrameDecodeData *fdd = (FrameDecodeData*)data;
+
+av_buffer_unref(>user_opaque_ref);
+
+av_freep();
+}
+
+static int attach_decode_data(AVFrame *frame)
+{
+AVBufferRef *fdd_buf;
+FrameDecodeData *fdd;
+
+fdd = av_mallocz(sizeof(*fdd));
+if (!fdd)
+return AVERROR(ENOMEM);
+
+fdd_buf = av_buffer_create((uint8_t*)fdd, sizeof(*fdd), decode_data_free,
+   NULL, AV_BUFFER_FLAG_READONLY);
+if (!fdd_buf) {
+av_freep();
+return AVERROR(ENOMEM);
+}
+
+fdd->user_opaque_ref = frame->opaque_ref;
+frame->opaque_ref= fdd_buf;
+
+return 0;
+}
+
 int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
 {
 const AVHWAccel *hwaccel = avctx->hwaccel;
@@ -1061,6 +1112,12 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, 
int flags)
 avctx->sw_pix_fmt = avctx->pix_fmt;
 
 ret = avctx->get_buffer2(avctx, frame, flags);
+if (ret < 0)
+goto end;
+
+ret = attach_decode_data(frame);
+if (ret < 0)
+goto end;
 
 end:
 if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions &&
diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index 2f29cf6107..61b53b2445 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -21,9 +21,22 @@
 #ifndef AVCODEC_DECODE_H
 #define AVCODEC_DECODE_H
 
+#include "libavutil/buffer.h"
+
 #include "avcodec.h"
 
 /**
+ * This struct stores per-frame lavc-internal data and is attached to it via
+ * opaque_ref.
+ */
+typedef struct FrameDecodeData {
+/**
+ * The original user-set opaque_ref.
+ */
+AVBufferRef *user_opaque_ref;
+} FrameDecodeData;
+
+/**
  * Called by decoders to get the next packet for decoding.
  *
  * @param pkt An empty packet to be filled with data.

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/decode: add missing \n to log message

2017-11-10 Thread wm4
ffmpeg | branch: master | wm4  | Tue Oct  3 17:43:13 
2017 +0200| [0aecc08e5fd15960639a75c43265539e70d0189e] | committer: Timo 
Rothenpieler

avcodec/decode: add missing \n to log message

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0aecc08e5fd15960639a75c43265539e70d0189e
---

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

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 9fdc7bb565..570799f6d7 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1115,7 +1115,7 @@ static int setup_hwaccel(AVCodecContext *avctx,
 
 if (!hwa) {
 av_log(avctx, AV_LOG_ERROR,
-   "Could not find an AVHWAccel for the pixel format: %s",
+   "Could not find an AVHWAccel for the pixel format: %s\n",
name);
 return AVERROR(ENOENT);
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/cuvid: rename cuvid.c to cuviddec.c

2017-11-10 Thread wm4
ffmpeg | branch: master | wm4  | Tue Oct  3 15:15:16 
2017 +0200| [5593049466bcd1d3f1ddbfe580be4f36123d7c3d] | committer: Timo 
Rothenpieler

avcodec/cuvid: rename cuvid.c to cuviddec.c

cuvid.c is used by Libav's CUVID hwaccel. Resolve the conflict and
avoid future merge problems by renaming our decoder.

Signed-off-by: Timo Rothenpieler 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5593049466bcd1d3f1ddbfe580be4f36123d7c3d
---

 libavcodec/Makefile| 10 +-
 libavcodec/{cuvid.c => cuviddec.c} |  0
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 95c843dee7..3704316d8c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -338,7 +338,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264dec.o 
h264_cabac.o h264_cavlc.o \
   h264_mb.o h264_picture.o \
   h264_refs.o h264_sei.o \
   h264_slice.o h264data.o
-OBJS-$(CONFIG_H264_CUVID_DECODER)  += cuvid.o
+OBJS-$(CONFIG_H264_CUVID_DECODER)  += cuviddec.o
 OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec.o
 OBJS-$(CONFIG_H264_MMAL_DECODER)   += mmaldec.o
 OBJS-$(CONFIG_H264_NVENC_ENCODER)  += nvenc_h264.o
@@ -357,7 +357,7 @@ OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o hap.o
 OBJS-$(CONFIG_HEVC_DECODER)+= hevcdec.o hevc_mvs.o \
   hevc_cabac.o hevc_refs.o hevcpred.o  
  \
   hevcdsp.o hevc_filter.o hevc_data.o
-OBJS-$(CONFIG_HEVC_CUVID_DECODER)  += cuvid.o
+OBJS-$(CONFIG_HEVC_CUVID_DECODER)  += cuviddec.o
 OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o
 OBJS-$(CONFIG_HEVC_NVENC_ENCODER)  += nvenc_hevc.o
 OBJS-$(CONFIG_NVENC_HEVC_ENCODER)  += nvenc_hevc.o
@@ -624,7 +624,7 @@ OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o 
vc1_block.o vc1_loopfilter.o
   vc1_mc.o vc1_pred.o vc1.o vc1data.o \
   msmpeg4dec.o msmpeg4.o msmpeg4data.o 
\
   wmv2dsp.o wmv2data.o
-OBJS-$(CONFIG_VC1_CUVID_DECODER)   += cuvid.o
+OBJS-$(CONFIG_VC1_CUVID_DECODER)   += cuviddec.o
 OBJS-$(CONFIG_VC1_MMAL_DECODER)+= mmaldec.o
 OBJS-$(CONFIG_VC1_QSV_DECODER) += qsvdec_other.o
 OBJS-$(CONFIG_VC1_V4L2M2M_DECODER) += v4l2_m2m_dec.o
@@ -643,7 +643,7 @@ OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o 
vp56data.o \
   vp6dsp.o vp56rac.o
 OBJS-$(CONFIG_VP7_DECODER) += vp8.o vp56rac.o
 OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp56rac.o
-OBJS-$(CONFIG_VP8_CUVID_DECODER)   += cuvid.o
+OBJS-$(CONFIG_VP8_CUVID_DECODER)   += cuviddec.o
 OBJS-$(CONFIG_VP8_MEDIACODEC_DECODER)  += mediacodecdec.o
 OBJS-$(CONFIG_VP8_QSV_DECODER) += qsvdec_other.o
 OBJS-$(CONFIG_VP8_RKMPP_DECODER)   += rkmppdec.o
@@ -653,7 +653,7 @@ OBJS-$(CONFIG_VP8_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
 OBJS-$(CONFIG_VP9_DECODER) += vp9.o vp9data.o vp9dsp.o vp9lpf.o 
vp9recon.o \
   vp9block.o vp9prob.o vp9mvs.o 
vp56rac.o \
   vp9dsp_8bpp.o vp9dsp_10bpp.o 
vp9dsp_12bpp.o
-OBJS-$(CONFIG_VP9_CUVID_DECODER)   += cuvid.o
+OBJS-$(CONFIG_VP9_CUVID_DECODER)   += cuviddec.o
 OBJS-$(CONFIG_VP9_MEDIACODEC_DECODER)  += mediacodecdec.o
 OBJS-$(CONFIG_VP9_RKMPP_DECODER)   += rkmppdec.o
 OBJS-$(CONFIG_VP9_VAAPI_ENCODER)   += vaapi_encode_vp9.o
diff --git a/libavcodec/cuvid.c b/libavcodec/cuviddec.c
similarity index 100%
rename from libavcodec/cuvid.c
rename to libavcodec/cuviddec.c

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] h264dec: add a NVDEC hwaccel

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Feb 11 
16:49:34 2017 +0100| [0e00624389955bc559d75855d5c4876266d9575f] | committer: 
Timo Rothenpieler

h264dec: add a NVDEC hwaccel

Some parts of the code are based on a patch by
Timo Rothenpieler 

Merges Libav commit b9129ec4668c511e0a79e25c6f25d748cee172c9.

Due to the name clash with our cuvid decoder, rename it to nvdec.

This commit also changes the Libav code to dynamic loading of the
cuda/cuvid libraries.

Signed-off-by: Timo Rothenpieler 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0e00624389955bc559d75855d5c4876266d9575f
---

 Changelog   |   1 +
 configure   |  10 +-
 fftools/ffmpeg.h|   1 +
 fftools/ffmpeg_opt.c|   4 +
 libavcodec/Makefile |   2 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/h264_slice.c |   4 +
 libavcodec/nvdec.c  | 431 
 libavcodec/nvdec.h  |  62 +++
 libavcodec/nvdec_h264.c | 176 
 libavcodec/version.h|   2 +-
 11 files changed, 691 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 3914672831..ba2951db25 100644
--- a/Changelog
+++ b/Changelog
@@ -13,6 +13,7 @@ version :
 - PCE support for extended channel layouts in the AAC encoder
 - native aptX encoder and decoder
 - Raw aptX muxer and demuxer
+- NVIDIA NVDEC-accelerated H.264 hwaccel decoding
 
 
 version 3.4:
diff --git a/configure b/configure
index f087ba61b1..1b90d8e9a1 100755
--- a/configure
+++ b/configure
@@ -313,6 +313,7 @@ External library support:
   --enable-libmfx  enable Intel MediaSDK (AKA Quick Sync Video) code 
via libmfx [no]
   --enable-libnpp  enable Nvidia Performance Primitives-based code [no]
   --enable-mmalenable Broadcom Multi-Media Abstraction Layer 
(Raspberry Pi) via MMAL [no]
+  --disable-nvdec  disable Nvidia video decoding acceleration (via 
hwaccel) [autodetect]
   --disable-nvenc  disable Nvidia video encoding code [autodetect]
   --enable-omx enable OpenMAX IL code [no]
   --enable-omx-rpi enable OpenMAX IL code for Raspberry Pi [no]
@@ -1647,6 +1648,7 @@ HWACCEL_AUTODETECT_LIBRARY_LIST="
 cuvid
 d3d11va
 dxva2
+nvdec
 nvenc
 vaapi
 vdpau
@@ -2672,6 +2674,8 @@ h264_dxva2_hwaccel_deps="dxva2"
 h264_dxva2_hwaccel_select="h264_decoder"
 h264_mediacodec_hwaccel_deps="mediacodec"
 h264_mmal_hwaccel_deps="mmal"
+h264_nvdec_hwaccel_deps="cuda nvdec"
+h264_nvdec_hwaccel_select="h264_decoder"
 h264_qsv_hwaccel_deps="libmfx"
 h264_vaapi_hwaccel_deps="vaapi"
 h264_vaapi_hwaccel_select="h264_decoder"
@@ -5940,6 +5944,8 @@ done
 enabled cuda_sdk  && require cuda_sdk cuda.h cuCtxCreate -lcuda
 enabled cuvid && { enabled cuda ||
die "ERROR: CUVID requires CUDA"; }
+enabled nvdec && { enabled cuda ||
+   die "ERROR: NVDEC hwaccel requires CUDA"; }
 enabled chromaprint   && require chromaprint chromaprint.h 
chromaprint_get_version -lchromaprint
 enabled decklink  && { require_header DeckLinkAPI.h &&
{ check_cpp_condition DeckLinkAPIVersion.h 
"BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a060100" || die "ERROR: Decklink API 
version must be >= 10.6.1."; } }
@@ -6295,11 +6301,11 @@ if enabled x86; then
 mingw32*|mingw64*|win32|win64|linux|cygwin*)
 ;;
 *)
-disable cuda cuvid nvenc
+disable cuda cuvid nvdec nvenc
 ;;
 esac
 else
-disable cuda cuvid nvenc
+disable cuda cuvid nvdec nvenc
 fi
 
 enabled nvenc &&
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 50fc8d5767..e0977e1bf1 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -68,6 +68,7 @@ enum HWAccelID {
 HWACCEL_VAAPI,
 HWACCEL_CUVID,
 HWACCEL_D3D11VA,
+HWACCEL_NVDEC,
 };
 
 typedef struct HWAccel {
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index ca6f10d5ca..e50895e64c 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -90,6 +90,10 @@ const HWAccel hwaccels[] = {
 { "vaapi", hwaccel_decode_init, HWACCEL_VAAPI, AV_PIX_FMT_VAAPI,
   AV_HWDEVICE_TYPE_VAAPI },
 #endif
+#if CONFIG_NVDEC
+{ "nvdec", hwaccel_decode_init, HWACCEL_NVDEC, AV_PIX_FMT_CUDA,
+   AV_HWDEVICE_TYPE_CUDA },
+#endif
 #if CONFIG_CUVID
 { "cuvid", cuvid_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA,
   AV_HWDEVICE_TYPE_NONE },
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3704316d8c..db1f70784a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -830,6 +830,7 @@ OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER)   += adpcmenc.o 
adpcm_data.o
 # hardware accelerators
 OBJS-$(CONFIG_D3D11VA)+= dxva2.o
 OBJS-$(CONFIG_DXVA2)  += dxva2.o
+OBJS-$(CONFIG_NVDEC)  += nvdec.o
 

[FFmpeg-cvslog] avcodec: allow multiple hwaccels for the same codec/pixfmt

2017-11-10 Thread wm4
ffmpeg | branch: master | wm4  | Tue Oct  3 15:04:45 
2017 +0200| [ae5046e492cd87233111e994ca4ae3d74a233b51] | committer: Timo 
Rothenpieler

avcodec: allow multiple hwaccels for the same codec/pixfmt

Currently, AVHWAccels are looked up using a (codec_id, pixfmt) tuple.
This means it's impossible to have 2 decoders for the same codec and
using the same opaque hardware pixel format.

This breaks merging Libav's CUVID hwaccel. FFmpeg has its own CUVID
support, but it's a full stream decoder, using NVIDIA's codec parser.
The Libav one is a true hwaccel, which is based on the builtin software
decoders.

Fix this by introducing another field to disambiguate AVHWAccels, and
use it for our CUVID decoders. FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS makes
this mechanism backwards compatible and optional.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae5046e492cd87233111e994ca4ae3d74a233b51
---

 libavcodec/avcodec.h  |  7 +++
 libavcodec/cuviddec.c |  2 ++
 libavcodec/decode.c   | 12 
 libavcodec/internal.h |  5 +
 4 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 429d62a60a..15ca871b59 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3532,6 +3532,13 @@ typedef struct AVHWAccel {
  * Internal hwaccel capabilities.
  */
 int caps_internal;
+
+/**
+ * Some hwaccels are ambiguous if only the id and pix_fmt fields are used.
+ * If non-NULL, the associated AVCodec must have
+ * FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS set.
+ */
+const AVClass *decoder_class;
 } AVHWAccel;
 
 /**
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 2ba8e00c6a..6370348639 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -1106,6 +1106,7 @@ static const AVOption options[] = {
 .type   = AVMEDIA_TYPE_VIDEO, \
 .id = AV_CODEC_ID_##X, \
 .pix_fmt= AV_PIX_FMT_CUDA, \
+.decoder_class  = ##_cuvid_class, \
 }; \
 AVCodec ff_##x##_cuvid_decoder = { \
 .name   = #x "_cuvid", \
@@ -1120,6 +1121,7 @@ static const AVOption options[] = {
 .receive_frame  = cuvid_output_frame, \
 .flush  = cuvid_flush, \
 .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
+.caps_internal  = FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS, \
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, \
 AV_PIX_FMT_NV12, \
 AV_PIX_FMT_P010, \
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 44b874d4f8..9fdc7bb565 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1090,15 +1090,19 @@ enum AVPixelFormat avcodec_default_get_format(struct 
AVCodecContext *s, const en
 return fmt[0];
 }
 
-static AVHWAccel *find_hwaccel(enum AVCodecID codec_id,
+static AVHWAccel *find_hwaccel(AVCodecContext *avctx,
enum AVPixelFormat pix_fmt)
 {
 AVHWAccel *hwaccel = NULL;
+const AVClass *av_class =
+(avctx->codec->caps_internal & FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS)
+? avctx->codec->priv_class : NULL;
 
-while ((hwaccel = av_hwaccel_next(hwaccel)))
-if (hwaccel->id == codec_id
+while ((hwaccel = av_hwaccel_next(hwaccel))) {
+if (hwaccel->decoder_class == av_class && hwaccel->id == 
avctx->codec_id
 && hwaccel->pix_fmt == pix_fmt)
 return hwaccel;
+}
 return NULL;
 }
 
@@ -1106,7 +1110,7 @@ static int setup_hwaccel(AVCodecContext *avctx,
  const enum AVPixelFormat fmt,
  const char *name)
 {
-AVHWAccel *hwa = find_hwaccel(avctx->codec_id, fmt);
+AVHWAccel *hwa = find_hwaccel(avctx, fmt);
 int ret= 0;
 
 if (!hwa) {
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 7748f09f54..948d5461c1 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -69,6 +69,11 @@
  */
 #define FF_CODEC_CAP_SLICE_THREAD_HAS_MF(1 << 5)
 
+/**
+ * Allow only AVHWAccels which have a matching decoder_class field.
+ */
+#define FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS  (1 << 6)
+
 #ifdef TRACE
 #   define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__)
 #else

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] aptx: add raw muxer and demuxer for aptX

2017-11-10 Thread Aurelien Jacobs
ffmpeg | branch: master | Aurelien Jacobs  | Fri Nov 10 
22:09:24 2017 +0100| [018eef1a1bb6f791201e9b9f38a317a2059c3af1] | committer: 
Rostislav Pehlivanov

aptx: add raw muxer and demuxer for aptX

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=018eef1a1bb6f791201e9b9f38a317a2059c3af1
---

 doc/general.texi |  1 +
 libavformat/Makefile |  2 ++
 libavformat/allformats.c |  1 +
 libavformat/aptxdec.c| 78 
 libavformat/rawenc.c | 13 
 libavformat/utils.c  |  1 +
 6 files changed, 96 insertions(+)

diff --git a/doc/general.texi b/doc/general.texi
index de4efee913..efd4a92495 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -441,6 +441,7 @@ library:
 @item raw AC-3  @tab X @tab X
 @item raw AMR-NB@tab   @tab X
 @item raw AMR-WB@tab   @tab X
+@item raw aptX  @tab X @tab X
 @item raw Chinese AVS video @tab X @tab X
 @item raw CRI ADX   @tab X @tab X
 @item raw Dirac @tab X @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 146a4656f2..b1e7b193f4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -94,6 +94,8 @@ OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
 OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
 OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
 OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
+OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
+OBJS-$(CONFIG_APTX_MUXER)+= rawenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
 avlanguage.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1896d50e9e..9213af9301 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -69,6 +69,7 @@ static void register_all(void)
 REGISTER_DEMUXER (APC,  apc);
 REGISTER_DEMUXER (APE,  ape);
 REGISTER_MUXDEMUX(APNG, apng);
+REGISTER_MUXDEMUX(APTX, aptx);
 REGISTER_DEMUXER (AQTITLE,  aqtitle);
 REGISTER_MUXDEMUX(ASF,  asf);
 REGISTER_DEMUXER (ASF_O,asf_o);
diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c
new file mode 100644
index 00..3b8fae1b55
--- /dev/null
+++ b/libavformat/aptxdec.c
@@ -0,0 +1,78 @@
+/*
+ * RAW aptX demuxer
+ *
+ * Copyright (C) 2017  Aurelien Jacobs 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "rawdec.h"
+
+#define APTX_BLOCK_SIZE   4
+#define APTX_PACKET_SIZE  (256*APTX_BLOCK_SIZE)
+
+typedef struct AptXDemuxerContext {
+AVClass *class;
+int sample_rate;
+} AptXDemuxerContext;
+
+static int aptx_read_header(AVFormatContext *s)
+{
+AptXDemuxerContext *s1 = s->priv_data;
+AVStream *st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id = AV_CODEC_ID_APTX;
+st->codecpar->format = AV_SAMPLE_FMT_S32P;
+st->codecpar->channels = 2;
+st->codecpar->sample_rate = s1->sample_rate;
+st->codecpar->bits_per_coded_sample = 4;
+st->codecpar->block_align = APTX_BLOCK_SIZE;
+st->codecpar->frame_size = APTX_PACKET_SIZE;
+st->start_time = 0;
+return 0;
+}
+
+static int aptx_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE);
+}
+
+static const AVOption aptx_options[] = {
+{ "sample_rate", "", offsetof(AptXDemuxerContext, sample_rate), 
AV_OPT_TYPE_INT, {.i64 = 48000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+{ NULL },
+};
+
+static const AVClass aptx_demuxer_class = {
+.class_name = "aptx demuxer",
+.item_name  = av_default_item_name,
+.option = aptx_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+AVInputFormat ff_aptx_demuxer = {
+.name   = "aptx",
+.long_name  = NULL_IF_CONFIG_SMALL("raw aptX"),
+.extensions = "aptx",
+.priv_data_size = sizeof(AptXDemuxerContext),
+

[FFmpeg-cvslog] aptx: implement the aptX bluetooth codec

2017-11-10 Thread Aurelien Jacobs
ffmpeg | branch: master | Aurelien Jacobs  | Fri Nov 10 
22:09:23 2017 +0100| [a337b36b8bd68cacd0e8903c0b26420cb30fbee8] | committer: 
Rostislav Pehlivanov

aptx: implement the aptX bluetooth codec

The encoder was reverse engineered from binary library and from
EP0398973B1 patent (long expired).
The decoder was simply deduced from the encoder.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a337b36b8bd68cacd0e8903c0b26420cb30fbee8
---

 doc/general.texi|   2 +
 libavcodec/Makefile |   2 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/aptx.c   | 860 
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 +
 6 files changed, 873 insertions(+)

diff --git a/doc/general.texi b/doc/general.texi
index e6ae277d23..de4efee913 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -993,6 +993,8 @@ following image formats are supported:
 @item Amazing Studio PAF Audio @tab @tab  X
 @item Apple lossless audio   @tab  X  @tab  X
 @tab QuickTime fourcc 'alac'
+@item aptX   @tab  X  @tab  X
+@tab Used in Bluetooth A2DP
 @item ATRAC1 @tab @tab  X
 @item ATRAC3 @tab @tab  X
 @item ATRAC3+@tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 45f4db5939..95c843dee7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -188,6 +188,8 @@ OBJS-$(CONFIG_AMV_ENCODER) += mjpegenc.o 
mjpegenc_common.o \
 OBJS-$(CONFIG_ANM_DECODER) += anm.o
 OBJS-$(CONFIG_ANSI_DECODER)+= ansi.o cga_data.o
 OBJS-$(CONFIG_APE_DECODER) += apedec.o
+OBJS-$(CONFIG_APTX_DECODER)+= aptx.o
+OBJS-$(CONFIG_APTX_ENCODER)+= aptx.o
 OBJS-$(CONFIG_APNG_DECODER)+= png.o pngdec.o pngdsp.o
 OBJS-$(CONFIG_APNG_ENCODER)+= png.o pngenc.o
 OBJS-$(CONFIG_SSA_DECODER) += assdec.o ass.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d96e499ba7..463f7ed64e 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -406,6 +406,7 @@ static void register_all(void)
 REGISTER_DECODER(AMRNB, amrnb);
 REGISTER_DECODER(AMRWB, amrwb);
 REGISTER_DECODER(APE,   ape);
+REGISTER_ENCDEC (APTX,  aptx);
 REGISTER_DECODER(ATRAC1,atrac1);
 REGISTER_DECODER(ATRAC3,atrac3);
 REGISTER_DECODER(ATRAC3AL,  atrac3al);
diff --git a/libavcodec/aptx.c b/libavcodec/aptx.c
new file mode 100644
index 00..d09ce8f838
--- /dev/null
+++ b/libavcodec/aptx.c
@@ -0,0 +1,860 @@
+/*
+ * Audio Processing Technology codec for Bluetooth (aptX)
+ *
+ * Copyright (C) 2017  Aurelien Jacobs 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "avcodec.h"
+#include "internal.h"
+#include "mathops.h"
+#include "audio_frame_queue.h"
+
+
+enum channels {
+LEFT,
+RIGHT,
+NB_CHANNELS
+};
+
+enum subbands {
+LF,  // Low Frequency (0-5.5 kHz)
+MLF, // Medium-Low Frequency (5.5-11kHz)
+MHF, // Medium-High Frequency (11-16.5kHz)
+HF,  // High Frequency (16.5-22kHz)
+NB_SUBBANDS
+};
+
+#define NB_FILTERS 2
+#define FILTER_TAPS 16
+
+typedef struct {
+int pos;
+int32_t buffer[2*FILTER_TAPS];
+} FilterSignal;
+
+typedef struct {
+FilterSignal outer_filter_signal[NB_FILTERS];
+FilterSignal inner_filter_signal[NB_FILTERS][NB_FILTERS];
+} QMFAnalysis;
+
+typedef struct {
+int32_t quantized_sample;
+int32_t quantized_sample_parity_change;
+int32_t error;
+} Quantize;
+
+typedef struct {
+int32_t quantization_factor;
+int32_t factor_select;
+int32_t reconstructed_difference;
+} InvertQuantize;
+
+typedef struct {
+int32_t prev_sign[2];
+int32_t s_weight[2];
+int32_t d_weight[24];
+int32_t pos;
+int32_t reconstructed_differences[48];
+int32_t previous_reconstructed_sample;
+int32_t predicted_difference;
+int32_t predicted_sample;
+} Prediction;
+
+typedef struct {
+int32_t codeword_history;
+int32_t dither_parity;
+int32_t dither[NB_SUBBANDS];
+
+QMFAnalysis qmf;
+

[FFmpeg-cvslog] Changelog: list the new aptX features

2017-11-10 Thread Rostislav Pehlivanov
ffmpeg | branch: master | Rostislav Pehlivanov  | Fri Nov 
10 21:31:07 2017 +| [eb7a01d692684b3d7008506aaedfcdd79193bde6] | committer: 
Rostislav Pehlivanov

Changelog: list the new aptX features

Signed-off-by: Rostislav Pehlivanov 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb7a01d692684b3d7008506aaedfcdd79193bde6
---

 Changelog | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Changelog b/Changelog
index c1c886193e..3914672831 100644
--- a/Changelog
+++ b/Changelog
@@ -11,6 +11,8 @@ version :
 - TiVo ty/ty+ demuxer
 - Intel QSV-accelerated MJPEG encoding
 - PCE support for extended channel layouts in the AAC encoder
+- native aptX encoder and decoder
+- Raw aptX muxer and demuxer
 
 
 version 3.4:

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] decode: add a mechanism for performing delayed processing on the decoded frames

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Nov 10 
16:07:44 2017 +0100| [7fa64514c8d2ec4d3dcb5f194511609ddcc288e6] | committer: 
Timo Rothenpieler

decode: add a mechanism for performing delayed processing on the decoded frames

This will be useful in the CUVID hwaccel.

Merges Libav commit badf0951f54c1332e77455dc40398f3512540c1b.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7fa64514c8d2ec4d3dcb5f194511609ddcc288e6
---

 libavcodec/decode.c | 15 +++
 libavcodec/decode.h | 14 ++
 2 files changed, 29 insertions(+)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 0f215d6915..8b03f61a22 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -620,6 +620,18 @@ static int decode_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 av_assert0((frame->private_ref && frame->private_ref->size == 
sizeof(FrameDecodeData)) ||
!(avctx->codec->capabilities & AV_CODEC_CAP_DR1));
 
+if (frame->private_ref) {
+FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data;
+
+if (fdd->post_process) {
+ret = fdd->post_process(avctx, frame);
+if (ret < 0) {
+av_frame_unref(frame);
+return ret;
+}
+}
+}
+
 av_buffer_unref(>private_ref);
 }
 
@@ -1566,6 +1578,9 @@ static void decode_data_free(void *opaque, uint8_t *data)
 {
 FrameDecodeData *fdd = (FrameDecodeData*)data;
 
+if (fdd->post_process_opaque_free)
+fdd->post_process_opaque_free(fdd->post_process_opaque);
+
 av_freep();
 }
 
diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index 519f875c98..51947b9ec0 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -22,6 +22,7 @@
 #define AVCODEC_DECODE_H
 
 #include "libavutil/buffer.h"
+#include "libavutil/frame.h"
 
 #include "avcodec.h"
 
@@ -30,6 +31,19 @@
  * private_ref.
  */
 typedef struct FrameDecodeData {
+/**
+ * The callback to perform some delayed processing on the frame right
+ * before it is returned to the caller.
+ *
+ * @note This code is called at some unspecified point after the frame is
+ * returned from the decoder's decode/receive_frame call. Therefore it 
cannot rely
+ * on AVCodecContext being in any specific state, so it does not get to
+ * access AVCodecContext directly at all. All the state it needs must be
+ * stored in the post_process_opaque object.
+ */
+int (*post_process)(void *logctx, AVFrame *frame);
+void *post_process_opaque;
+void (*post_process_opaque_free)(void *opaque);
 } FrameDecodeData;
 
 /**

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] decode: add a per-frame private data for hwaccel use

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Oct 13 
18:59:19 2017 +0200| [81c021c6a2d7848c31984d65f225ba54bdd6f560] | committer: 
Timo Rothenpieler

decode: add a per-frame private data for hwaccel use

This will be useful in the CUVID hwaccel. It should also eventually
replace current decoder-specific mechanisms used by various other
hwaccels.

Merges Libav commit 704311b2946d74a80f65906961cd9baaa18683a3.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=81c021c6a2d7848c31984d65f225ba54bdd6f560
---

 libavcodec/decode.c | 3 +++
 libavcodec/decode.h | 6 ++
 2 files changed, 9 insertions(+)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 8b03f61a22..44b874d4f8 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1581,6 +1581,9 @@ static void decode_data_free(void *opaque, uint8_t *data)
 if (fdd->post_process_opaque_free)
 fdd->post_process_opaque_free(fdd->post_process_opaque);
 
+if (fdd->hwaccel_priv_free)
+fdd->hwaccel_priv_free(fdd->hwaccel_priv);
+
 av_freep();
 }
 
diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index 51947b9ec0..03fc783bba 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -44,6 +44,12 @@ typedef struct FrameDecodeData {
 int (*post_process)(void *logctx, AVFrame *frame);
 void *post_process_opaque;
 void (*post_process_opaque_free)(void *opaque);
+
+/**
+ * Per-frame private data for hwaccels.
+ */
+void *hwaccel_priv;
+void (*hwaccel_priv_free)(void *priv);
 } FrameDecodeData;
 
 /**

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] decode: add a method for attaching lavc-internal data to frames

2017-11-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Oct 13 
18:59:17 2017 +0200| [9f1cfd88af88a7d7d5c56a368a46639dfdfdef75] | committer: 
Timo Rothenpieler

decode: add a method for attaching lavc-internal data to frames

Use the AVFrame.private_ref field.

This new struct will be useful in the following commits.

Merges Libav commit 359a8a3e2d1194b52b6c386f94fd0929567dfb67.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9f1cfd88af88a7d7d5c56a368a46639dfdfdef75
---

 libavcodec/decode.c  | 51 ++--
 libavcodec/decode.h  | 11 ++
 libavcodec/wrapped_avframe.c |  7 ++
 3 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 86fe5aef52..0f215d6915 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -613,6 +613,16 @@ static int decode_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 if (ret == AVERROR_EOF)
 avci->draining_done = 1;
 
+/* free the per-frame decode data */
+if (!ret) {
+/* the only case where decode data is not set should be decoders
+ * that do not call ff_get_buffer() */
+av_assert0((frame->private_ref && frame->private_ref->size == 
sizeof(FrameDecodeData)) ||
+   !(avctx->codec->capabilities & AV_CODEC_CAP_DR1));
+
+av_buffer_unref(>private_ref);
+}
+
 return ret;
 }
 
@@ -1552,6 +1562,37 @@ static void validate_avframe_allocation(AVCodecContext 
*avctx, AVFrame *frame)
 }
 }
 
+static void decode_data_free(void *opaque, uint8_t *data)
+{
+FrameDecodeData *fdd = (FrameDecodeData*)data;
+
+av_freep();
+}
+
+int ff_attach_decode_data(AVFrame *frame)
+{
+AVBufferRef *fdd_buf;
+FrameDecodeData *fdd;
+
+av_assert1(!frame->private_ref);
+av_buffer_unref(>private_ref);
+
+fdd = av_mallocz(sizeof(*fdd));
+if (!fdd)
+return AVERROR(ENOMEM);
+
+fdd_buf = av_buffer_create((uint8_t*)fdd, sizeof(*fdd), decode_data_free,
+   NULL, AV_BUFFER_FLAG_READONLY);
+if (!fdd_buf) {
+av_freep();
+return AVERROR(ENOMEM);
+}
+
+frame->private_ref = fdd_buf;
+
+return 0;
+}
+
 static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int 
flags)
 {
 const AVHWAccel *hwaccel = avctx->hwaccel;
@@ -1588,8 +1629,14 @@ static int get_buffer_internal(AVCodecContext *avctx, 
AVFrame *frame, int flags)
 avctx->sw_pix_fmt = avctx->pix_fmt;
 
 ret = avctx->get_buffer2(avctx, frame, flags);
-if (ret >= 0)
-validate_avframe_allocation(avctx, frame);
+if (ret < 0)
+goto end;
+
+validate_avframe_allocation(avctx, frame);
+
+ret = ff_attach_decode_data(frame);
+if (ret < 0)
+goto end;
 
 end:
 if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions &&
diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index c9630228dc..519f875c98 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -21,9 +21,18 @@
 #ifndef AVCODEC_DECODE_H
 #define AVCODEC_DECODE_H
 
+#include "libavutil/buffer.h"
+
 #include "avcodec.h"
 
 /**
+ * This struct stores per-frame lavc-internal data and is attached to it via
+ * private_ref.
+ */
+typedef struct FrameDecodeData {
+} FrameDecodeData;
+
+/**
  * Called by decoders to get the next packet for decoding.
  *
  * @param pkt An empty packet to be filled with data.
@@ -36,4 +45,6 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket 
*pkt);
 
 void ff_decode_bsfs_uninit(AVCodecContext *avctx);
 
+int ff_attach_decode_data(AVFrame *frame);
+
 #endif /* AVCODEC_DECODE_H */
diff --git a/libavcodec/wrapped_avframe.c b/libavcodec/wrapped_avframe.c
index 5f88a668b9..85ff32d13a 100644
--- a/libavcodec/wrapped_avframe.c
+++ b/libavcodec/wrapped_avframe.c
@@ -25,6 +25,7 @@
  */
 
 #include "avcodec.h"
+#include "decode.h"
 #include "internal.h"
 
 #include "libavutil/internal.h"
@@ -98,6 +99,12 @@ static int wrapped_avframe_decode(AVCodecContext *avctx, 
void *data,
 
 av_frame_move_ref(out, in);
 
+err = ff_attach_decode_data(out);
+if (err < 0) {
+av_frame_unref(out);
+return err;
+}
+
 *got_frame = 1;
 return 0;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avutil/frame: Add private_ref to AVFrame

2017-11-10 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed 
Nov  8 23:55:00 2017 +0100| [1fa3a9a31de11a2dee0efc75b89862e80ab3c90f] | 
committer: Timo Rothenpieler

avutil/frame: Add private_ref to AVFrame

This gives FFmpeg libs a field that they can freely and safely use.
Avoiding the need of wrapping of a users opaque_ref field and its issues.

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1fa3a9a31de11a2dee0efc75b89862e80ab3c90f
---

 libavutil/frame.c |  8 +++-
 libavutil/frame.h | 13 +
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 982fbb5c81..662a7e5ab5 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -383,12 +383,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
 av_buffer_unref(>opaque_ref);
+av_buffer_unref(>private_ref);
 if (src->opaque_ref) {
 dst->opaque_ref = av_buffer_ref(src->opaque_ref);
 if (!dst->opaque_ref)
 return AVERROR(ENOMEM);
 }
-
+if (src->private_ref) {
+dst->private_ref = av_buffer_ref(src->private_ref);
+if (!dst->private_ref)
+return AVERROR(ENOMEM);
+}
 return 0;
 }
 
@@ -524,6 +529,7 @@ void av_frame_unref(AVFrame *frame)
 av_buffer_unref(>hw_frames_ctx);
 
 av_buffer_unref(>opaque_ref);
+av_buffer_unref(>private_ref);
 
 get_frame_defaults(frame);
 }
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 0c6aab1c02..d54bd9a354 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -563,6 +563,19 @@ typedef struct AVFrame {
 /**
  * @}
  */
+
+/**
+ * AVBufferRef for internal use by a single libav* library.
+ * Must not be used to transfer data between libraries.
+ * Has to be NULL when ownership of the frame leaves the respective 
library.
+ *
+ * Code outside the FFmpeg libs should never check or change the contents 
of the buffer ref.
+ *
+ * FFmpeg calls av_buffer_unref() on it when the frame is unreferenced.
+ * av_frame_copy_props() calls create a new reference with av_buffer_ref()
+ * for the target frame's private_ref field.
+ */
+AVBufferRef *private_ref;
 } AVFrame;
 
 #if FF_API_FRAME_GET_SET

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog