Re: [FFmpeg-devel] [PATCH, v2 1/6] lavu/pixfmt: add new pixel format ayuv/y210/y410

2019-09-16 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Carl Eugen Hoyos
> Sent: Saturday, September 14, 2019 00:31
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH, v2 1/6] lavu/pixfmt: add new pixel
> format ayuv/y210/y410
> 
> Am Fr., 13. Sept. 2019 um 18:13 Uhr schrieb Fu, Linjie :
> >
> > > -Original Message-
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > > Of Michael Niedermayer
> > > Sent: Friday, September 13, 2019 23:11
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH, v2 1/6] lavu/pixfmt: add new pixel
> > > format ayuv/y210/y410
> > >
> > > On Thu, Sep 12, 2019 at 12:28:41AM +0800, Linjie Fu wrote:
> > > > Previously, media driver provided planar format(like 420 8 bit),
> > > > but for HEVC Range Extension (422/444 8/10 bit), the decoded image
> > > > is produced in packed format because Windows expects it.
> > > >
> > > > Add some packed pixel formats for hardware decode support in VAAPI
> > > > and QSV:
> > > >
> > > > 4:2:2 10 bit: Y210
> > > > 4:4:4  8 bit: AYUV
> > > > 4:4:4 10 bit: Y410
> > > >
> > > > Signed-off-by: Linjie Fu 
> > > > ---
> > > >  libavutil/pixdesc.c   | 62
> > > +++
> > > >  libavutil/pixfmt.h|  9 +++
> > > >  libavutil/tests/pixfmt_best.c |  1 +
> > > >  libavutil/version.h   |  2 +-
> > > >  4 files changed, 73 insertions(+), 1 deletion(-)
> > >
> > > breaks fate
> > >
> > > --- ./tests/ref/fate/pixfmt_best  2019-09-11 20:36:09.435012759 +0200
> > > +++ tests/data/fate/pixfmt_best   2019-09-13 17:09:53.430392453 +0200
> > > @@ -1 +1 @@
> > > -73 tests passed, 0 tests failed.
> > > +74 tests passed, 0 tests failed.
> > > Test pixfmt_best failed. Look at tests/data/fate/pixfmt_best.err for
> details.
> > > make: *** [fate-pixfmt_best] Error 1
> > >
> >
> > If I didn't get anything missed in the upstream patch, this patch set has
> passed
> > the pre-patch check in https://github.com/intel-media-ci/ffmpeg/pull/88,
> > which includes the fate check.
> 
> Apparently not.
> 
> > Above fate breaking will gone after applying patch 3/6 in the patch set:
> > https://patchwork.ffmpeg.org/patch/15007/
> 
> This indicates you have to merge part(s) of the patches.
> The idea is of course that no patch breaks fate.
> 

Thanks, no single patch breaks fate is reasonable, will include the pixel format
query support in this patch and move the pixfmt_best modification to the fate
patch.

linjie

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/3] lavu/pixfmt: add new pixel format ayuv/y210/y410

2019-09-16 Thread Linjie Fu
Previously, media driver provided planar format(like 420 8 bit),
but for HEVC Range Extension (422/444 8/10 bit), the decoded image
is produced in packed format because Windows expects it.

Add some packed pixel formats for hardware decode support in VAAPI
and QSV:

4:2:2 10 bit: Y210
4:4:4  8 bit: AYUV
4:4:4 10 bit: Y410

Add query support in fate.

Signed-off-by: Linjie Fu 
---
 libavutil/pixdesc.c  | 62 
 libavutil/pixfmt.h   |  9 ++
 libavutil/version.h  |  2 +-
 tests/ref/fate/sws-pixdesc-query | 19 
 4 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 05dd4a1..c2de0d8 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -205,6 +205,68 @@ static const AVPixFmtDescriptor 
av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
 { 0, 4, 1, 0, 8, 3, 7, 2 },/* V */
 },
 },
+[AV_PIX_FMT_Y210LE] = {
+.name = "y210le",
+.nb_components = 3,
+.log2_chroma_w = 1,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 4, 0, 6, 10, 3, 9, 1 },/* Y */
+{ 0, 8, 2, 6, 10, 7, 9, 3 },/* U */
+{ 0, 8, 6, 6, 10, 7, 9, 7 },/* V */
+},
+},
+[AV_PIX_FMT_Y210BE] = {
+.name = "y210be",
+.nb_components = 3,
+.log2_chroma_w = 1,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 4, 0, 6, 10, 3, 9, 1 },/* Y */
+{ 0, 8, 2, 6, 10, 7, 9, 3 },/* U */
+{ 0, 8, 6, 6, 10, 7, 9, 7 },/* V */
+},
+.flags = AV_PIX_FMT_FLAG_BE,
+},
+[AV_PIX_FMT_AYUV] = {
+.name = "ayuv",
+.nb_components = 4,
+.log2_chroma_w = 0,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 4, 1, 0, 8, 3, 7, 2 },/* Y */
+{ 0, 4, 2, 0, 8, 3, 7, 3 },/* U */
+{ 0, 4, 3, 0, 8, 3, 7, 4 },/* V */
+{ 0, 4, 0, 0, 8, 3, 7, 1 },/* A */
+},
+.flags = AV_PIX_FMT_FLAG_ALPHA,
+},
+[AV_PIX_FMT_Y410LE] = {
+.name = "y410le",
+.nb_components = 4,
+.log2_chroma_w = 0,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 32, 10, 0, 10, 31, 9, 11 },/* Y */
+{ 0, 32,  0, 0, 10, 31, 9,  1 },/* U */
+{ 0, 32, 20, 0, 10, 31, 9, 21 },/* V */
+{ 0, 32, 30, 0,  2, 31, 1, 31 },/* A */
+},
+.flags = AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_BITSTREAM,
+},
+[AV_PIX_FMT_Y410BE] = {
+.name = "y410be",
+.nb_components = 4,
+.log2_chroma_w = 0,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 32, 10, 0, 10, 31, 9, 11 },/* Y */
+{ 0, 32,  0, 0, 10, 31, 9,  1 },/* U */
+{ 0, 32, 20, 0, 10, 31, 9, 21 },/* V */
+{ 0, 32, 30, 0,  2, 31, 1, 31 },/* A */
+},
+.flags = AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_BITSTREAM | 
AV_PIX_FMT_FLAG_BE,
+},
 [AV_PIX_FMT_RGB24] = {
 .name = "rgb24",
 .nb_components = 3,
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index d78e863..0176a2a 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -348,6 +348,12 @@ enum AVPixelFormat {
 AV_PIX_FMT_NV24,  ///< planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 
plane for the UV components, which are interleaved (first byte U and the 
following byte V)
 AV_PIX_FMT_NV42,  ///< as above, but U and V bytes are swapped
 
+AV_PIX_FMT_Y210BE,///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, big-endian
+AV_PIX_FMT_Y210LE,///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, 
little-endian
+AV_PIX_FMT_AYUV,  ///< packed YUV 4:4:4, 32bpp,  A  Y Cb Cr,
+AV_PIX_FMT_Y410LE,///< packed YUV 4:4:4, 32bpp, Cr  Y Cb  A, 
little-endian
+AV_PIX_FMT_Y410BE,///< packed YUV 4:4:4, 32bpp, Cr  Y Cb  A, big-endian
+
 AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you 
want to link with shared libav* because the number of formats might differ 
between versions
 };
 
@@ -436,6 +442,9 @@ enum AVPixelFormat {
 #define AV_PIX_FMT_P010   AV_PIX_FMT_NE(P010BE,  P010LE)
 #define AV_PIX_FMT_P016   AV_PIX_FMT_NE(P016BE,  P016LE)
 
+#define AV_PIX_FMT_Y210   AV_PIX_FMT_NE(Y210BE,  Y210LE)
+#define AV_PIX_FMT_Y410   AV_PIX_FMT_NE(Y410BE,  Y410LE)
+
 /**
   * Chromaticity coordinates of the source primaries.
   * These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1.
diff --git a/libavutil/version.h b/libavutil/version.h
index 3395769..af3abf7 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  35
+#define LIBAVUTIL_VERSION_MINOR  36
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAV

[FFmpeg-devel] [PATCH 3/3] swscale: Add swscale input support for Y210

2019-09-16 Thread Linjie Fu
Add swscale input support for Y210, output support and fate
test could be added later if there is requirement for software
CSC to this packed format.

Signed-off-by: Linjie Fu 
---
 libswscale/input.c | 36 
 libswscale/utils.c |  2 ++
 2 files changed, 38 insertions(+)

diff --git a/libswscale/input.c b/libswscale/input.c
index 73d1aa9..527a923 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -571,6 +571,42 @@ static void ayuvToUV_c(uint8_t *dstU, uint8_t *dstV, const 
uint8_t *unused0, con
 av_assert1(src1 == src2);
 }
 
+static void y210le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, 
const uint8_t *src,
+const uint8_t *unused1, int width, uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++) {
+AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> 6);
+AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> 6);
+}
+}
+
+static void y210be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, 
const uint8_t *src,
+const uint8_t *unused1, int width, uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++) {
+AV_WN16(dstU + i * 2, AV_RB16(src + i * 8 + 2) >> 6);
+AV_WN16(dstV + i * 2, AV_RB16(src + i * 8 + 6) >> 6);
+}
+}
+
+static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0,
+   const uint8_t *unused1, int width, uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++)
+AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6);
+}
+
+static void y210be_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0,
+   const uint8_t *unused1, int width, uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++)
+AV_WN16(dst + i * 2 ,AV_RB16(src + i * 4) >> 6);
+}
+
 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t 
*unused1, const uint8_t *unused2, int width,
uint32_t *unused)
 {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 1e12e21..ad5f669 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -266,6 +266,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
 [AV_PIX_FMT_YUVA444P12LE] = { 1, 1 },
 [AV_PIX_FMT_NV24]= { 1, 1 },
 [AV_PIX_FMT_NV42]= { 1, 1 },
+[AV_PIX_FMT_Y210BE]  = { 1, 0 },
+[AV_PIX_FMT_Y210LE]  = { 1, 0 },
 [AV_PIX_FMT_AYUV]= { 1, 1 },
 };
 
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/3] swscale: Add swscale and fate support for AYUV

2019-09-16 Thread Linjie Fu
Add input and output support in swscale for AYUV.

Add fate test for AYUV.

Signed-off-by: Linjie Fu 
---
 libavutil/tests/pixfmt_best.c|  1 +
 libswscale/input.c   | 26 +
 libswscale/output.c  | 50 
 libswscale/utils.c   |  1 +
 libswscale/version.h |  2 +-
 tests/ref/fate/filter-pixdesc-ayuv   |  1 +
 tests/ref/fate/filter-pixfmts-copy   |  1 +
 tests/ref/fate/filter-pixfmts-crop   |  1 +
 tests/ref/fate/filter-pixfmts-field  |  1 +
 tests/ref/fate/filter-pixfmts-fieldorder |  1 +
 tests/ref/fate/filter-pixfmts-hflip  |  1 +
 tests/ref/fate/filter-pixfmts-il |  1 +
 tests/ref/fate/filter-pixfmts-null   |  1 +
 tests/ref/fate/filter-pixfmts-pad|  1 +
 tests/ref/fate/filter-pixfmts-scale  |  1 +
 tests/ref/fate/filter-pixfmts-transpose  |  1 +
 tests/ref/fate/filter-pixfmts-vflip  |  1 +
 tests/ref/fate/pixfmt_best   |  2 +-
 18 files changed, 92 insertions(+), 2 deletions(-)
 create mode 100644 tests/ref/fate/filter-pixdesc-ayuv

diff --git a/libavutil/tests/pixfmt_best.c b/libavutil/tests/pixfmt_best.c
index 53f7264..2939e48 100644
--- a/libavutil/tests/pixfmt_best.c
+++ b/libavutil/tests/pixfmt_best.c
@@ -91,6 +91,7 @@ int main(void)
 TEST(AV_PIX_FMT_YUVA420P,  AV_PIX_FMT_YUV420P);
 TEST(AV_PIX_FMT_YUVA422P,  AV_PIX_FMT_YUV422P);
 TEST(AV_PIX_FMT_YUVA444P,  AV_PIX_FMT_YUV444P);
+TEST(AV_PIX_FMT_AYUV,  AV_PIX_FMT_YUV444P);
 TEST(AV_PIX_FMT_AYUV64,AV_PIX_FMT_YUV444P16);
 TEST(AV_PIX_FMT_RGBA,  AV_PIX_FMT_RGB24);
 TEST(AV_PIX_FMT_ABGR,  AV_PIX_FMT_RGB24);
diff --git a/libswscale/input.c b/libswscale/input.c
index 064f8da..73d1aa9 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -552,6 +552,25 @@ static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const 
uint8_t *unused0, con
 av_assert1(src1 == src2);
 }
 
+static void ayuvToY_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused1, const uint8_t *unused2,  int width,
+  uint32_t *unused)
+{
+int i;
+for (i = 0; i < width; i++)
+dst[i] = src[4 * i + 2];
+}
+
+static void ayuvToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, 
const uint8_t *src1,
+   const uint8_t *src2, int width, uint32_t *unused)
+{
+int i;
+for (i = 0; i < width; i++) {
+dstV[i] = src1[4 * i];
+dstU[i] = src1[4 * i + 1];
+}
+av_assert1(src1 == src2);
+}
+
 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t 
*unused1, const uint8_t *unused2, int width,
uint32_t *unused)
 {
@@ -1154,6 +1173,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_P016BE:
 c->chrToYV12 = p016BEToUV_c;
 break;
+case AV_PIX_FMT_AYUV:
+c->chrToYV12 = ayuvToUV_c;
+break;
 }
 if (c->chrSrcHSubSample) {
 switch (srcFormat) {
@@ -1586,6 +1608,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 c->lumToYV12 = grayf32ToY16_bswap_c;
 #endif
 break;
+case AV_PIX_FMT_AYUV:
+c->lumToYV12 = ayuvToY_c;
+break;
 }
 if (c->needAlpha) {
 if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
@@ -1599,6 +1624,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_RGBA64BE:  c->alpToYV12 = rgba64beToA_c; break;
 case AV_PIX_FMT_BGRA:
 case AV_PIX_FMT_RGBA:
+case AV_PIX_FMT_AYUV:
 c->alpToYV12 = rgbaToA_c;
 break;
 case AV_PIX_FMT_ABGR:
diff --git a/libswscale/output.c b/libswscale/output.c
index 7eb4644..ebd4f93 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2403,6 +2403,53 @@ yuv2ya8_X_c(SwsContext *c, const int16_t *lumFilter,
 }
 
 static void
+yuv2ayuv_X_c(SwsContext *c, const int16_t *lumFilter,
+ const int16_t **lumSrc, int lumFilterSize,
+ const int16_t *chrFilter, const int16_t **chrUSrc,
+ const int16_t **chrVSrc, int chrFilterSize,
+ const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
+{
+int hasAlpha = !!alpSrc;
+int i;
+
+for (i = 0; i < dstW; i++) {
+int j;
+int A = 1 << 18;
+int Y = 1 << 18;
+int U = 1 << 18;
+int V = 1 << 18;
+
+for (j = 0; j < lumFilterSize; j++) {
+Y += lumSrc[j][i]  * lumFilter[j];
+}
+for (j = 0; j < chrFilterSize; j++) {
+U += chrUSrc[j][i] * chrFilter[j];
+V += chrVSrc[j][i] * chrFilter[j];
+}
+if (hasAlpha)
+for (j = 0; j < lumFilterSize; j++)
+A += alpSrc[j][i] * lumFilter[j];
+A >>= 19;
+Y >>= 19;
+U >>= 19;
+V >>= 19;
+A = hasAlpha ? A : 255;
+
+if ((A | Y | U | V) & 0x100) {
+A = av_cli

[FFmpeg-devel] [PATCH 1/5] lavc/vaapi_hevc: extend parameter buffer to ParameterBufferHEVCExtension

2019-09-16 Thread Linjie Fu
Extend ParameterBufferHEVC to ParameterBufferHEVCExtension for both
VAPicture and VASlice.

Pass Range Extension flags to support the decode for HEVC REXT.

Separate the behaviour of ff_vaapi_decode_make_slice_buffer for base and
rext to avoid potential regression.

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_hevc.c | 134 
 1 file changed, 112 insertions(+), 22 deletions(-)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index c69d63d..f0b6f8e 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -29,8 +29,13 @@
 #include "vaapi_decode.h"
 
 typedef struct VAAPIDecodePictureHEVC {
+#if VA_CHECK_VERSION(1, 2, 0)
+VAPictureParameterBufferHEVCExtension pic_param;
+VASliceParameterBufferHEVCExtension last_slice_param;
+#else
 VAPictureParameterBufferHEVC pic_param;
 VASliceParameterBufferHEVC last_slice_param;
+#endif
 const uint8_t *last_buffer;
 size_t last_size;
 
@@ -116,12 +121,17 @@ static int vaapi_hevc_start_frame(AVCodecContext  
*avctx,
 const HEVCSPS  *sps = h->ps.sps;
 const HEVCPPS  *pps = h->ps.pps;
 
+#if VA_CHECK_VERSION(1, 2, 0)
+VAPictureParameterBufferHEVC *pic_param = &pic->pic_param.base;
+#else
+VAPictureParameterBufferHEVC *pic_param = &pic->pic_param;
+#endif
+
 const ScalingList *scaling_list = NULL;
 int err, i;
 
 pic->pic.output_surface = ff_vaapi_get_surface_id(h->ref->frame);
-
-pic->pic_param = (VAPictureParameterBufferHEVC) {
+*pic_param = (VAPictureParameterBufferHEVC) {
 .pic_width_in_luma_samples= sps->width,
 .pic_height_in_luma_samples   = sps->height,
 .log2_min_luma_coding_block_size_minus3   = sps->log2_min_cb_size 
- 3,
@@ -188,26 +198,54 @@ static int vaapi_hevc_start_frame(AVCodecContext  
*avctx,
 },
 };
 
-fill_vaapi_pic(&pic->pic_param.CurrPic, h->ref, 0);
-fill_vaapi_reference_frames(h, &pic->pic_param);
+fill_vaapi_pic(&pic_param->CurrPic, h->ref, 0);
+fill_vaapi_reference_frames(h, pic_param);
 
 if (pps->tiles_enabled_flag) {
-pic->pic_param.num_tile_columns_minus1 = pps->num_tile_columns - 1;
-pic->pic_param.num_tile_rows_minus1= pps->num_tile_rows - 1;
+pic_param->num_tile_columns_minus1 = pps->num_tile_columns - 1;
+pic_param->num_tile_rows_minus1= pps->num_tile_rows - 1;
 
 for (i = 0; i < pps->num_tile_columns; i++)
-pic->pic_param.column_width_minus1[i] = pps->column_width[i] - 1;
-
+pic_param->column_width_minus1[i] = pps->column_width[i] - 1;
 for (i = 0; i < pps->num_tile_rows; i++)
-pic->pic_param.row_height_minus1[i] = pps->row_height[i] - 1;
+pic_param->row_height_minus1[i] = pps->row_height[i] - 1;
 }
 
 if (h->sh.short_term_ref_pic_set_sps_flag == 0 && h->sh.short_term_rps) {
-pic->pic_param.st_rps_bits = h->sh.short_term_ref_pic_set_size;
+pic_param->st_rps_bits = h->sh.short_term_ref_pic_set_size;
 } else {
-pic->pic_param.st_rps_bits = 0;
+pic_param->st_rps_bits = 0;
 }
 
+#if VA_CHECK_VERSION(1, 2, 0)
+if (sps->sps_range_extension_flag) {
+pic->pic_param.rext = (VAPictureParameterBufferHEVCRext) {
+.range_extension_pic_fields.bits  = {
+.transform_skip_rotation_enabled_flag   = 
sps->transform_skip_rotation_enabled_flag,
+.transform_skip_context_enabled_flag= 
sps->transform_skip_context_enabled_flag,
+.implicit_rdpcm_enabled_flag= 
sps->implicit_rdpcm_enabled_flag,
+.explicit_rdpcm_enabled_flag= 
sps->explicit_rdpcm_enabled_flag,
+.extended_precision_processing_flag = 
sps->extended_precision_processing_flag,
+.intra_smoothing_disabled_flag  = 
sps->intra_smoothing_disabled_flag,
+.high_precision_offsets_enabled_flag= 
sps->high_precision_offsets_enabled_flag,
+.persistent_rice_adaptation_enabled_flag= 
sps->persistent_rice_adaptation_enabled_flag,
+.cabac_bypass_alignment_enabled_flag= 
sps->cabac_bypass_alignment_enabled_flag,
+.cross_component_prediction_enabled_flag= 
pps->cross_component_prediction_enabled_flag,
+.chroma_qp_offset_list_enabled_flag = 
pps->chroma_qp_offset_list_enabled_flag,
+},
+.diff_cu_chroma_qp_offset_depth = 
pps->diff_cu_chroma_qp_offset_depth,
+.chroma_qp_offset_list_len_minus1   = 
pps->chroma_qp_offset_list_len_minus1,
+.log2_sao_offset_scale_luma = 
pps->log2_sao_offset_scale_luma,
+.log2_sao_offset_scale_chroma   = 
pps->log2_sao_offset_scale_chroma,
+.log2_max_t

[FFmpeg-devel] [PATCH 2/5] lavc/hevc_ps: parse constraint flags for HEVC REXT

2019-09-16 Thread Linjie Fu
Parse all the constraint flags according to ITU-T Rec. H.265 (02/2018).

It can be passed to hw decoders to determine the exact profile for Range
Extension HEVC.

Signed-off-by: Linjie Fu 
---
 libavcodec/hevc_ps.c | 44 
 libavcodec/hevc_ps.h | 13 -
 2 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index abf08b9..82d3b79 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -267,7 +267,7 @@ static int decode_profile_tier_level(GetBitContext *gb, 
AVCodecContext *avctx,
 {
 int i;
 
-if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 16 + 16 + 12)
+if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 43 + 1)
 return -1;
 
 ptl->profile_space = get_bits(gb, 2);
@@ -295,9 +295,45 @@ static int decode_profile_tier_level(GetBitContext *gb, 
AVCodecContext *avctx,
 ptl->non_packed_constraint_flag = get_bits1(gb);
 ptl->frame_only_constraint_flag = get_bits1(gb);
 
-skip_bits(gb, 16); // XXX_reserved_zero_44bits[0..15]
-skip_bits(gb, 16); // XXX_reserved_zero_44bits[16..31]
-skip_bits(gb, 12); // XXX_reserved_zero_44bits[32..43]
+#define check_profile_idc(idc) \
+ptl->profile_idc == idc || ptl->profile_compatibility_flag[idc]
+
+if (check_profile_idc(4) || check_profile_idc(5) || check_profile_idc(6) ||
+check_profile_idc(7) || check_profile_idc(8) || check_profile_idc(9) ||
+check_profile_idc(10)) {
+
+ptl->max_12bit_constraint_flag= get_bits1(gb);
+ptl->max_10bit_constraint_flag= get_bits1(gb);
+ptl->max_8bit_constraint_flag = get_bits1(gb);
+ptl->max_422chroma_constraint_flag= get_bits1(gb);
+ptl->max_420chroma_constraint_flag= get_bits1(gb);
+ptl->max_monochrome_constraint_flag   = get_bits1(gb);
+ptl->intra_constraint_flag= get_bits1(gb);
+ptl->one_picture_only_constraint_flag = get_bits1(gb);
+ptl->lower_bit_rate_constraint_flag   = get_bits1(gb);
+
+if (check_profile_idc(5) || check_profile_idc(9) || 
check_profile_idc(10)) {
+ptl->max_14bit_constraint_flag= get_bits1(gb);
+skip_bits_long(gb, 33); // XXX_reserved_zero_33bits[0..32]
+} else {
+skip_bits_long(gb, 34); // XXX_reserved_zero_34bits[0..33]
+}
+} else if (check_profile_idc(2)) {
+skip_bits(gb, 7);
+ptl->one_picture_only_constraint_flag = get_bits1(gb);
+skip_bits_long(gb, 35); // XXX_reserved_zero_35bits[0..34]
+} else {
+skip_bits_long(gb, 43); // XXX_reserved_zero_43bits[0..42]
+}
+
+if ((ptl->profile_idc >=1 && ptl->profile_idc <= 5) || ptl->profile_idc == 
9 ||
+ptl->profile_compatibility_flag[1] || 
ptl->profile_compatibility_flag[2] ||
+ptl->profile_compatibility_flag[3] || 
ptl->profile_compatibility_flag[4] ||
+ptl->profile_compatibility_flag[5] || 
ptl->profile_compatibility_flag[9])
+ptl->inbld_flag = get_bits1(gb);
+else
+skip_bits1(gb);
+#undef check_profile_idc
 
 return 0;
 }
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 2840dc4..8e1bccd 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -177,11 +177,22 @@ typedef struct PTLCommon {
 uint8_t tier_flag;
 uint8_t profile_idc;
 uint8_t profile_compatibility_flag[32];
-uint8_t level_idc;
 uint8_t progressive_source_flag;
 uint8_t interlaced_source_flag;
 uint8_t non_packed_constraint_flag;
 uint8_t frame_only_constraint_flag;
+uint8_t max_12bit_constraint_flag;
+uint8_t max_10bit_constraint_flag;
+uint8_t max_8bit_constraint_flag;
+uint8_t max_422chroma_constraint_flag;
+uint8_t max_420chroma_constraint_flag;
+uint8_t max_monochrome_constraint_flag;
+uint8_t intra_constraint_flag;
+uint8_t one_picture_only_constraint_flag;
+uint8_t lower_bit_rate_constraint_flag;
+uint8_t max_14bit_constraint_flag;
+uint8_t inbld_flag;
+uint8_t level_idc;
 } PTLCommon;
 
 typedef struct PTL {
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/5] lavc/vaapi_hevc: add function to find exact va_profile for REXT

2019-09-16 Thread Linjie Fu
Add vaapi_parse_rext_profile and use profile constraint flags to
determine the exact va_profile for HEVC_REXT.

Add build object in Makefile for h265_profile_level dependency.

Signed-off-by: Linjie Fu 
---
 libavcodec/Makefile |  2 +-
 libavcodec/vaapi_hevc.c | 69 +
 libavcodec/vaapi_hevc.h | 24 +
 3 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/vaapi_hevc.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6bc4383..e799e97 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -880,7 +880,7 @@ 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_VAAPI_HWACCEL) += vaapi_hevc.o h265_profile_level.o
 OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
 OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL)+= nvdec_mjpeg.o
 OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL)+= vaapi_mjpeg.o
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index f0b6f8e..b3f6163 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -27,6 +27,8 @@
 #include "hevcdec.h"
 #include "hwaccel.h"
 #include "vaapi_decode.h"
+#include "vaapi_hevc.h"
+#include "h265_profile_level.h"
 
 typedef struct VAAPIDecodePictureHEVC {
 #if VA_CHECK_VERSION(1, 2, 0)
@@ -511,6 +513,73 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 return 0;
 }
 
+static int ptl_convert(const PTLCommon *general_ptl, H265RawProfileTierLevel 
*h265_raw_ptl)
+{
+h265_raw_ptl->general_profile_space = general_ptl->profile_space;
+h265_raw_ptl->general_tier_flag = general_ptl->tier_flag;
+h265_raw_ptl->general_profile_idc   = general_ptl->profile_idc;
+
+memcpy(h265_raw_ptl->general_profile_compatibility_flag,
+  general_ptl->profile_compatibility_flag, 32 
* sizeof(int));
+
+h265_raw_ptl->general_progressive_source_flag  = 
general_ptl->progressive_source_flag;
+h265_raw_ptl->general_interlaced_source_flag   = 
general_ptl->interlaced_source_flag;
+h265_raw_ptl->general_non_packed_constraint_flag   = 
general_ptl->non_packed_constraint_flag;
+h265_raw_ptl->general_frame_only_constraint_flag   = 
general_ptl->frame_only_constraint_flag;
+h265_raw_ptl->general_max_12bit_constraint_flag= 
general_ptl->max_12bit_constraint_flag;
+h265_raw_ptl->general_max_10bit_constraint_flag= 
general_ptl->max_10bit_constraint_flag;
+h265_raw_ptl->general_max_8bit_constraint_flag = 
general_ptl->max_8bit_constraint_flag;
+h265_raw_ptl->general_max_422chroma_constraint_flag= 
general_ptl->max_422chroma_constraint_flag;
+h265_raw_ptl->general_max_420chroma_constraint_flag= 
general_ptl->max_420chroma_constraint_flag;
+h265_raw_ptl->general_max_monochrome_constraint_flag   = 
general_ptl->max_monochrome_constraint_flag;
+h265_raw_ptl->general_intra_constraint_flag= 
general_ptl->intra_constraint_flag;
+h265_raw_ptl->general_one_picture_only_constraint_flag = 
general_ptl->one_picture_only_constraint_flag;
+h265_raw_ptl->general_lower_bit_rate_constraint_flag   = 
general_ptl->lower_bit_rate_constraint_flag;
+h265_raw_ptl->general_max_14bit_constraint_flag= 
general_ptl->max_14bit_constraint_flag;
+h265_raw_ptl->general_inbld_flag   = 
general_ptl->inbld_flag;
+h265_raw_ptl->general_level_idc= 
general_ptl->level_idc;
+
+return 0;
+}
+
+/*
+ * Find exact va_profile for HEVC Range Extension
+ */
+VAProfile ff_vaapi_parse_rext_profile(AVCodecContext *avctx)
+{
+const HEVCContext *h = avctx->priv_data;
+const HEVCSPS *sps = h->ps.sps;
+const PTL *ptl = &(sps->ptl);
+const PTLCommon *general_ptl = &(ptl->general_ptl);
+const H265ProfileDescriptor *profile = NULL;
+
+H265RawProfileTierLevel *h265_raw_ptl = 
av_mallocz(sizeof(H265RawProfileTierLevel));
+/* convert PTLCommon to H265RawProfileTierLevel */
+ptl_convert(general_ptl, h265_raw_ptl);
+
+profile = ff_h265_get_profile(h265_raw_ptl);
+av_freep(&h265_raw_ptl);
+
+if (!profile)
+return VAProfileNone;
+
+#if VA_CHECK_VERSION(1, 2, 0)
+if (!strcmp(profile->name, "Main 4:2:2 10") ||
+!strcmp(profile->name, "Main 4:2:2 10 Intra"))
+return VAProfileHEVCMain422_10;
+else if (!strcmp(profile->name, "Main 4:4:4") ||
+ !strcmp(profile->name, "Main 4:4:4 Intra"))
+return VAProfileHEVCMain444;
+else if (!strcmp(profile->name, "Main 4:4:4 10") ||
+ !strcmp(profile->name, "Main 4:4:4 10 Intra"))
+return VAProfileHEVCMain444_10;
+#else
+av_log(avctx, AV_LOG_WARNING, "HEVC profile %s i

[FFmpeg-devel] [PATCH 4/5] lavc/vaapi_decode: add profile_parser and format map support for HEVC REXT

2019-09-16 Thread Linjie Fu
Add function pointer field in vaapi_profile_map[], set profile_parser
for HEVC_REXT to find the exact va_profile.

Also add format map support.

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_decode.c | 83 ++-
 1 file changed, 53 insertions(+), 30 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 69512e1..ff36b88 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -24,7 +24,7 @@
 #include "decode.h"
 #include "internal.h"
 #include "vaapi_decode.h"
-
+#include "vaapi_hevc.h"
 
 int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
   VAAPIDecodePicture *pic,
@@ -256,10 +256,22 @@ static const struct {
 #ifdef VA_FOURCC_YV16
 MAP(YV16, YUV422P),
 #endif
+#ifdef VA_FOURCC_YUY2
+MAP(YUY2, YUYV422),
+#endif
+#ifdef VA_FOURCC_Y210
+MAP(Y210, Y210),
+#endif
 // 4:4:0
 MAP(422V, YUV440P),
 // 4:4:4
 MAP(444P, YUV444P),
+#ifdef VA_FOURCC_AYUV
+MAP(AYUV, AYUV),
+#endif
+#ifdef VA_FOURCC_Y410
+MAP(Y410, Y410),
+#endif
 // 4:2:0 10-bit
 #ifdef VA_FOURCC_P010
 MAP(P010, P010),
@@ -364,39 +376,44 @@ static const struct {
 enum AVCodecID codec_id;
 int codec_profile;
 VAProfile va_profile;
+VAProfile (*profile_parser)(AVCodecContext *avctx);
 } vaapi_profile_map[] = {
-#define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v }
-MAP(MPEG2VIDEO,  MPEG2_SIMPLE,MPEG2Simple ),
-MAP(MPEG2VIDEO,  MPEG2_MAIN,  MPEG2Main   ),
-MAP(H263,UNKNOWN, H263Baseline),
-MAP(MPEG4,   MPEG4_SIMPLE,MPEG4Simple ),
+#define MAP(c, p, v, f) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v, 
f}
+MAP(MPEG2VIDEO,  MPEG2_SIMPLE,MPEG2Simple , NULL ),
+MAP(MPEG2VIDEO,  MPEG2_MAIN,  MPEG2Main   , NULL ),
+MAP(H263,UNKNOWN, H263Baseline, NULL ),
+MAP(MPEG4,   MPEG4_SIMPLE,MPEG4Simple , NULL ),
 MAP(MPEG4,   MPEG4_ADVANCED_SIMPLE,
-   MPEG4AdvancedSimple),
-MAP(MPEG4,   MPEG4_MAIN,  MPEG4Main   ),
+   MPEG4AdvancedSimple, NULL ),
+MAP(MPEG4,   MPEG4_MAIN,  MPEG4Main   , NULL ),
 MAP(H264,H264_CONSTRAINED_BASELINE,
-   H264ConstrainedBaseline),
-MAP(H264,H264_MAIN,   H264Main),
-MAP(H264,H264_HIGH,   H264High),
+   H264ConstrainedBaseline, NULL ),
+MAP(H264,H264_MAIN,   H264Main, NULL ),
+MAP(H264,H264_HIGH,   H264High, NULL ),
 #if VA_CHECK_VERSION(0, 37, 0)
-MAP(HEVC,HEVC_MAIN,   HEVCMain),
-MAP(HEVC,HEVC_MAIN_10,HEVCMain10  ),
+MAP(HEVC,HEVC_MAIN,   HEVCMain, NULL ),
+MAP(HEVC,HEVC_MAIN_10,HEVCMain10  , NULL ),
+#endif
+#if VA_CHECK_VERSION(1, 2, 0)
+MAP(HEVC,HEVC_REXT,   None,
+  ff_vaapi_parse_rext_profile),
 #endif
 MAP(MJPEG,   MJPEG_HUFFMAN_BASELINE_DCT,
-  JPEGBaseline),
-MAP(WMV3,VC1_SIMPLE,  VC1Simple   ),
-MAP(WMV3,VC1_MAIN,VC1Main ),
-MAP(WMV3,VC1_COMPLEX, VC1Advanced ),
-MAP(WMV3,VC1_ADVANCED,VC1Advanced ),
-MAP(VC1, VC1_SIMPLE,  VC1Simple   ),
-MAP(VC1, VC1_MAIN,VC1Main ),
-MAP(VC1, VC1_COMPLEX, VC1Advanced ),
-MAP(VC1, VC1_ADVANCED,VC1Advanced ),
-MAP(VP8, UNKNOWN,   VP8Version0_3 ),
+  JPEGBaseline, NULL ),
+MAP(WMV3,VC1_SIMPLE,  VC1Simple   , NULL ),
+MAP(WMV3,VC1_MAIN,VC1Main , NULL ),
+MAP(WMV3,VC1_COMPLEX, VC1Advanced , NULL ),
+MAP(WMV3,VC1_ADVANCED,VC1Advanced , NULL ),
+MAP(VC1, VC1_SIMPLE,  VC1Simple   , NULL ),
+MAP(VC1, VC1_MAIN,VC1Main , NULL ),
+MAP(VC1, VC1_COMPLEX, VC1Advanced , NULL ),
+MAP(VC1, VC1_ADVANCED,VC1Advanced , NULL ),
+MAP(VP8, UNKNOWN,   VP8Version0_3 , NULL ),
 #if VA_CHECK_VERSION(0, 38, 0)
-MAP(VP9, VP9_0,   VP9Profile0 ),
+MAP(VP9, VP9_0,   VP9Profile0 , NULL ),
 #endif
 #if VA_CHECK_VERSION(0, 39, 0)
-MAP(VP9, VP9_2,   VP9Profile2 ),
+MAP(VP9, VP9_2,   VP9Profile2 , NULL ),
 #endif
 #undef MAP
 };
@@ -415,8 +432,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 VAStatus vas;
 int err, i, j;
 const AVCodecDescriptor *codec_desc;
-VAProfile *profile_list = NULL, matched_va_profile;
-int profile_count, exact_match, matched_ff_profile;
+VAProfile *profile_list = NULL, matched_va_profile, va_profile;
+int profile_count, exact_match, matched

[FFmpeg-devel] [PATCH 5/5] lavc/hevcdec: add VAAPI decode support for HEVC Rext

2019-09-16 Thread Linjie Fu
Add decode support for 422/444, 8/10bit HEVC REXT clips.

Signed-off-by: Linjie Fu 
---
 libavcodec/hevcdec.c | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index eed0319..f1ff177 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -419,6 +419,12 @@ static enum AVPixelFormat get_format(HEVCContext *s, const 
HEVCSPS *sps)
 *fmt++ = AV_PIX_FMT_CUDA;
 #endif
 break;
+case AV_PIX_FMT_YUV422P:
+case AV_PIX_FMT_YUV422P10LE:
+#if CONFIG_HEVC_VAAPI_HWACCEL
+   *fmt++ = AV_PIX_FMT_VAAPI;
+#endif
+break;
 case AV_PIX_FMT_YUV444P:
 #if CONFIG_HEVC_VDPAU_HWACCEL
 *fmt++ = AV_PIX_FMT_VDPAU;
@@ -426,9 +432,19 @@ static enum AVPixelFormat get_format(HEVCContext *s, const 
HEVCSPS *sps)
 #if CONFIG_HEVC_NVDEC_HWACCEL
 *fmt++ = AV_PIX_FMT_CUDA;
 #endif
+#if CONFIG_HEVC_VAAPI_HWACCEL
+   *fmt++ = AV_PIX_FMT_VAAPI;
+#endif
 break;
-case AV_PIX_FMT_YUV420P12:
 case AV_PIX_FMT_YUV444P10:
+#if CONFIG_HEVC_NVDEC_HWACCEL
+*fmt++ = AV_PIX_FMT_CUDA;
+#endif
+#if CONFIG_HEVC_VAAPI_HWACCEL
+   *fmt++ = AV_PIX_FMT_VAAPI;
+#endif
+break;
+case AV_PIX_FMT_YUV420P12:
 case AV_PIX_FMT_YUV444P12:
 #if CONFIG_HEVC_NVDEC_HWACCEL
 *fmt++ = AV_PIX_FMT_CUDA;
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v1 1/4] avutil/avstring: support input path is a null pointer or empty string

2019-09-16 Thread Tomas Härdin
mån 2019-09-16 klockan 09:03 +0800 skrev lance.lmw...@gmail.com:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavutil/avstring.c | 12 
>  libavutil/avstring.h | 13 +
>  2 files changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/libavutil/avstring.c b/libavutil/avstring.c
> index 4c068f5bc5..9fddd0c77b 100644
> --- a/libavutil/avstring.c
> +++ b/libavutil/avstring.c
> @@ -257,8 +257,12 @@ char *av_strireplace(const char *str, const char
> *from, const char *to)
>  
>  const char *av_basename(const char *path)
>  {
> -char *p = strrchr(path, '/');
> +char *p = NULL;
> +
> +if (!path || *path == '\0')
> +return ".";

I will note here that this kind of thing would go great with a contract
on the function prototype, so that callers could formally verify that
they can indeed remove the NULL checks, and that the result of
av_basename() is always a valid string..

The patch itself is probably fine

/Tomas

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/ttaenc: Fix undefined shift

2019-09-16 Thread Paul B Mahol
LGTM

On 9/15/19, Andreas Rheinhardt  wrote:
> ttaenc contained (1 << unary) - 1 as an argument for a function
> expecting an unsigned int. unary can be as big as 31 in this case.
> The type of the shift and the whole expression is int, because 1 fits
> into an integer, so that the behaviour is undefined if unary == 31
> as the result of the shift can't be represented in an int §. Subtraction
> by 1 (which makes the result of the whole expression representable in
> an int) doesn't change that this is undefined (it usually leads to
> signed integer overflow which is undefined, too).
>
> The solution is simple: Make 1 unsigned to change the type of the
> whole expression to unsigned int (as the function expects anyway).
>
> Fixes ticket #8153.
>
> §: This of course presupposes the common int range of -2^31..2^31-1
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/ttaenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/ttaenc.c b/libavcodec/ttaenc.c
> index 3cc54d78c5..08a0d0483a 100644
> --- a/libavcodec/ttaenc.c
> +++ b/libavcodec/ttaenc.c
> @@ -164,7 +164,7 @@ pkt_alloc:
>  put_bits(&pb, 31, 0x7FFF);
>  unary -= 31;
>  } else {
> -put_bits(&pb, unary, (1 << unary) - 1);
> +put_bits(&pb, unary, (1U << unary) - 1);
>  unary = 0;
>  }
>  } while (unary);
> --
> 2.21.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v1 1/4] avutil/avstring: support input path is a null pointer or empty string

2019-09-16 Thread Liu Steven


> 在 2019年9月16日,下午4:19,Tomas Härdin  写道:
> 
> mån 2019-09-16 klockan 09:03 +0800 skrev lance.lmw...@gmail.com:
>> From: Limin Wang 
>> 
>> Signed-off-by: Limin Wang 
>> ---
>> libavutil/avstring.c | 12 
>> libavutil/avstring.h | 13 +
>> 2 files changed, 17 insertions(+), 8 deletions(-)
>> 
>> diff --git a/libavutil/avstring.c b/libavutil/avstring.c
>> index 4c068f5bc5..9fddd0c77b 100644
>> --- a/libavutil/avstring.c
>> +++ b/libavutil/avstring.c
>> @@ -257,8 +257,12 @@ char *av_strireplace(const char *str, const char
>> *from, const char *to)
>> 
>> const char *av_basename(const char *path)
>> {
>> -char *p = strrchr(path, '/');
>> +char *p = NULL;
>> +
>> +if (!path || *path == '\0')
>> +return ".";
> 
> I will note here that this kind of thing would go great with a contract
> on the function prototype, so that callers could formally verify that
> they can indeed remove the NULL checks, and that the result of
> av_basename() is always a valid string..
> 
> The patch itself is probably fine
+1
> 
> /Tomas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 1/5] avcodec/v210enc: add depth parameter for WRITE_PIXELS and CLIP

2019-09-16 Thread Michael Niedermayer
On Thu, Sep 12, 2019 at 11:32:32PM +0800, Limin Wang wrote:
> 
> ping for the patchset.

output support for swscale would simplify testing

./ffplay matrixbench_mpeg2.mpg -vf format=y210
...
Impossible to convert between the formats supported by the filter 
'ffplay_buffer' and the filter 'auto_scaler_0'


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is what and why we do it that matters, not just one of them.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/5] lavc/hevc_ps: parse constraint flags for HEVC REXT

2019-09-16 Thread Carl Eugen Hoyos
Am Mo., 16. Sept. 2019 um 09:35 Uhr schrieb Linjie Fu :
>
> Parse all the constraint flags according to ITU-T Rec. H.265 (02/2018).

> It can be passed to hw decoders to determine the exact profile for
> Range Extension HEVC.

I am not a native speaker but I believe this should be more like:
They are needed at least for some hw decoders
or
They have to be passed to hw decoders

Or are the flags not really "needed" for vaapi?


Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 5/5] avcodec/v210enc: move the duplicate code to template file

2019-09-16 Thread Michael Niedermayer
On Sun, Sep 01, 2019 at 09:20:23PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/v210_template.c |  59 +-
>  libavcodec/v210enc.c   | 123 
> +++--
>  2 files changed, 75 insertions(+), 107 deletions(-)

[PATCH v3 3/5] avcodec/v210enc: move the duplicate code to template file
[PATCH v3 5/5] avcodec/v210enc: move the duplicate code to template file

why do 2 patches have the same first line in the commit message ?


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Elect your leaders based on what they did after the last election, not
based on what they say before an election.



signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/5] lavc/vaapi_decode: add profile_parser and format map support for HEVC REXT

2019-09-16 Thread Carl Eugen Hoyos
Am Mo., 16. Sept. 2019 um 09:36 Uhr schrieb Linjie Fu :
>
> Add function pointer field in vaapi_profile_map[], set profile_parser
> for HEVC_REXT to find the exact va_profile.
>
> Also add format map support.

Please remove all cosmetic changes from this patch.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH V3 1/2] avformat/dashdec: fix pointer being freed was not allocated

2019-09-16 Thread vectronic
prevent attempt to call xmlFree if val was not allocated

fixes: 8135
Signed-off-by: vectronic 
---
 libavformat/dashdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 8c0a9b0102..738bfeaefb 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1203,6 +1203,7 @@ static int parse_programinformation(AVFormatContext *s, 
xmlNodePtr node)
 }
 node = xmlNextElementSibling(node);
 xmlFree(val);
+val = NULL;
 }
 return 0;
 }
-- 
2.20.1 (Apple Git-117)

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH V3 2/2] avformat/dashdec: fix segfault when parsing segmentlist

2019-09-16 Thread vectronic
index into segmentlists_tab was specified as 4 instead of 3 causing invalid 
access

further fix to: 8135

Signed-off-by: vectronic 
---
 libavformat/dashdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 738bfeaefb..7713ee8907 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1017,7 +1017,7 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 
 duration_val = get_val_from_nodes_tab(segmentlists_tab, 3, 
"duration");
 timescale_val = get_val_from_nodes_tab(segmentlists_tab, 3, 
"timescale");
-startnumber_val = get_val_from_nodes_tab(segmentlists_tab, 4, 
"startNumber");
+startnumber_val = get_val_from_nodes_tab(segmentlists_tab, 3, 
"startNumber");
 if (duration_val) {
 rep->fragment_duration = (int64_t) strtoll(duration_val, NULL, 
10);
 av_log(s, AV_LOG_TRACE, "rep->fragment_duration = 
[%"PRId64"]\n", rep->fragment_duration);
-- 
2.20.1 (Apple Git-117)

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V3 1/2] avformat/dashdec: fix pointer being freed was not allocated

2019-09-16 Thread Liu Steven


> 在 2019年9月16日,下午6:44,vectronic  写道:
> 
> prevent attempt to call xmlFree if val was not allocated
> 
> fixes: 8135
> Signed-off-by: vectronic 
> ---
> libavformat/dashdec.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 8c0a9b0102..738bfeaefb 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -1203,6 +1203,7 @@ static int parse_programinformation(AVFormatContext *s, 
> xmlNodePtr node)
> }
> node = xmlNextElementSibling(node);
> xmlFree(val);
> +val = NULL;
> }
> return 0;
> }
> -- 
> 2.20.1 (Apple Git-117)
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

patchset LGTM

Thanks
Steven

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 1/5] avcodec/v210enc: add depth parameter for WRITE_PIXELS and CLIP

2019-09-16 Thread Limin Wang
On Mon, Sep 16, 2019 at 12:05:45PM +0200, Michael Niedermayer wrote:
> On Thu, Sep 12, 2019 at 11:32:32PM +0800, Limin Wang wrote:
> > 
> > ping for the patchset.
> 
> output support for swscale would simplify testing
> 
> ./ffplay matrixbench_mpeg2.mpg -vf format=y210
> ...
> Impossible to convert between the formats supported by the filter 
> 'ffplay_buffer' and the filter 'auto_scaler_0'
> 
Sorry, I haven't catch what's your intention. 
v210 is packed format, if we want to play *.v210 file, you can play by below
command:
./ffplay -s 3840x2160  ~/Movies/1.v210

or force to convertto yuv420p:
./ffplay -s 3840x2160  ~/Movies/1.v210 -vf format=yuv420p

For v210 in AVI, we can play it directly:
ffplay ../fate-suite/v210/v210_720p-partial.avi


> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> It is what and why we do it that matters, not just one of them.



> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 5/5] avcodec/v210enc: move the duplicate code to template file

2019-09-16 Thread Limin Wang
On Mon, Sep 16, 2019 at 12:21:36PM +0200, Michael Niedermayer wrote:
> On Sun, Sep 01, 2019 at 09:20:23PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavcodec/v210_template.c |  59 +-
> >  libavcodec/v210enc.c   | 123 
> > +++--
> >  2 files changed, 75 insertions(+), 107 deletions(-)
> 
> [PATCH v3 3/5] avcodec/v210enc: move the duplicate code to template file
> [PATCH v3 5/5] avcodec/v210enc: move the duplicate code to template file
> 
> why do 2 patches have the same first line in the commit message ?
It's for split the patch for review, 3/5 is move v210_planar_pack, 5/5 is 
moving 
v210enc related function, so the code is different.

> 
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Elect your leaders based on what they did after the last election, not
> based on what they say before an election.
> 



> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 1/4] avutil/avstring: support input path is a null pointer or empty string

2019-09-16 Thread lance . lmwang
From: Limin Wang 

Reviewed-by: Tomas Härdin 
Reviewed-by: Liu Steven 
Signed-off-by: Limin Wang 
---
 libavutil/avstring.c | 12 
 libavutil/avstring.h | 13 +
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index 4c068f5bc5..551ca5daee 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -257,8 +257,12 @@ char *av_strireplace(const char *str, const char *from, 
const char *to)
 
 const char *av_basename(const char *path)
 {
-char *p = strrchr(path, '/');
+char *p = NULL;
+
+if (!path || *path == '\0')
+return ".";
 
+p = strrchr(path, '/');
 #if HAVE_DOS_PATHS
 char *q = strrchr(path, '\\');
 char *d = strchr(path, ':');
@@ -274,11 +278,11 @@ const char *av_basename(const char *path)
 
 const char *av_dirname(char *path)
 {
-char *p = strrchr(path, '/');
+char *p = path ? strrchr(path, '/') : NULL;
 
 #if HAVE_DOS_PATHS
-char *q = strrchr(path, '\\');
-char *d = strchr(path, ':');
+char *q = path ? strrchr(path, '\\') : NULL;
+char *d = path ? strchr(path, ':')  : NULL;
 
 d = d ? d + 1 : d;
 
diff --git a/libavutil/avstring.h b/libavutil/avstring.h
index 37dd4e2da0..274335cfb9 100644
--- a/libavutil/avstring.h
+++ b/libavutil/avstring.h
@@ -274,16 +274,21 @@ char *av_strireplace(const char *str, const char *from, 
const char *to);
 
 /**
  * Thread safe basename.
- * @param path the path, on DOS both \ and / are considered separators.
+ * @param path the string to parse, on DOS both \ and / are considered 
separators.
  * @return pointer to the basename substring.
+ * If path does not contain a slash, the function returns a copy of path.
+ * If path is a NULL pointer or points to an empty string, a pointer
+ * to a string "." is returned.
  */
 const char *av_basename(const char *path);
 
 /**
  * Thread safe dirname.
- * @param path the path, on DOS both \ and / are considered separators.
- * @return the path with the separator replaced by the string terminator or 
".".
- * @note the function may change the input string.
+ * @param path the string to parse, on DOS both \ and / are considered 
separators.
+ * @return A pointer to a string that's the parent directory of path.
+ * If path is a NULL pointer or points to an empty string, a pointer
+ * to a string "." is returned.
+ * @note the function may modify the contents of the path, so copies should be 
passed.
  */
 const char *av_dirname(char *path);
 
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 2/4] avformat/hlsenc: remove the unnecessary null pointer check

2019-09-16 Thread lance . lmwang
From: Limin Wang 

Reviewed-by: Liu Steven 
Signed-off-by: Limin Wang 
---
 libavformat/hlsenc.c | 26 ++
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 1f2bdfbe4d..d663785e4a 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1613,16 +1613,13 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
 if (c->use_localtime_mkdir) {
 const char *dir;
 char *fn_copy = av_strdup(oc->url);
-if (!fn_copy) {
-return AVERROR(ENOMEM);
-}
 dir = av_dirname(fn_copy);
 if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
 av_log(oc, AV_LOG_ERROR, "Could not create directory %s 
with use_localtime_mkdir\n", dir);
-av_free(fn_copy);
+av_freep(&fn_copy);
 return AVERROR(errno);
 }
-av_free(fn_copy);
+av_freep(&fn_copy);
 }
 } else {
 char *filename = NULL;
@@ -1784,11 +1781,6 @@ static int validate_name(int nb_vs, const char *fn)
 }
 
 fn_dup = av_strdup(fn);
-if (!fn_dup) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-
 filename = av_basename(fn);
 subdir_name = av_dirname(fn_dup);
 
@@ -1846,11 +1838,6 @@ static int format_name(const char *buf, char **s, int 
index, const char *varname
 /* if %v is present in the file's directory, create sub-directory */
 if (av_stristr(dir, "%v") && proto && !strcmp(proto, "file")) {
 mod_buf_dup = av_strdup(*s);
-if (!mod_buf_dup) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-
 dir = av_dirname(mod_buf_dup);
 if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
 ret = AVERROR(errno);
@@ -2151,11 +2138,6 @@ static int update_master_pl_info(AVFormatContext *s)
 int ret = 0;
 
 fn1 = av_strdup(s->url);
-if (!fn1) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-
 dir = av_dirname(fn1);
 
 /**
@@ -2164,10 +2146,6 @@ static int update_master_pl_info(AVFormatContext *s)
  */
 if (dir && av_stristr(av_basename(dir), "%v")) {
 fn2 = av_strdup(dir);
-if (!fn2) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
 dir = av_dirname(fn2);
 }
 
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 4/4] avformat/hlsenc: replace with av_freep for all av_free

2019-09-16 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/hlsenc.c | 64 ++--
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 753addcbde..784a2b5ec0 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -590,7 +590,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 if ((ret = vs->vtt_avf->io_open(vs->vtt_avf, &out, sub_path, 
AVIO_FLAG_WRITE, &options)) < 0) {
 if (hls->ignore_io_errors)
 ret = 0;
-av_free(sub_path);
+av_freep(&sub_path);
 goto fail;
 }
 ff_format_io_close(vs->vtt_avf, &out);
@@ -598,18 +598,18 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
%s\n",
sub_path, strerror(errno));
 }
-av_free(sub_path);
+av_freep(&sub_path);
 }
 av_freep(&path);
 previous_segment = segment;
 segment = previous_segment->next;
-av_free(previous_segment);
+av_freep(&previous_segment);
 }
 
 fail:
-av_free(path);
-av_free(dirname);
-av_free(vtt_dirname);
+av_freep(&path);
+av_freep(&dirname);
+av_freep(&vtt_dirname);
 
 return ret;
 }
@@ -887,7 +887,7 @@ static int sls_flags_filename_process(struct 
AVFormatContext *s, HLSContext *hls
 strlen(vs->current_segment_final_filename_fmt)) {
 char * new_url = av_strdup(vs->current_segment_final_filename_fmt);
 if (!new_url) {
-av_free(en);
+av_freep(&en);
 return AVERROR(ENOMEM);
 }
 ff_format_set_url(vs->avf, new_url);
@@ -898,8 +898,8 @@ static int sls_flags_filename_process(struct 
AVFormatContext *s, HLSContext *hls
"Invalid second level segment filename template '%s', "
"you can try to remove second_level_segment_size 
flag\n",
vs->avf->url);
-av_free(filename);
-av_free(en);
+av_freep(&filename);
+av_freep(&en);
 return AVERROR(EINVAL);
 }
 ff_format_set_url(vs->avf, filename);
@@ -912,8 +912,8 @@ static int sls_flags_filename_process(struct 
AVFormatContext *s, HLSContext *hls
"Invalid second level segment filename template '%s', "
"you can try to remove second_level_segment_time 
flag\n",
vs->avf->url);
-av_free(filename);
-av_free(en);
+av_freep(&filename);
+av_freep(&en);
 return AVERROR(EINVAL);
 }
 ff_format_set_url(vs->avf, filename);
@@ -985,7 +985,7 @@ static int sls_flag_use_localtime_filename(AVFormatContext 
*oc, HLSContext *c, V
 av_log(c, AV_LOG_ERROR, "Invalid second level segment filename 
template '%s', "
 "you can try to remove second_level_segment_index flag\n",
oc->url);
-av_free(filename);
+av_freep(&filename);
 return AVERROR(EINVAL);
 }
 ff_format_set_url(oc, filename);
@@ -999,7 +999,7 @@ static int sls_flag_use_localtime_filename(AVFormatContext 
*oc, HLSContext *c, V
 av_log(c, AV_LOG_ERROR, "Invalid second level segment filename 
template '%s', "
 "you can try to remove second_level_segment_size 
flag\n",
oc->url);
-av_free(filename);
+av_freep(&filename);
 return AVERROR(EINVAL);
 }
 ff_format_set_url(oc, filename);
@@ -1010,7 +1010,7 @@ static int 
sls_flag_use_localtime_filename(AVFormatContext *oc, HLSContext *c, V
 av_log(c, AV_LOG_ERROR, "Invalid second level segment filename 
template '%s', "
 "you can try to remove second_level_segment_time 
flag\n",
oc->url);
-av_free(filename);
+av_freep(&filename);
 return AVERROR(EINVAL);
 }
 ff_format_set_url(oc, filename);
@@ -1098,7 +1098,7 @@ static int hls_append_segment(struct AVFormatContext *s, 
HLSContext *hls,
 if ((ret = hls_delete_old_segments(s, hls, vs)) < 0)
 return ret;
 } else
-av_free(en);
+av_freep(&en);
 } else
 vs->nb_entries++;
 
@@ -1207,7 +1207,7 @@ static void hls_free_segments(HLSSegment *p)
 while (p) {
 en = p;
 p = p->next;
-av_free(en);
+av_freep(&en);
 }
 }
 
@@ -1574,7 +1574,7 @@ static int hls_start(AVFormatContext *s, VariantS

[FFmpeg-devel] [PATCH v2 3/4] avformat/hlsenc: replace with av_dirname to get the directory

2019-09-16 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/hlsenc.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index d663785e4a..753addcbde 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -486,7 +486,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 float playlist_duration = 0.0f;
 int ret = 0, path_size, sub_path_size;
 int segment_cnt = 0;
-char *dirname = NULL, *p, *sub_path;
+char *dirname = NULL, *sub_path;
 char *path = NULL;
 char *vtt_dirname = NULL;
 AVDictionary *options = NULL;
@@ -517,13 +517,8 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 }
 
 if (segment && !hls->use_localtime_mkdir) {
-dirname = hls->segment_filename ? av_strdup(hls->segment_filename): 
av_strdup(vs->avf->url);
-if (!dirname) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-p = (char *)av_basename(dirname);
-*p = '\0';
+char *dirname_r = hls->segment_filename ? 
av_strdup(hls->segment_filename): av_strdup(vs->avf->url);
+dirname = (char*)av_dirname(dirname_r);
 }
 
 /* if %v is present in the file's directory
@@ -542,7 +537,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 }
 }
 
-av_free(dirname);
+av_freep(&dirname);
 dirname = r_dirname;
 }
 
@@ -578,13 +573,8 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 }
 
 if ((segment->sub_filename[0] != '\0')) {
-vtt_dirname = av_strdup(vs->vtt_avf->url);
-if (!vtt_dirname) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-p = (char *)av_basename(vtt_dirname);
-*p = '\0';
+char *vtt_dirname_r = av_strdup(vs->vtt_avf->url);
+vtt_dirname = (char*)av_dirname(vtt_dirname_r);
 sub_path_size = strlen(segment->sub_filename) + 1 + 
strlen(vtt_dirname);
 sub_path = av_malloc(sub_path_size);
 if (!sub_path) {
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH NV HEADERS] Add cuCtxGetDevice

2019-09-16 Thread Steve Lhomme

On 2019-09-13 11:56, Timo Rothenpieler wrote:

On 12/09/2019 15:19, Steve Lhomme wrote:
It can be useful to determine if the decoder context is the same as 
the display

context.

It's used in some samples at https://github.com/NVIDIA/video-sdk-samples
---
  include/ffnvcodec/dynlink_cuda.h   | 1 +
  include/ffnvcodec/dynlink_loader.h | 2 ++
  2 files changed, 3 insertions(+)



applied


Thanks !


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 2/2] avfilter: Add tonemap vaapi filter

2019-09-16 Thread Carl Eugen Hoyos
Am Mi., 11. Sept. 2019 um 23:02 Uhr schrieb Carl Eugen Hoyos
:
>
> Am Mi., 11. Sept. 2019 um 07:41 Uhr schrieb Zachary Zhou
> :
> >
> > It supports ICL platform.
> > H2H (HDR to HDR): P010 -> A2R10G10B10
> > H2S (HDR to SDR): P010 -> ARGB
>
> > +if (ctx->hdr_type == HDR_VAAPI_H2H) {
> > +vpp_ctx->output_format = AV_PIX_FMT_A2R10G10B10;
>
> I believe that even if you tell me that a conversion to planar on the
> gpu is impossible (why?), a slow C conversion still makes the filter
> more useful.

Ping.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 1/2] libavuitl: add A2R10G10B10 & A2B10G10R10

2019-09-16 Thread Carl Eugen Hoyos
Am Mi., 11. Sept. 2019 um 07:40 Uhr schrieb Zachary Zhou
:

> +AV_PIX_FMT_A2R10G10B10, ///< 10-bit Pixel RGB formats.
> +AV_PIX_FMT_A2B10G10R10, ///< 10-bit Pixel BGR formats.

Without more explanation, this patch is not ok imo.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] tools/target_dec_fuzzer: Adjust threshold for binkvideo

2019-09-16 Thread Peter Ross
On Sat, Sep 14, 2019 at 11:39:49PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (89sec -> 7sec)
> Fixes: 
> 17035/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINK_fuzzer-5737222422134784
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  tools/target_dec_fuzzer.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
> index 6fb53d5ab2..945f7a497c 100644
> --- a/tools/target_dec_fuzzer.c
> +++ b/tools/target_dec_fuzzer.c
> @@ -128,6 +128,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> size) {
>  maxpixels = maxpixels_per_frame * maxiteration;
>  switch (c->id) {
>  // Allows a small input to generate gigantic output
> +case AV_CODEC_ID_BINKVIDEO: maxpixels /= 32; break;
>  case AV_CODEC_ID_DIRAC: maxpixels /= 8192; break;
>  case AV_CODEC_ID_MSRLE: maxpixels /= 16;  break;
>  case AV_CODEC_ID_QTRLE: maxpixels /= 16;  break;
> -- 
> 2.23.0

approve

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 4/4] avformat/hlsenc: replace with av_freep for all av_free

2019-09-16 Thread Liu Steven


> 在 2019年9月16日,下午7:25,lance.lmw...@gmail.com 写道:
> 
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
> libavformat/hlsenc.c | 64 ++--
> 1 file changed, 32 insertions(+), 32 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 753addcbde..784a2b5ec0 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -590,7 +590,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
> HLSContext *hls,
> if ((ret = vs->vtt_avf->io_open(vs->vtt_avf, &out, sub_path, 
> AVIO_FLAG_WRITE, &options)) < 0) {
> if (hls->ignore_io_errors)
> ret = 0;
> -av_free(sub_path);
> +av_freep(&sub_path);
> goto fail;
> }
> ff_format_io_close(vs->vtt_avf, &out);
> @@ -598,18 +598,18 @@ static int hls_delete_old_segments(AVFormatContext *s, 
> HLSContext *hls,
> av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
> %s\n",
>sub_path, strerror(errno));
> }
> -av_free(sub_path);
> +av_freep(&sub_path);
> }
> av_freep(&path);
> previous_segment = segment;
> segment = previous_segment->next;
> -av_free(previous_segment);
> +av_freep(&previous_segment);
> }
> 
> fail:
> -av_free(path);
> -av_free(dirname);
> -av_free(vtt_dirname);
> +av_freep(&path);
> +av_freep(&dirname);
> +av_freep(&vtt_dirname);
> 
> return ret;
> }
> @@ -887,7 +887,7 @@ static int sls_flags_filename_process(struct 
> AVFormatContext *s, HLSContext *hls
> strlen(vs->current_segment_final_filename_fmt)) {
> char * new_url = av_strdup(vs->current_segment_final_filename_fmt);
> if (!new_url) {
> -av_free(en);
> +av_freep(&en);
> return AVERROR(ENOMEM);
> }
> ff_format_set_url(vs->avf, new_url);
> @@ -898,8 +898,8 @@ static int sls_flags_filename_process(struct 
> AVFormatContext *s, HLSContext *hls
>"Invalid second level segment filename template '%s', "
>"you can try to remove second_level_segment_size 
> flag\n",
>vs->avf->url);
> -av_free(filename);
> -av_free(en);
> +av_freep(&filename);
> +av_freep(&en);
> return AVERROR(EINVAL);
> }
> ff_format_set_url(vs->avf, filename);
> @@ -912,8 +912,8 @@ static int sls_flags_filename_process(struct 
> AVFormatContext *s, HLSContext *hls
>"Invalid second level segment filename template '%s', "
>"you can try to remove second_level_segment_time 
> flag\n",
>vs->avf->url);
> -av_free(filename);
> -av_free(en);
> +av_freep(&filename);
> +av_freep(&en);
> return AVERROR(EINVAL);
> }
> ff_format_set_url(vs->avf, filename);
> @@ -985,7 +985,7 @@ static int 
> sls_flag_use_localtime_filename(AVFormatContext *oc, HLSContext *c, V
> av_log(c, AV_LOG_ERROR, "Invalid second level segment filename 
> template '%s', "
> "you can try to remove second_level_segment_index flag\n",
>oc->url);
> -av_free(filename);
> +av_freep(&filename);
> return AVERROR(EINVAL);
> }
> ff_format_set_url(oc, filename);
> @@ -999,7 +999,7 @@ static int 
> sls_flag_use_localtime_filename(AVFormatContext *oc, HLSContext *c, V
> av_log(c, AV_LOG_ERROR, "Invalid second level segment 
> filename template '%s', "
> "you can try to remove second_level_segment_size 
> flag\n",
>oc->url);
> -av_free(filename);
> +av_freep(&filename);
> return AVERROR(EINVAL);
> }
> ff_format_set_url(oc, filename);
> @@ -1010,7 +1010,7 @@ static int 
> sls_flag_use_localtime_filename(AVFormatContext *oc, HLSContext *c, V
> av_log(c, AV_LOG_ERROR, "Invalid second level segment 
> filename template '%s', "
> "you can try to remove second_level_segment_time 
> flag\n",
>oc->url);
> -av_free(filename);
> +av_freep(&filename);
> return AVERROR(EINVAL);
> }
> ff_format_set_url(oc, filename);
> @@ -1098,7 +1098,7 @@ static int hls_append_segment(struct AVFormatContext 
> *s, HLSContext *hls,
> if ((ret = hls_delete_old_segments(s, hls, vs)) < 0)
> return ret;
> } else
> -av_free(en);
> +av_freep(&en);
> } else
> vs->nb_entries++;
> 
> @

Re: [FFmpeg-devel] [PATCH v2 2/4] avformat/hlsenc: remove the unnecessary null pointer check

2019-09-16 Thread Liu Steven


> 在 2019年9月16日,下午7:25,lance.lmw...@gmail.com 写道:
> 
> From: Limin Wang 
> 
> Reviewed-by: Liu Steven 
> Signed-off-by: Limin Wang 
> ---
> libavformat/hlsenc.c | 26 ++
> 1 file changed, 2 insertions(+), 24 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 1f2bdfbe4d..d663785e4a 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1613,16 +1613,13 @@ static int hls_start(AVFormatContext *s, 
> VariantStream *vs)
> if (c->use_localtime_mkdir) {
> const char *dir;
> char *fn_copy = av_strdup(oc->url);
> -if (!fn_copy) {
> -return AVERROR(ENOMEM);
> -}
> dir = av_dirname(fn_copy);
> if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
> av_log(oc, AV_LOG_ERROR, "Could not create directory %s 
> with use_localtime_mkdir\n", dir);
> -av_free(fn_copy);
> +av_freep(&fn_copy);
> return AVERROR(errno);
> }
> -av_free(fn_copy);
> +av_freep(&fn_copy);
> }
> } else {
> char *filename = NULL;
> @@ -1784,11 +1781,6 @@ static int validate_name(int nb_vs, const char *fn)
> }
> 
> fn_dup = av_strdup(fn);
> -if (!fn_dup) {
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> -
> filename = av_basename(fn);
> subdir_name = av_dirname(fn_dup);
> 
> @@ -1846,11 +1838,6 @@ static int format_name(const char *buf, char **s, int 
> index, const char *varname
> /* if %v is present in the file's directory, create sub-directory */
> if (av_stristr(dir, "%v") && proto && !strcmp(proto, "file")) {
> mod_buf_dup = av_strdup(*s);
> -if (!mod_buf_dup) {
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> -
> dir = av_dirname(mod_buf_dup);
> if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
> ret = AVERROR(errno);
> @@ -2151,11 +2138,6 @@ static int update_master_pl_info(AVFormatContext *s)
> int ret = 0;
> 
> fn1 = av_strdup(s->url);
> -if (!fn1) {
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> -
> dir = av_dirname(fn1);
> 
> /**
> @@ -2164,10 +2146,6 @@ static int update_master_pl_info(AVFormatContext *s)
>  */
> if (dir && av_stristr(av_basename(dir), "%v")) {
> fn2 = av_strdup(dir);
> -if (!fn2) {
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> dir = av_dirname(fn2);
> }
> 
> -- 
> 2.21.0
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


No, they need null pointer check, becase there have http protocol, i have paste 
the output in the last version patch.


Thanks
Steven

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 2/4] avformat/hlsenc: remove the unnecessary null pointer check

2019-09-16 Thread Steven Liu


> 在 2019年9月16日,20:06,Liu Steven  写道:
> 
> 
> 
>> 在 2019年9月16日,下午7:25,lance.lmw...@gmail.com 写道:
>> 
>> From: Limin Wang 
>> 
>> Reviewed-by: Liu Steven 
>> Signed-off-by: Limin Wang 
>> ---
>> libavformat/hlsenc.c | 26 ++
>> 1 file changed, 2 insertions(+), 24 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 1f2bdfbe4d..d663785e4a 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -1613,16 +1613,13 @@ static int hls_start(AVFormatContext *s, 
>> VariantStream *vs)
>>if (c->use_localtime_mkdir) {
>>const char *dir;
>>char *fn_copy = av_strdup(oc->url);
>> -if (!fn_copy) {
>> -return AVERROR(ENOMEM);
>> -}
>>dir = av_dirname(fn_copy);
>>if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
>>av_log(oc, AV_LOG_ERROR, "Could not create directory %s 
>> with use_localtime_mkdir\n", dir);
>> -av_free(fn_copy);
>> +av_freep(&fn_copy);
>>return AVERROR(errno);
>>}
>> -av_free(fn_copy);
>> +av_freep(&fn_copy);
>>}
>>} else {
>>char *filename = NULL;
>> @@ -1784,11 +1781,6 @@ static int validate_name(int nb_vs, const char *fn)
>>}
>> 
>>fn_dup = av_strdup(fn);
>> -if (!fn_dup) {
>> -ret = AVERROR(ENOMEM);
>> -goto fail;
>> -}
>> -
>>filename = av_basename(fn);
>>subdir_name = av_dirname(fn_dup);
>> 
>> @@ -1846,11 +1838,6 @@ static int format_name(const char *buf, char **s, int 
>> index, const char *varname
>>/* if %v is present in the file's directory, create sub-directory */
>>if (av_stristr(dir, "%v") && proto && !strcmp(proto, "file")) {
>>mod_buf_dup = av_strdup(*s);
>> -if (!mod_buf_dup) {
>> -ret = AVERROR(ENOMEM);
>> -goto fail;
>> -}
>> -
>>dir = av_dirname(mod_buf_dup);
>>if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
>>ret = AVERROR(errno);
>> @@ -2151,11 +2138,6 @@ static int update_master_pl_info(AVFormatContext *s)
>>int ret = 0;
>> 
>>fn1 = av_strdup(s->url);
>> -if (!fn1) {
>> -ret = AVERROR(ENOMEM);
>> -goto fail;
>> -}
>> -
>>dir = av_dirname(fn1);
>> 
>>/**
>> @@ -2164,10 +2146,6 @@ static int update_master_pl_info(AVFormatContext *s)
>> */
>>if (dir && av_stristr(av_basename(dir), "%v")) {
>>fn2 = av_strdup(dir);
>> -if (!fn2) {
>> -ret = AVERROR(ENOMEM);
>> -goto fail;
>> -}
>>dir = av_dirname(fn2);
>>}
>> 
>> -- 
>> 2.21.0
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 
> 
> No, they need null pointer check, becase there have http protocol, i have 
> paste the output in the last version patch.
Ah, i have re check it again, it’s ok.
> 
> 
> Thanks
> Steven
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Thanks
Steven





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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/5] lavc/hevc_ps: parse constraint flags for HEVC REXT

2019-09-16 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Carl Eugen Hoyos
> Sent: Monday, September 16, 2019 18:06
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 2/5] lavc/hevc_ps: parse constraint flags
> for HEVC REXT
> 
> Am Mo., 16. Sept. 2019 um 09:35 Uhr schrieb Linjie Fu :
> >
> > Parse all the constraint flags according to ITU-T Rec. H.265 (02/2018).
> 
> > It can be passed to hw decoders to determine the exact profile for
> > Range Extension HEVC.
> 
> I am not a native speaker but I believe this should be more like:
> They are needed at least for some hw decoders
> or
> They have to be passed to hw decoders
> 
> Or are the flags not really "needed" for vaapi?
> 
These flags are needed for VAAPI.
And it could be emphasized in the commit message to make it more clear.

- linjie

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/5] lavc/vaapi_decode: add profile_parser and format map support for HEVC REXT

2019-09-16 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Carl Eugen Hoyos
> Sent: Monday, September 16, 2019 18:14
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 4/5] lavc/vaapi_decode: add
> profile_parser and format map support for HEVC REXT
> 
> Am Mo., 16. Sept. 2019 um 09:36 Uhr schrieb Linjie Fu :
> >
> > Add function pointer field in vaapi_profile_map[], set profile_parser
> > for HEVC_REXT to find the exact va_profile.
> >
> > Also add format map support.
> 
> Please remove all cosmetic changes from this patch.
> 
Did the "cosmetic changes" refer to the elimination of a blank line in the file 
header?

#include "vaapi_decode.h"
-
+#include "vaapi_hevc.h"

Yes, this could be avoided.
And is there anything else I missed?

- linjie
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] doc: fix various spelling mistakes

2019-09-16 Thread Moritz Barsnick
On Sun, Sep 15, 2019 at 09:59:49 +0530, Gyan wrote:
> On 15-09-2019 01:41 AM, Moritz Barsnick wrote:
> >   @item lp
> > -Lowpass lines prior further proccessing. Default is disabled.
> > +Lowpass lines prior further processing. Default is disabled.
>
> "Lowpass lines prior to further ..."

I only meant to fix spelling (quickly), not such grammar. ;-) We can
make quite a big issue about grammar.

But since it's in a line which is being modified anyway, sure, why not.
Shall I refine the patch?

> Rest LGTM.

Thanks,
Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/5] lavc/vaapi_decode: add profile_parser and format map support for HEVC REXT

2019-09-16 Thread Carl Eugen Hoyos
Am Mo., 16. Sept. 2019 um 16:01 Uhr schrieb Fu, Linjie :
>
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> > Of Carl Eugen Hoyos
> > Sent: Monday, September 16, 2019 18:14
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH 4/5] lavc/vaapi_decode: add
> > profile_parser and format map support for HEVC REXT
> >
> > Am Mo., 16. Sept. 2019 um 09:36 Uhr schrieb Linjie Fu :
> > >
> > > Add function pointer field in vaapi_profile_map[], set profile_parser
> > > for HEVC_REXT to find the exact va_profile.
> > >
> > > Also add format map support.
> >
> > Please remove all cosmetic changes from this patch.
> >
> Did the "cosmetic changes" refer to the elimination of a blank line in the 
> file header?
>
> #include "vaapi_decode.h"
> -
> +#include "vaapi_hevc.h"
>
> Yes, this could be avoided.

> And is there anything else I missed?

No, it was my mistake although I wonder if the
patch could be split to allow seeing the actual change
(but that may only be me),

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodecc/dnxhddec: fix ACT checking

2019-09-16 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/dnxhddec.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 1e95086696..512accadfd 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -499,19 +499,17 @@ static int dnxhd_decode_macroblock(const DNXHDContext 
*ctx, RowContext *row,
 qscale = get_bits(&row->gb, 11);
 }
 act = get_bits1(&row->gb);
-if (act) {
-if (!ctx->act) {
-static int act_warned;
-if (!act_warned) {
-act_warned = 1;
-av_log(ctx->avctx, AV_LOG_ERROR,
-   "ACT flag set, in violation of frame header.\n");
-}
-} else if (row->format == -1) {
-row->format = act;
-} else if (row->format != act) {
-row->format = 2; // Variable
+if (ctx->act != act) {
+static int act_warned;
+if (!act_warned) {
+act_warned = 1;
+av_log(ctx->avctx, AV_LOG_ERROR,
+   "ACT flag set, in violation of frame header.\n");
 }
+} else if (row->format == -1) {
+row->format = act;
+} else if (row->format != act) {
+row->format = 2; // Variable
 }
 
 if (qscale != row->last_qscale) {
-- 
2.17.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/5] avutil/encryption_info: Don't pass NULL to memcpy

2019-09-16 Thread Andreas Rheinhardt
The pointer arguments to memcpy (and several other functions of the
C standard library) are not allowed to be NULL, not even when the number
of bytes to copy is zero. An AVEncryptionInitInfo's data pointer is
explicitly allowed to be NULL and yet av_encryption_init_info_add_side_data
uncoditionally used it as a source pointer to copy from. This commit changes
this so that copying is only done if the number of bytes to copy is > 0.

Fixes ticket #8141 as well as a part of ticket #8150.

Signed-off-by: Andreas Rheinhardt 
---
 libavutil/encryption_info.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavutil/encryption_info.c b/libavutil/encryption_info.c
index 812c704776..614791f2af 100644
--- a/libavutil/encryption_info.c
+++ b/libavutil/encryption_info.c
@@ -331,7 +331,8 @@ uint8_t *av_encryption_init_info_add_side_data(const 
AVEncryptionInitInfo *info,
 memcpy(cur_buffer, cur_info->key_ids[i], cur_info->key_id_size);
 cur_buffer += cur_info->key_id_size;
 }
-memcpy(cur_buffer, cur_info->data, cur_info->data_size);
+if (cur_info->data_size > 0)
+memcpy(cur_buffer, cur_info->data, cur_info->data_size);
 cur_buffer += cur_info->data_size;
 }
 
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 5/5] avformat/utils: Fix always true check

2019-09-16 Thread Andreas Rheinhardt
Found via PVS-Studio (ticket #8156).

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index b83a740500..1cd7aa211c 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4837,7 +4837,7 @@ int ff_mkdir_p(const char *path)
 }
 }
 
-if ((*(pos - 1) != '/') || (*(pos - 1) != '\\')) {
+if ((*(pos - 1) != '/') && (*(pos - 1) != '\\')) {
 ret = mkdir(temp, 0755);
 }
 
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 4/5] fftools/ffmpeg_opt: Fix signed integer overflow

2019-09-16 Thread Andreas Rheinhardt
Fixes ticket #8154.

Signed-off-by: Andreas Rheinhardt 
---
 fftools/ffmpeg_opt.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index f5ca18aa64..b2aa63e7ee 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1,3 +1,4 @@
+
 /*
  * ffmpeg option parsing
  *
@@ -2769,13 +2770,14 @@ static int opt_target(void *optctx, const char *opt, 
const char *arg)
 } else {
 /* Try to determine PAL/NTSC by peeking in the input files */
 if (nb_input_files) {
-int i, j, fr;
+int i, j;
 for (j = 0; j < nb_input_files; j++) {
 for (i = 0; i < input_files[j]->nb_streams; i++) {
 AVStream *st = input_files[j]->ctx->streams[i];
+int64_t fr;
 if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
 continue;
-fr = st->time_base.den * 1000 / st->time_base.num;
+fr = st->time_base.den * 1000LL / st->time_base.num;
 if (fr == 25000) {
 norm = PAL;
 break;
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/5] avformat/mov: Fix memleak

2019-09-16 Thread Andreas Rheinhardt
When the mov/mp4 demuxer encounters an error during decrypting a packet,
it returns the error, yet doesn't free the packet, so that the packet
leaks. This has been fixed in this commit.

Fixes the memleaks from ticket #8150.

Signed-off-by: Andreas Rheinhardt 
---
This only fixes the memleaks from #8150. I can't reproduce the
uninitialized reads, so I can't do anything about them. Can someone else
reproduce them?

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 675b915906..cd3f5bffcf 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7843,8 +7843,10 @@ static int mov_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 aax_filter(pkt->data, pkt->size, mov);
 
 ret = cenc_filter(mov, st, sc, pkt, current_index);
-if (ret < 0)
+if (ret < 0) {
+av_packet_unref(pkt);
 return ret;
+}
 
 return 0;
 }
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/5] libavformat/mov: Improve demuxing DV audio

2019-09-16 Thread Andreas Rheinhardt
The code for demuxing DV audio predates the introduction of refcounted
packets and when the latter was added, changes to the former were
forgotten. This meant that when avpriv_dv_produce_packet initialized the
packet containing the AVBufferRef, the AVBufferRef as well as the
underlying AVBuffer leaked; the actual packet data didn't leak: They
were directly freed, but not via their AVBuffer's free function.

Moreover, errors in avpriv_dv_produce_packet were ignored; this has been
changed, too.

Furthermore, in the hypothetical scenario that the track has a palette,
this would leak, too, so reorder the code so that the palette code
appears after the DV audio code.

Signed-off-by: Andreas Rheinhardt 
---
Completely untested as I don't have a sample for it. I also don't think
that a dv audio stream can have a palette, but better safe than sorry.

 libavformat/mov.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index cd3f5bffcf..885b5f2485 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7766,6 +7766,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 return ret;
 }
+#if CONFIG_DV_DEMUXER
+if (mov->dv_demux && sc->dv_audio_container) {
+AVBufferRef *buf = pkt->buf;
+ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, 
pkt->size, pkt->pos);
+pkt->buf = buf;
+av_packet_unref(pkt);
+if (ret < 0)
+return ret;
+ret = avpriv_dv_get_packet(mov->dv_demux, pkt);
+if (ret < 0)
+return ret;
+}
+#endif
 if (sc->has_palette) {
 uint8_t *pal;
 
@@ -,16 +7790,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 sc->has_palette = 0;
 }
 }
-#if CONFIG_DV_DEMUXER
-if (mov->dv_demux && sc->dv_audio_container) {
-avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, 
pkt->pos);
-av_freep(&pkt->data);
-pkt->size = 0;
-ret = avpriv_dv_get_packet(mov->dv_demux, pkt);
-if (ret < 0)
-return ret;
-}
-#endif
 if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && 
pkt->size > 4) {
 if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0)
 st->need_parsing = AVSTREAM_PARSE_FULL;
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] doc: fix various spelling mistakes

2019-09-16 Thread Gyan



On 16-09-2019 07:50 PM, Moritz Barsnick wrote:

On Sun, Sep 15, 2019 at 09:59:49 +0530, Gyan wrote:

On 15-09-2019 01:41 AM, Moritz Barsnick wrote:

   @item lp
-Lowpass lines prior further proccessing. Default is disabled.
+Lowpass lines prior further processing. Default is disabled.

"Lowpass lines prior to further ..."

I only meant to fix spelling (quickly), not such grammar. ;-) We can
make quite a big issue about grammar.

But since it's in a line which is being modified anyway, sure, why not.
Shall I refine the patch?


Yes, please.

Gyan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/allcodecs: make libdav1d the preferred AV1 decoder

2019-09-16 Thread James Almer
On 9/15/2019 11:31 AM, James Almer wrote:
> It's considerably faster than libaom in most systems.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/allcodecs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 5130fca026..d5dfba1877 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -680,7 +680,6 @@ extern AVCodec ff_pcm_mulaw_at_encoder;
>  extern AVCodec ff_pcm_mulaw_at_decoder;
>  extern AVCodec ff_qdmc_at_decoder;
>  extern AVCodec ff_qdm2_at_decoder;
> -extern AVCodec ff_libaom_av1_decoder;
>  extern AVCodec ff_libaom_av1_encoder;
>  extern AVCodec ff_libaribb24_decoder;
>  extern AVCodec ff_libcelt_decoder;
> @@ -738,6 +737,7 @@ extern AVCodec ff_idf_decoder;
>  /* external libraries, that shouldn't be used by default if one of the
>   * above is available */
>  extern AVCodec ff_h263_v4l2m2m_encoder;
> +extern AVCodec ff_libaom_av1_decoder;
>  extern AVCodec ff_libopenh264_encoder;
>  extern AVCodec ff_libopenh264_decoder;
>  extern AVCodec ff_h264_amf_encoder;
> 

Approved on IRC by Ronald, and pushed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH]lavc/g729dec: Support decoding ACELP.KELVIN

2019-09-16 Thread Carl Eugen Hoyos
Am Fr., 23. Aug. 2019 um 09:14 Uhr schrieb Paul B Mahol :
>
> allcodecs.c entry is in wrong section, it should be audio one but yours is
> in video section.
> the avcodec.h entry may contradict with next libav entry so better move it
> bellow hcom.

Pushed with these changes.

Thank you!

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 2/5] avcodec/v210enc: make 8bit and 10bit function consistent

2019-09-16 Thread Michael Niedermayer
On Sun, Sep 01, 2019 at 09:20:20PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> I have benchmarked the performance with c code and haven't see any
> performance impact.
> 
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/v210enc.c | 7 +--
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
> index 1b840b2..69a2efe 100644
> --- a/libavcodec/v210enc.c
> +++ b/libavcodec/v210enc.c
> @@ -43,12 +43,7 @@ static void v210_planar_pack_8_c(const uint8_t *y, const 
> uint8_t *u,
>  uint32_t val;
>  int i;
>  
> -/* unroll this to match the assembly */
> -for (i = 0; i < width - 11; i += 12) {
> -WRITE_PIXELS(u, y, v, 8);
> -WRITE_PIXELS(y, u, y, 8);
> -WRITE_PIXELS(v, y, u, 8);
> -WRITE_PIXELS(y, v, y, 8);
> +for (i = 0; i < width - 5; i += 6) {
>  WRITE_PIXELS(u, y, v, 8);
>  WRITE_PIXELS(y, u, y, 8);
>  WRITE_PIXELS(v, y, u, 8);

I have retested this with START/STOP_TIMER
and the more unrolled loop is consistently faster

./ffmpeg -cpuflags 0 -v 99 -i matrixbench_mpeg2.mpg -vcodec v210 -an test.avi

 31620 decicycles in TEST, 2096691 runs,461 skips  0  0  0  0  0  0  0  0  
0  0  0 21 13  9  8  7  8  7  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 31509 decicycles in TEST, 2096892 runs,260 skips  0  0  0  0  0  0  0  0  
0  0  0 21 10  9  8  6  7  3  2  0  0  0  0  0  0  0  0  0  0  0  0  0
 32069 decicycles in TEST, 2096965 runs,187 skips  0  0  0  0  0  0  0  0  
0  0  0 21 16 10  8  6  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 31522 decicycles in TEST, 2096962 runs,190 skips  0  0  0  0  0  0  0  0  
0  0  0 21 10  9  8  6  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 31537 decicycles in TEST, 2096784 runs,368 skips  0  0  0  0  0  0  0  0  
0  0  0 21 12  8  9  7  7  7  0  0  0  0  0  0  0  0  0  0  0  0  0  0

prev:
 30705 decicycles in TEST, 2096875 runs,277 skips  0  0  0  0  0  0  0  0  
0  0  0 21 15  9  9  7  5  3  1  0  0  0  0  0  0  0  0  0  0  0  0  0
 30771 decicycles in TEST, 2096907 runs,245 skips  0  0  0  0  0  0  0  0  
0  0  0 21 15  9  8  6  7  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 30560 decicycles in TEST, 2096904 runs,248 skips  0  0  0  0  0  0  0  0  
0  0  0 21 10  9  9  6  2  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 31020 decicycles in TEST, 2096974 runs,178 skips  0  0  0  0  0  0  0  0  
0  0  0 21 16  9  8  6  2  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 31018 decicycles in TEST, 2096980 runs,172 skips  0  0  0  0  0  0  0  0  
0  0  0 21 16  9  8  6  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/4] avutil/avstring: support input path is a null pointer or empty string

2019-09-16 Thread Michael Niedermayer
On Mon, Sep 16, 2019 at 07:25:13PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Reviewed-by: Tomas Härdin 
> Reviewed-by: Liu Steven 
> Signed-off-by: Limin Wang 
> ---
>  libavutil/avstring.c | 12 
>  libavutil/avstring.h | 13 +
>  2 files changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/libavutil/avstring.c b/libavutil/avstring.c
> index 4c068f5bc5..551ca5daee 100644
> --- a/libavutil/avstring.c
> +++ b/libavutil/avstring.c
> @@ -257,8 +257,12 @@ char *av_strireplace(const char *str, const char *from, 
> const char *to)
>  
>  const char *av_basename(const char *path)
>  {
> -char *p = strrchr(path, '/');
> +char *p = NULL;

the NULL assignment is unneeded


> +
> +if (!path || *path == '\0')
> +return ".";
>  
> +p = strrchr(path, '/');


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/ttaenc: Fix undefined shift

2019-09-16 Thread Michael Niedermayer
On Mon, Sep 16, 2019 at 10:16:36AM +0200, Paul B Mahol wrote:
> LGTM

will apply

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/8] avformat/utils: Fix memleaks

2019-09-16 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> ff_read_packet had several potential memleaks:
> 1. If av_packet_make_refcounted fails, it means that the packet is not
> refcounted, but it could nevertheless carry side data and therefore
> needs to be unreferenced.
> 2. If a packet happens to have an illegal stream index (i.e. one that
> does not correspond to a stream), it should nevertheless be
> unreferenced.
> 3. If putting a packet on a packet list fails, it wasn't unreferenced.
> 
> Furthermore, read_frame_internal leaked a packet's (side) data if a
> context update was required and failed.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> The two memleaks in read_frame_internal have been added in v2.
> 
>  libavformat/utils.c | 17 +
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index b57e680089..564be02334 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -873,8 +873,10 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
>  }
>  
>  err = av_packet_make_refcounted(pkt);
> -if (err < 0)
> +if (err < 0) {
> +av_packet_unref(pkt);
>  return err;
> +}
>  
>  if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT) &&
>  (pkt->flags & AV_PKT_FLAG_CORRUPT)) {
> @@ -887,6 +889,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
>  
>  if (pkt->stream_index >= (unsigned)s->nb_streams) {
>  av_log(s, AV_LOG_ERROR, "Invalid stream index %d\n", 
> pkt->stream_index);
> +av_packet_unref(pkt);
>  continue;
>  }
>  
> @@ -917,8 +920,10 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
>  err = ff_packet_list_put(&s->internal->raw_packet_buffer,
>   &s->internal->raw_packet_buffer_end,
>   pkt, 0);
> -if (err)
> +if (err < 0) {
> +av_packet_unref(pkt);
>  return err;
> +}
>  s->internal->raw_packet_buffer_remaining_size -= pkt->size;
>  
>  if ((err = probe_codec(s, st, pkt)) < 0)
> @@ -1611,15 +1616,19 @@ static int read_frame_internal(AVFormatContext *s, 
> AVPacket *pkt)
>  }
>  
>  ret = avcodec_parameters_to_context(st->internal->avctx, 
> st->codecpar);
> -if (ret < 0)
> +if (ret < 0) {
> +av_packet_unref(&cur_pkt);
>  return ret;
> +}
>  
>  #if FF_API_LAVF_AVCTX
>  FF_DISABLE_DEPRECATION_WARNINGS
>  /* update deprecated public codec context */
>  ret = avcodec_parameters_to_context(st->codec, st->codecpar);
> -if (ret < 0)
> +if (ret < 0) {
> +av_packet_unref(&cur_pkt);
>  return ret;
> +}
>  FF_ENABLE_DEPRECATION_WARNINGS
>  #endif
>  
> 
Ping for the whole patchset. Notice that the commit message of #7
contains a typo; [1] is a fixed version.

- Andreas

[1]:
https://ffmpeg.org/pipermail/ffmpeg-devel/2019-September/249683.html
(Patchwork: https://patchwork.ffmpeg.org/patch/14991/)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 1/5] avcodec/v210enc: add depth parameter for WRITE_PIXELS and CLIP

2019-09-16 Thread Michael Niedermayer
On Mon, Sep 16, 2019 at 07:11:06PM +0800, Limin Wang wrote:
> On Mon, Sep 16, 2019 at 12:05:45PM +0200, Michael Niedermayer wrote:
> > On Thu, Sep 12, 2019 at 11:32:32PM +0800, Limin Wang wrote:
> > > 
> > > ping for the patchset.
> > 
> > output support for swscale would simplify testing
> > 
> > ./ffplay matrixbench_mpeg2.mpg -vf format=y210
> > ...
> > Impossible to convert between the formats supported by the filter 
> > 'ffplay_buffer' and the filter 'auto_scaler_0'
> > 
> Sorry, I haven't catch what's your intention. 
> v210 is packed format, if we want to play *.v210 file, you can play by below
> command:
> ./ffplay -s 3840x2160  ~/Movies/1.v210
> 
> or force to convertto yuv420p:
> ./ffplay -s 3840x2160  ~/Movies/1.v210 -vf format=yuv420p
> 
> For v210 in AVI, we can play it directly:
> ffplay ../fate-suite/v210/v210_720p-partial.avi

v210dec produces yuv422p10le unless i missed a patch not the v210 format so 
that doesnt work for testing the v210 pixel format

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 5/5] avcodec/v210enc: move the duplicate code to template file

2019-09-16 Thread Michael Niedermayer
On Mon, Sep 16, 2019 at 07:17:52PM +0800, Limin Wang wrote:
> On Mon, Sep 16, 2019 at 12:21:36PM +0200, Michael Niedermayer wrote:
> > On Sun, Sep 01, 2019 at 09:20:23PM +0800, lance.lmw...@gmail.com wrote:
> > > From: Limin Wang 
> > > 
> > > Signed-off-by: Limin Wang 
> > > ---
> > >  libavcodec/v210_template.c |  59 +-
> > >  libavcodec/v210enc.c   | 123 
> > > +++--
> > >  2 files changed, 75 insertions(+), 107 deletions(-)
> > 
> > [PATCH v3 3/5] avcodec/v210enc: move the duplicate code to template file
> > [PATCH v3 5/5] avcodec/v210enc: move the duplicate code to template file
> > 
> > why do 2 patches have the same first line in the commit message ?
> It's for split the patch for review, 3/5 is move v210_planar_pack, 5/5 is 
> moving 
> v210enc related function, so the code is different.

If the same description is good for different changes then the description
is not very good (not specific enough) IMO

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2] Add option to log timing

2019-09-16 Thread Soft Works
This commit adds two logging flags: 'timing' and 'datetiming'.

Usage:

ffmpeg -loglevel +timing

or

ffmpeg -loglevel +datetiming
---
 fftools/cmdutils.c | 14 ++
 libavutil/log.c| 37 -
 libavutil/log.h| 10 ++
 3 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index fdcd376b76..7805058f8b 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -912,6 +912,20 @@ int opt_loglevel(void *optctx, const char *opt, const char 
*arg)
 flags |= AV_LOG_PRINT_LEVEL;
 }
 arg = token + 5;
+} else if (!strncmp(token, "timing", 6)) {
+if (cmd == '-') {
+flags &= ~AV_LOG_PRINT_TIME;
+} else {
+flags |= AV_LOG_PRINT_TIME;
+}
+arg = token + 6;
+} else if (!strncmp(token, "datetiming", 10)) {
+if (cmd == '-') {
+flags &= ~AV_LOG_PRINT_DATETIME;
+} else {
+flags |= AV_LOG_PRINT_DATETIME;
+}
+arg = token + 10;
 } else {
 break;
 }
diff --git a/libavutil/log.c b/libavutil/log.c
index 93a156b8e4..16a1d13d1d 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -40,6 +40,8 @@
 #include "internal.h"
 #include "log.h"
 #include "thread.h"
+#include "time.h"
+#include "time_internal.h"
 
 static AVMutex mutex = AV_MUTEX_INITIALIZER;
 
@@ -243,14 +245,32 @@ static const char *get_level_str(int level)
 }
 }
 
+static void format_date_now(AVBPrint* timeBuf, int include_date)
+{
+struct tm *ptm, tmbuf;
+int64_t time_us = av_gettime();
+int64_t time_ms = time_us / 1000;
+const time_t time_s = time_ms / 1000;
+int millisec = time_ms - (time_s * 1000);
+ptm = localtime_r(&time_s, &tmbuf);
+if (ptm) {
+if (include_date)
+av_bprint_strftime(timeBuf, "%Y-%m-%d ", ptm);
+
+av_bprint_strftime(timeBuf, "%H:%M:%S", ptm);
+av_bprintf(timeBuf, ".%03d ", millisec);
+}
+}
+
 static void format_line(void *avcl, int level, const char *fmt, va_list vl,
-AVBPrint part[4], int *print_prefix, int type[2])
+AVBPrint part[5], int *print_prefix, int type[2])
 {
 AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
 av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(part+3, 0, 65536);
+av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC);
 
 if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
 if (*print_prefix && avc) {
@@ -268,6 +288,10 @@ static void format_line(void *avcl, int level, const char 
*fmt, va_list vl,
 if(type) type[1] = get_category(avcl);
 }
 
+if (*print_prefix
+&& ((flags & AV_LOG_PRINT_TIME) || (flags & AV_LOG_PRINT_DATETIME)))
+format_date_now(&part[4], flags & AV_LOG_PRINT_DATETIME);
+
 if (*print_prefix && (level > AV_LOG_QUIET) && (flags & 
AV_LOG_PRINT_LEVEL))
 av_bprintf(part+2, "[%s] ", get_level_str(level));
 
@@ -288,12 +312,12 @@ void av_log_format_line(void *ptr, int level, const char 
*fmt, va_list vl,
 int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
 char *line, int line_size, int *print_prefix)
 {
-AVBPrint part[4];
+AVBPrint part[5];
 int ret;
 
 format_line(ptr, level, fmt, vl, part, print_prefix, NULL);
 ret = snprintf(line, line_size, "%s%s%s%s", part[0].str, part[1].str, 
part[2].str, part[3].str);
-av_bprint_finalize(part+3, NULL);
+av_bprint_finalize(part+4, NULL);
 return ret;
 }
 
@@ -302,7 +326,7 @@ void av_log_default_callback(void* ptr, int level, const 
char* fmt, va_list vl)
 static int print_prefix = 1;
 static int count;
 static char prev[LINE_SZ];
-AVBPrint part[4];
+AVBPrint part[5];
 char line[LINE_SZ];
 static int is_atty;
 int type[2];
@@ -337,6 +361,9 @@ void av_log_default_callback(void* ptr, int level, const 
char* fmt, va_list vl)
 count = 0;
 }
 strcpy(prev, line);
+
+sanitize(part[4].str);
+colored_fputs(7, 0, part[4].str);
 sanitize(part[0].str);
 colored_fputs(type[0], 0, part[0].str);
 sanitize(part[1].str);
@@ -351,7 +378,7 @@ void av_log_default_callback(void* ptr, int level, const 
char* fmt, va_list vl)
 VALGRIND_PRINTF_BACKTRACE("%s", "");
 #endif
 end:
-av_bprint_finalize(part+3, NULL);
+av_bprint_finalize(part+4, NULL);
 ff_mutex_unlock(&mutex);
 }
 
diff --git a/libavutil/log.h b/libavutil/log.h
index d9554e609d..34ccded4bc 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -352,6 +352,16 @@ int av_log_format_line2(void *ptr, int level, const char 
*fmt, va_list vl,
  */
 #define AV_LOG_PRINT_LEVEL 2
 
+/**
+ * Include system time in log output

[FFmpeg-devel] Is it ok to add G.722.1 decoder as external lib?

2019-09-16 Thread Hyun Yoo
I implemented a g.722.1 decoder by linking FreeSwitch's libg722_1
as external lib like libilbc, libspeex(ex. configure --enable-libg722_1)
(https://github.com/traviscross/freeswitch/tree/master/libs/libg722_1)

But I'm not sure about the license issue
because g.722.1 is licensed by Polycom(royalty-free)

Getting permission is my(commiter) job? or user(who link and compile)'s job?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] Fix gif decoder max option

2019-09-16 Thread Soft Works
An int32 option cannot have a maximum of UINT32_MAX

Before this patch
  -trans_color   .D.V. color value (ARGB) that is used 
instead of transparent color (from 0 to UINT32_MAX)

Afterwards:
  -trans_color   .D.V. color value (ARGB) that is used 
instead of transparent color (from 0 to INT_MAX)
Signed-off-by: softworkz 
---
 libavcodec/gifdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index 1906a4c738..4c5246c3d4 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -546,7 +546,7 @@ static av_cold int gif_decode_close(AVCodecContext *avctx)
 static const AVOption options[] = {
 { "trans_color", "color value (ARGB) that is used instead of transparent 
color",
   offsetof(GifState, trans_color), AV_OPT_TYPE_INT,
-  {.i64 = GIF_TRANSPARENT_COLOR}, 0, 0x,
+  {.i64 = GIF_TRANSPARENT_COLOR}, 0, INT_MAX,
   AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_VIDEO_PARAM },
 { NULL },
 };
-- 
2.17.1.windows.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] Fix printing integer option defaults

2019-09-16 Thread Soft Works
Integer values should not be printed using format specifier '%g' which leads to 
inexact display in case of higher values.

Before this patch:
  -trans_color   .D.V. color value [...] (default 
1.67772e+07)

Afterwards:
  -trans_color   .D.V. color value [...] (default 16777215)
Signed-off-by: softworkz 
---
 libavutil/opt.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 93d6c26c11..01530394e1 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1034,6 +1034,23 @@ int av_opt_flag_is_set(void *obj, const char 
*field_name, const char *flag_name)
 return res & flag->default_val.i64;
 }
 
+static void log_int_value(void *av_log_obj, int level, int64_t i)
+{
+if (i == INT_MAX) {
+av_log(av_log_obj, level, "INT_MAX");
+} else if (i == INT_MIN) {
+av_log(av_log_obj, level, "INT_MIN");
+} else if (i == UINT32_MAX) {
+av_log(av_log_obj, level, "UINT32_MAX");
+} else if (i == INT64_MAX) {
+av_log(av_log_obj, level, "I64_MAX");
+} else if (i == INT64_MIN) {
+av_log(av_log_obj, level, "I64_MIN");
+} else {
+av_log(av_log_obj, level, "%d", i);
+}
+}
+
 static void log_value(void *av_log_obj, int level, double d)
 {
 if  (d == INT_MAX) {
@@ -1254,7 +1271,7 @@ static void opt_list(void *obj, void *av_log_obj, const 
char *unit,
 if (def_const)
 av_log(av_log_obj, AV_LOG_INFO, "%s", def_const);
 else
-log_value(av_log_obj, AV_LOG_INFO, opt->default_val.i64);
+log_int_value(av_log_obj, AV_LOG_INFO, 
opt->default_val.i64);
 break;
 }
 case AV_OPT_TYPE_DOUBLE:
-- 
2.17.1.windows.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] Print out numeric values of option constants

2019-09-16 Thread Soft Works
It's often not obvious how option constants relate to numerical values.
Defaults are sometimes printed as numbers and from/to are always printed as 
numbers.
Printing the numeric values of options constants avoids this confusion.
It also allows to see which constants are equivalent.

Before this patch:

  -segment_list_type E set the segment list type (from -1 
to 4) (default -1)
 flat E flat format
 csv  E csv format
 ext  E extended format
 ffconcat E ffconcat format
 m3u8 E M3U8 format
 hls  E Apple HTTP Live Streaming compatible

Afterwards:

  -segment_list_type E set the segment list type (from -1 
to 4) (default -1)
 flat0E flat format
 csv 1E csv format
 ext 3E extended format
 ffconcat4E ffconcat format
 m3u82E M3U8 format
 hls 2E Apple HTTP Live Streaming compatible

Signed-off-by: softworkz 
---
 libavutil/opt.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 93d6c26c11..ed90808d6d 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1102,7 +1102,7 @@ static char *get_opt_flags_string(void *obj, const char 
*unit, int64_t value)
 }
 
 static void opt_list(void *obj, void *av_log_obj, const char *unit,
- int req_flags, int rej_flags)
+ int req_flags, int rej_flags, enum AVOptionType 
parent_type)
 {
 const AVOption *opt = NULL;
 AVOptionRanges *r;
@@ -1182,6 +1182,11 @@ static void opt_list(void *obj, void *av_log_obj, const 
char *unit,
 av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
 break;
 case AV_OPT_TYPE_CONST:
+if (parent_type == AV_OPT_TYPE_INT)
+av_log(av_log_obj, AV_LOG_INFO, "%-12d ", 
opt->default_val.i64);
+else
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
+break;
 default:
 av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
 break;
@@ -1286,7 +1291,7 @@ static void opt_list(void *obj, void *av_log_obj, const 
char *unit,
 
 av_log(av_log_obj, AV_LOG_INFO, "\n");
 if (opt->unit && opt->type != AV_OPT_TYPE_CONST)
-opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags);
+opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags, 
opt->type);
 }
 }
 
@@ -1297,7 +1302,7 @@ int av_opt_show2(void *obj, void *av_log_obj, int 
req_flags, int rej_flags)
 
 av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass 
**)obj)->class_name);
 
-opt_list(obj, av_log_obj, NULL, req_flags, rej_flags);
+opt_list(obj, av_log_obj, NULL, req_flags, rej_flags, -1);
 
 return 0;
 }
-- 
2.17.1.windows.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] Fix gif decoder max option

2019-09-16 Thread James Almer
On 9/16/2019 10:05 PM, Soft Works wrote:
> An int32 option cannot have a maximum of UINT32_MAX

AV_OPT_TYPE_INT options are int64_t. In this case however the storage
type for trans_color in GifState is int.

Reading the code i see it's intended to be uint32_t, so i think the
correct fix is changing its storage type, and not limiting its allowed
range. Same with stored_bg_color.

> 
> Before this patch
>   -trans_color   .D.V. color value (ARGB) that is used 
> instead of transparent color (from 0 to UINT32_MAX)
> 
> Afterwards:
>   -trans_color   .D.V. color value (ARGB) that is used 
> instead of transparent color (from 0 to INT_MAX)
> Signed-off-by: softworkz 
> ---
>  libavcodec/gifdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
> index 1906a4c738..4c5246c3d4 100644
> --- a/libavcodec/gifdec.c
> +++ b/libavcodec/gifdec.c
> @@ -546,7 +546,7 @@ static av_cold int gif_decode_close(AVCodecContext *avctx)
>  static const AVOption options[] = {
>  { "trans_color", "color value (ARGB) that is used instead of transparent 
> color",
>offsetof(GifState, trans_color), AV_OPT_TYPE_INT,
> -  {.i64 = GIF_TRANSPARENT_COLOR}, 0, 0x,
> +  {.i64 = GIF_TRANSPARENT_COLOR}, 0, INT_MAX,
>AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_VIDEO_PARAM },
>  { NULL },
>  };
> 

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] Fix printing integer option defaults

2019-09-16 Thread James Almer
On 9/16/2019 10:07 PM, Soft Works wrote:
> Integer values should not be printed using format specifier '%g' which leads 
> to inexact display in case of higher values.
> 
> Before this patch:
>   -trans_color   .D.V. color value [...] (default 
> 1.67772e+07)
> 
> Afterwards:
>   -trans_color   .D.V. color value [...] (default 
> 16777215)
> Signed-off-by: softworkz 
> ---
>  libavutil/opt.c | 19 ++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index 93d6c26c11..01530394e1 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -1034,6 +1034,23 @@ int av_opt_flag_is_set(void *obj, const char 
> *field_name, const char *flag_name)
>  return res & flag->default_val.i64;
>  }
>  
> +static void log_int_value(void *av_log_obj, int level, int64_t i)
> +{
> +if (i == INT_MAX) {
> +av_log(av_log_obj, level, "INT_MAX");
> +} else if (i == INT_MIN) {
> +av_log(av_log_obj, level, "INT_MIN");
> +} else if (i == UINT32_MAX) {
> +av_log(av_log_obj, level, "UINT32_MAX");
> +} else if (i == INT64_MAX) {
> +av_log(av_log_obj, level, "I64_MAX");
> +} else if (i == INT64_MIN) {
> +av_log(av_log_obj, level, "I64_MIN");
> +} else {
> +av_log(av_log_obj, level, "%d", i);

This should be PRId64.

> +}
> +}
> +
>  static void log_value(void *av_log_obj, int level, double d)
>  {
>  if  (d == INT_MAX) {
> @@ -1254,7 +1271,7 @@ static void opt_list(void *obj, void *av_log_obj, const 
> char *unit,
>  if (def_const)
>  av_log(av_log_obj, AV_LOG_INFO, "%s", def_const);
>  else
> -log_value(av_log_obj, AV_LOG_INFO, opt->default_val.i64);
> +log_int_value(av_log_obj, AV_LOG_INFO, 
> opt->default_val.i64);
>  break;
>  }
>  case AV_OPT_TYPE_DOUBLE:
> 

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/4] avutil/avstring: support input path is a null pointer or empty string

2019-09-16 Thread Limin Wang
On Mon, Sep 16, 2019 at 09:30:15PM +0200, Michael Niedermayer wrote:
> On Mon, Sep 16, 2019 at 07:25:13PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Reviewed-by: Tomas Härdin 
> > Reviewed-by: Liu Steven 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavutil/avstring.c | 12 
> >  libavutil/avstring.h | 13 +
> >  2 files changed, 17 insertions(+), 8 deletions(-)
> > 
> > diff --git a/libavutil/avstring.c b/libavutil/avstring.c
> > index 4c068f5bc5..551ca5daee 100644
> > --- a/libavutil/avstring.c
> > +++ b/libavutil/avstring.c
> > @@ -257,8 +257,12 @@ char *av_strireplace(const char *str, const char 
> > *from, const char *to)
> >  
> >  const char *av_basename(const char *path)
> >  {
> > -char *p = strrchr(path, '/');
> > +char *p = NULL;
> 
> the NULL assignment is unneeded
Yes, it's unneeded, I will remove it.

> 
> 
> > +
> > +if (!path || *path == '\0')
> > +return ".";
> >  
> > +p = strrchr(path, '/');
> 
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> He who knows, does not speak. He who speaks, does not know. -- Lao Tsu



> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] Fix gif decoder max option

2019-09-16 Thread Soft Works
> From: ffmpeg-devel  On Behalf Of
> James Almer
> Sent: Tuesday, September 17, 2019 3:11 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] Fix gif decoder max option
> 
> On 9/16/2019 10:05 PM, Soft Works wrote:
> > An int32 option cannot have a maximum of UINT32_MAX
> 
> AV_OPT_TYPE_INT options are int64_t. In this case however the storage
> type for trans_color in GifState is int.
> 
> Reading the code i see it's intended to be uint32_t, so i think the correct 
> fix is
> changing its storage type, and not limiting its allowed range. Same with
> stored_bg_color.

Hi James,

Thanks for looking into this.

The purpose of this option is to indicate a "replacement color" for transparent 
pixels.
Such a replacement color itself can never have an alpha component.

I was unsure how to indicate this. Maybe, by setting the maximum to 0x00FF ?

softworkz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2] libavformat/webvttenc: Allow (but discard) additional streams

2019-09-16 Thread Soft Works
This allows mapping a video stream as reference stream for creating vtt 
segments when using the segment muxer. Example:

ffmpeg -i INPUT -map 0:3 -c:0 webvtt -map 0:0 -c:v:0 copy -f segment 
-segment_format webvtt -segment_time 6 -write_empty_segments 1 -y 
"sub_segment3%d.vtt"

The mpegts segments are being created in a constant and regular way. But not 
necessearily in the case of subtitles: When hitting a time range without any 
subtitle event, the segmenter stops generating subtitle segments, even when 
write_empty_segments is configured.
It's not that write_empty_segments would not be working, though: As soon as a 
new subtitle event reaches the muxer, it catches up by creating the missed 
empty segments all at once. This might be OK for precreating content for 
HLS/VOD scenarios but it's a behavioral bug when you rely on having accurate 
results while the process is running.

This is happening because When there are no subtitle events, there are no 
packets arriving at the segment muxer (for vtt).

This patch allows a video stream as input to the WebVTT muxer which is 
discarded - but will allow the segment muxer to use it as reference stream.

Signed-off-by: softworkz 
---
 libavformat/webvttenc.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c
index 61b7f54622..be85c03130 100644
--- a/libavformat/webvttenc.c
+++ b/libavformat/webvttenc.c
@@ -49,8 +49,8 @@ static int webvtt_write_header(AVFormatContext *ctx)
 AVCodecParameters *par = ctx->streams[0]->codecpar;
 AVIOContext *pb = ctx->pb;
 
-if (ctx->nb_streams != 1 || par->codec_id != AV_CODEC_ID_WEBVTT) {
-av_log(ctx, AV_LOG_ERROR, "Exactly one WebVTT stream is needed.\n");
+if (par->codec_id != AV_CODEC_ID_WEBVTT) {
+av_log(ctx, AV_LOG_ERROR, "First stream must be WebVTT.\n");
 return AVERROR(EINVAL);
 }
 
@@ -68,6 +68,9 @@ static int webvtt_write_packet(AVFormatContext *ctx, AVPacket 
*pkt)
 int id_size, settings_size;
 uint8_t *id, *settings;
 
+if (pkt->stream_index != 0)
+return 0;
+
 avio_printf(pb, "\n");
 
 id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER,
-- 
2.17.1.windows.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] Fix gif decoder max option

2019-09-16 Thread James Almer
On 9/16/2019 10:24 PM, Soft Works wrote:
>> From: ffmpeg-devel  On Behalf Of
>> James Almer
>> Sent: Tuesday, September 17, 2019 3:11 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH] Fix gif decoder max option
>>
>> On 9/16/2019 10:05 PM, Soft Works wrote:
>>> An int32 option cannot have a maximum of UINT32_MAX
>>
>> AV_OPT_TYPE_INT options are int64_t. In this case however the storage
>> type for trans_color in GifState is int.
>>
>> Reading the code i see it's intended to be uint32_t, so i think the correct 
>> fix is
>> changing its storage type, and not limiting its allowed range. Same with
>> stored_bg_color.
> 
> Hi James,
> 
> Thanks for looking into this.
> 
> The purpose of this option is to indicate a "replacement color" for 
> transparent pixels.
> Such a replacement color itself can never have an alpha component.
> 
> I was unsure how to indicate this. Maybe, by setting the maximum to 
> 0x00FF ?

In that case set the max to GIF_TRANSPARENT_COLOR (default value), which
is 0x00FF.

Storage type as int in the struct is still wrong IMO, but i guess it's
harmless. I'll let others chime in either way.

> 
> softworkz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 2/5] avcodec/v210enc: make 8bit and 10bit function consistent

2019-09-16 Thread Limin Wang
On Mon, Sep 16, 2019 at 09:06:06PM +0200, Michael Niedermayer wrote:
> On Sun, Sep 01, 2019 at 09:20:20PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > I have benchmarked the performance with c code and haven't see any
> > performance impact.
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavcodec/v210enc.c | 7 +--
> >  1 file changed, 1 insertion(+), 6 deletions(-)
> > 
> > diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
> > index 1b840b2..69a2efe 100644
> > --- a/libavcodec/v210enc.c
> > +++ b/libavcodec/v210enc.c
> > @@ -43,12 +43,7 @@ static void v210_planar_pack_8_c(const uint8_t *y, const 
> > uint8_t *u,
> >  uint32_t val;
> >  int i;
> >  
> > -/* unroll this to match the assembly */
> > -for (i = 0; i < width - 11; i += 12) {
> > -WRITE_PIXELS(u, y, v, 8);
> > -WRITE_PIXELS(y, u, y, 8);
> > -WRITE_PIXELS(v, y, u, 8);
> > -WRITE_PIXELS(y, v, y, 8);
> > +for (i = 0; i < width - 5; i += 6) {
> >  WRITE_PIXELS(u, y, v, 8);
> >  WRITE_PIXELS(y, u, y, 8);
> >  WRITE_PIXELS(v, y, u, 8);
> 
> I have retested this with START/STOP_TIMER
> and the more unrolled loop is consistently faster

Sorry, I haven't used START/STOP_TIMER before, so only using -benchmark for 
checking quickly.
As it's faster and we can't make the two function consistent, so I'll update 
the patch and
discard patch#2 and patch#3.


> 
> ./ffmpeg -cpuflags 0 -v 99 -i matrixbench_mpeg2.mpg -vcodec v210 -an test.avi
> 
>  31620 decicycles in TEST, 2096691 runs,461 skips  0  0  0  0  0  0  0  0 
>  0  0  0 21 13  9  8  7  8  7  0  0  0  0  0  0  0  0  0  0  0  0  0  0
>  31509 decicycles in TEST, 2096892 runs,260 skips  0  0  0  0  0  0  0  0 
>  0  0  0 21 10  9  8  6  7  3  2  0  0  0  0  0  0  0  0  0  0  0  0  0
>  32069 decicycles in TEST, 2096965 runs,187 skips  0  0  0  0  0  0  0  0 
>  0  0  0 21 16 10  8  6  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
>  31522 decicycles in TEST, 2096962 runs,190 skips  0  0  0  0  0  0  0  0 
>  0  0  0 21 10  9  8  6  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
>  31537 decicycles in TEST, 2096784 runs,368 skips  0  0  0  0  0  0  0  0 
>  0  0  0 21 12  8  9  7  7  7  0  0  0  0  0  0  0  0  0  0  0  0  0  0
> 
> prev:
>  30705 decicycles in TEST, 2096875 runs,277 skips  0  0  0  0  0  0  0  0 
>  0  0  0 21 15  9  9  7  5  3  1  0  0  0  0  0  0  0  0  0  0  0  0  0
>  30771 decicycles in TEST, 2096907 runs,245 skips  0  0  0  0  0  0  0  0 
>  0  0  0 21 15  9  8  6  7  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
>  30560 decicycles in TEST, 2096904 runs,248 skips  0  0  0  0  0  0  0  0 
>  0  0  0 21 10  9  9  6  2  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
>  31020 decicycles in TEST, 2096974 runs,178 skips  0  0  0  0  0  0  0  0 
>  0  0  0 21 16  9  8  6  2  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
>  31018 decicycles in TEST, 2096980 runs,172 skips  0  0  0  0  0  0  0  0 
>  0  0  0 21 16  9  8  6  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> I have often repented speaking, but never of holding my tongue.
> -- Xenocrates



> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2] Fix printing integer option defaults

2019-09-16 Thread Soft Works
Integer values should not be printed using format specifier '%g' which leads to 
inexact display in case of higher values.

Before this patch:
  -trans_color   .D.V. color value [...] (default 
1.67772e+07)

Afterwards:
  -trans_color   .D.V. color value [...] (default 16777215)

Update: Use PRId64 format specifier
Signed-off-by: softworkz 
---
 libavutil/opt.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 93d6c26c11..5a35109f39 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1034,6 +1034,23 @@ int av_opt_flag_is_set(void *obj, const char 
*field_name, const char *flag_name)
 return res & flag->default_val.i64;
 }
 
+static void log_int_value(void *av_log_obj, int level, int64_t i)
+{
+if (i == INT_MAX) {
+av_log(av_log_obj, level, "INT_MAX");
+} else if (i == INT_MIN) {
+av_log(av_log_obj, level, "INT_MIN");
+} else if (i == UINT32_MAX) {
+av_log(av_log_obj, level, "UINT32_MAX");
+} else if (i == INT64_MAX) {
+av_log(av_log_obj, level, "I64_MAX");
+} else if (i == INT64_MIN) {
+av_log(av_log_obj, level, "I64_MIN");
+} else {
+av_log(av_log_obj, level, "%"PRId64, i);
+}
+}
+
 static void log_value(void *av_log_obj, int level, double d)
 {
 if  (d == INT_MAX) {
@@ -1254,7 +1271,7 @@ static void opt_list(void *obj, void *av_log_obj, const 
char *unit,
 if (def_const)
 av_log(av_log_obj, AV_LOG_INFO, "%s", def_const);
 else
-log_value(av_log_obj, AV_LOG_INFO, opt->default_val.i64);
+log_int_value(av_log_obj, AV_LOG_INFO, 
opt->default_val.i64);
 break;
 }
 case AV_OPT_TYPE_DOUBLE:
-- 
2.17.1.windows.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 5/5] avcodec/v210enc: move the duplicate code to template file

2019-09-16 Thread Limin Wang
On Tue, Sep 17, 2019 at 01:16:36AM +0200, Michael Niedermayer wrote:
> On Mon, Sep 16, 2019 at 07:17:52PM +0800, Limin Wang wrote:
> > On Mon, Sep 16, 2019 at 12:21:36PM +0200, Michael Niedermayer wrote:
> > > On Sun, Sep 01, 2019 at 09:20:23PM +0800, lance.lmw...@gmail.com wrote:
> > > > From: Limin Wang 
> > > > 
> > > > Signed-off-by: Limin Wang 
> > > > ---
> > > >  libavcodec/v210_template.c |  59 +-
> > > >  libavcodec/v210enc.c   | 123 
> > > > +++--
> > > >  2 files changed, 75 insertions(+), 107 deletions(-)
> > > 
> > > [PATCH v3 3/5] avcodec/v210enc: move the duplicate code to template file
> > > [PATCH v3 5/5] avcodec/v210enc: move the duplicate code to template file
> > > 
> > > why do 2 patches have the same first line in the commit message ?
> > It's for split the patch for review, 3/5 is move v210_planar_pack, 5/5 is 
> > moving 
> > v210enc related function, so the code is different.
> 
> If the same description is good for different changes then the description
> is not very good (not specific enough) IMO

Yes, will avoid to use same description next time.

> 
> thanks
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> In a rich man's house there is no place to spit but his face.
> -- Diogenes of Sinope



> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] Fix gif decoder max option

2019-09-16 Thread Soft Works
> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> James Almer
> Sent: Tuesday, September 17, 2019 3:29 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] Fix gif decoder max option
> 
> On 9/16/2019 10:24 PM, Soft Works wrote:
> >> From: ffmpeg-devel  On Behalf Of
> >> James Almer
> >> Sent: Tuesday, September 17, 2019 3:11 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: Re: [FFmpeg-devel] [PATCH] Fix gif decoder max option
> >>
> >> On 9/16/2019 10:05 PM, Soft Works wrote:
> >>> An int32 option cannot have a maximum of UINT32_MAX
> >>
> >> AV_OPT_TYPE_INT options are int64_t. In this case however the storage
> >> type for trans_color in GifState is int.
> >>
> >> Reading the code i see it's intended to be uint32_t, so i think the
> >> correct fix is changing its storage type, and not limiting its
> >> allowed range. Same with stored_bg_color.
> >
> > Hi James,
> >
> > Thanks for looking into this.
> >
> > The purpose of this option is to indicate a "replacement color" for
> transparent pixels.
> > Such a replacement color itself can never have an alpha component.
> >
> > I was unsure how to indicate this. Maybe, by setting the maximum to
> 0x00FF ?
> 
> In that case set the max to GIF_TRANSPARENT_COLOR (default value), which
> is 0x00FF.
> 
> Storage type as int in the struct is still wrong IMO, but i guess it's 
> harmless. I'll
> let others chime in either way.

Thanks James,

I agree with all your comments. 
But to be honest, I didn't intend to get into gif decoder development.

I had just seen this:

$ ffmpeg -h decoder=gif

Decoder gif [GIF (Graphics Interchange Format)]:
General capabilities: dr1
Threading capabilities: none
gif decoder AVOptions:
  -trans_color   .D.V. color value (ARGB) that is used 
instead of transparent color (from 0 to UINT32_MAX) (default 1.67772e+07)

Two things are incorrect here: The max and the default.

My patches are turning this into:

  -trans_color   .D.V. color value (ARGB) that is used 
instead of transparent color (from 0 to INT_MAX) (default 16777215)

It might not be perfect, but it's much better than before.

Changing the storage type would need code changes to the gif decoder and 
require testing. At this time, I'm afraid, I'm not able to get into this. Of 
course, I'll do requested detail adjustments to my patches, though. :-)

Best regards,

softworkz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 2/3] avcodec/v210enc: make 8bit and 10bit process consistent

2019-09-16 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/v210enc.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 1b840b2c22..f545e43c6c 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -75,7 +75,7 @@ av_cold void ff_v210enc_init(V210EncContext *s)
 {
 s->pack_line_8  = v210_planar_pack_8_c;
 s->pack_line_10 = v210_planar_pack_10_c;
-s->sample_factor_8  = 1;
+s->sample_factor_8  = 2;
 s->sample_factor_10 = 1;
 
 if (ARCH_X86)
@@ -150,18 +150,18 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 if (w < avctx->width - 1) {
 WRITE_PIXELS(u, y, v, 10);
 
-val = CLIP(*y++, 10);
+val = CLIP(*y++, 10) << (10-10);
 if (w == avctx->width - 2) {
 AV_WL32(dst, val);
 dst += 4;
 }
 }
 if (w < avctx->width - 3) {
-val |= (CLIP(*u++, 10) << 10) | (CLIP(*y++, 10) << 20);
+val |= (CLIP(*u++, 10) << (20-10)) | (CLIP(*y++, 10) << 
(30-10));
 AV_WL32(dst, val);
 dst += 4;
 
-val = CLIP(*v++, 10) | (CLIP(*y++, 10) << 10);
+val = CLIP(*v++, 10) << (10-10) | (CLIP(*y++, 10) << (20-10));
 AV_WL32(dst, val);
 dst += 4;
 }
@@ -177,7 +177,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 const uint8_t *u = pic->data[1];
 const uint8_t *v = pic->data[2];
 
-const int sample_size = 12 * s->sample_factor_8;
+const int sample_size = 6 * s->sample_factor_8;
 const int sample_w= avctx->width / sample_size;
 
 for (h = 0; h < avctx->height; h++) {
@@ -188,7 +188,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 y += w;
 u += w >> 1;
 v += w >> 1;
-dst += sample_w * 32 * s->sample_factor_8;
+dst += sample_w * 16 * s->sample_factor_8;
 
 for (; w < avctx->width - 5; w += 6) {
 WRITE_PIXELS(u, y, v, 8);
@@ -199,18 +199,18 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 if (w < avctx->width - 1) {
 WRITE_PIXELS(u, y, v, 8);
 
-val = CLIP(*y++, 8) << 2;
+val = CLIP(*y++, 8) << (10-8);
 if (w == avctx->width - 2) {
 AV_WL32(dst, val);
 dst += 4;
 }
 }
 if (w < avctx->width - 3) {
-val |= (CLIP(*u++, 8) << 12) | (CLIP(*y++, 8) << 22);
+val |= (CLIP(*u++, 8) << (20-8)) | (CLIP(*y++, 8) << (30-8));
 AV_WL32(dst, val);
 dst += 4;
 
-val = (CLIP(*v++, 8) << 2) | (CLIP(*y++, 8) << 12);
+val = (CLIP(*v++, 8) << (10-8)) | (CLIP(*y++, 8) << (20-8));
 AV_WL32(dst, val);
 dst += 4;
 }
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 1/3] avcodec/v210enc: add depth parameter for WRITE_PIXELS and CLIP

2019-09-16 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/v210enc.c | 83 +++-
 1 file changed, 36 insertions(+), 47 deletions(-)

diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index b024806d0b..1b840b2c22 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -26,25 +26,14 @@
 #include "internal.h"
 #include "v210enc.h"
 
-#define CLIP(v) av_clip(v, 4, 1019)
-#define CLIP8(v) av_clip(v, 1, 254)
-
-#define WRITE_PIXELS(a, b, c)   \
-do {\
-val  =  CLIP(*a++); \
-val |= (CLIP(*b++) << 10) | \
-   (CLIP(*c++) << 20);  \
-AV_WL32(dst, val);  \
-dst += 4;   \
-} while (0)
-
-#define WRITE_PIXELS8(a, b, c)  \
-do {\
-val  = (CLIP8(*a++) << 2);  \
-val |= (CLIP8(*b++) << 12) |\
-   (CLIP8(*c++) << 22); \
-AV_WL32(dst, val);  \
-dst += 4;   \
+#define CLIP(v, depth) av_clip(v, 1 << (depth-8), ((1 << depth)-(1 << 
(depth-8)) -1))
+#define WRITE_PIXELS(a, b, c, depth)  \
+do {  \
+val  =  CLIP(*a++, depth)  << (10-depth); \
+val |=  (CLIP(*b++, depth) << (20-depth)) |   \
+(CLIP(*c++, depth) << (30-depth));\
+AV_WL32(dst, val);\
+dst += 4; \
 } while (0)
 
 static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
@@ -56,14 +45,14 @@ static void v210_planar_pack_8_c(const uint8_t *y, const 
uint8_t *u,
 
 /* unroll this to match the assembly */
 for (i = 0; i < width - 11; i += 12) {
-WRITE_PIXELS8(u, y, v);
-WRITE_PIXELS8(y, u, y);
-WRITE_PIXELS8(v, y, u);
-WRITE_PIXELS8(y, v, y);
-WRITE_PIXELS8(u, y, v);
-WRITE_PIXELS8(y, u, y);
-WRITE_PIXELS8(v, y, u);
-WRITE_PIXELS8(y, v, y);
+WRITE_PIXELS(u, y, v, 8);
+WRITE_PIXELS(y, u, y, 8);
+WRITE_PIXELS(v, y, u, 8);
+WRITE_PIXELS(y, v, y, 8);
+WRITE_PIXELS(u, y, v, 8);
+WRITE_PIXELS(y, u, y, 8);
+WRITE_PIXELS(v, y, u, 8);
+WRITE_PIXELS(y, v, y, 8);
 }
 }
 
@@ -75,10 +64,10 @@ static void v210_planar_pack_10_c(const uint16_t *y, const 
uint16_t *u,
 int i;
 
 for (i = 0; i < width - 5; i += 6) {
-WRITE_PIXELS(u, y, v);
-WRITE_PIXELS(y, u, y);
-WRITE_PIXELS(v, y, u);
-WRITE_PIXELS(y, v, y);
+WRITE_PIXELS(u, y, v, 10);
+WRITE_PIXELS(y, u, y, 10);
+WRITE_PIXELS(v, y, u, 10);
+WRITE_PIXELS(y, v, y, 10);
 }
 }
 
@@ -153,26 +142,26 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 dst += sample_w * 16 * s->sample_factor_10;
 
 for (; w < avctx->width - 5; w += 6) {
-WRITE_PIXELS(u, y, v);
-WRITE_PIXELS(y, u, y);
-WRITE_PIXELS(v, y, u);
-WRITE_PIXELS(y, v, y);
+WRITE_PIXELS(u, y, v, 10);
+WRITE_PIXELS(y, u, y, 10);
+WRITE_PIXELS(v, y, u, 10);
+WRITE_PIXELS(y, v, y, 10);
 }
 if (w < avctx->width - 1) {
-WRITE_PIXELS(u, y, v);
+WRITE_PIXELS(u, y, v, 10);
 
-val = CLIP(*y++);
+val = CLIP(*y++, 10);
 if (w == avctx->width - 2) {
 AV_WL32(dst, val);
 dst += 4;
 }
 }
 if (w < avctx->width - 3) {
-val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);
+val |= (CLIP(*u++, 10) << 10) | (CLIP(*y++, 10) << 20);
 AV_WL32(dst, val);
 dst += 4;
 
-val = CLIP(*v++) | (CLIP(*y++) << 10);
+val = CLIP(*v++, 10) | (CLIP(*y++, 10) << 10);
 AV_WL32(dst, val);
 dst += 4;
 }
@@ -202,26 +191,26 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 dst += sample_w * 32 * s->sample_factor_8;
 
 for (; w < avctx->width - 5; w += 6) {
-WRITE_PIXELS8(u, y, v);
-WRITE_PIXELS8(y, u, y);
-WRITE_PIXELS8(v, y, u);
-WRITE_PIXELS8(y, v, y);
+WRITE_PIXELS(u, y, v, 8);
+WRITE_PIXELS(y, u, y, 8);
+WRITE_PIXELS(v, y, u, 8);
+WRITE_PIXELS(y, v, y, 8);
 }
 if (w < avctx->width - 1) {
-WRITE_PIXELS8(u, y, v);
+WRITE_PIXELS(u, y, v, 8);
 
-val = CLIP8(*y++) << 2;
+val = CLIP(*y++, 8) << 2;
 if (w == avctx->width - 2

[FFmpeg-devel] [PATCH v4 3/3] avcodec/v210enc: move v210_enc_8/10 function to template file

2019-09-16 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/v210_template.c |  90 +
 libavcodec/v210enc.c   | 135 +++--
 2 files changed, 114 insertions(+), 111 deletions(-)
 create mode 100644 libavcodec/v210_template.c

diff --git a/libavcodec/v210_template.c b/libavcodec/v210_template.c
new file mode 100644
index 00..9e1d9f9cd3
--- /dev/null
+++ b/libavcodec/v210_template.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2009 Michael Niedermayer 
+ * Copyright (c) 2009 Baptiste Coudurier 
+ *
+ * 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 "bytestream.h"
+#include "internal.h"
+
+#define CLIP(v, depth) av_clip(v, 1<<(depth-8), ((1width + 47) / 48) * 48;
+int stride = aligned_width * 8 / 3;
+int line_padding = stride - ((avctx->width * 8 + 11) / 12) * 4;
+int h, w;
+const TYPE *y = (const TYPE *)pic->data[0];
+const TYPE *u = (const TYPE *)pic->data[1];
+const TYPE *v = (const TYPE *)pic->data[2];
+const int sample_size = 6 * s->RENAME(sample_factor);
+const int sample_w= avctx->width / sample_size;
+
+for (h = 0; h < avctx->height; h++) {
+uint32_t val;
+w = sample_w * sample_size;
+s->RENAME(pack_line)(y, u, v, dst, w);
+
+y += w;
+u += w >> 1;
+v += w >> 1;
+dst += sample_w * 16 * s->RENAME(sample_factor);
+
+for (; w < avctx->width - 5; w += 6) {
+WRITE_PIXELS(u, y, v, DEPTH);
+WRITE_PIXELS(y, u, y, DEPTH);
+WRITE_PIXELS(v, y, u, DEPTH);
+WRITE_PIXELS(y, v, y, DEPTH);
+}
+if (w < avctx->width - 1) {
+WRITE_PIXELS(u, y, v, DEPTH);
+
+val = CLIP(*y++, DEPTH) << (10-DEPTH);
+if (w == avctx->width - 2) {
+AV_WL32(dst, val);
+dst += 4;
+}
+}
+if (w < avctx->width - 3) {
+val |= (CLIP(*u++, DEPTH) << (20-DEPTH)) | (CLIP(*y++, DEPTH) << 
(30-DEPTH));
+AV_WL32(dst, val);
+dst += 4;
+
+val = CLIP(*v++, DEPTH) << (10-DEPTH) | (CLIP(*y++, DEPTH) << 
(20-DEPTH));
+AV_WL32(dst, val);
+dst += 4;
+}
+
+memset(dst, 0, line_padding);
+dst += line_padding;
+y += pic->linesize[0] / BYTES_PER_PIXEL - avctx->width;
+u += pic->linesize[1] / BYTES_PER_PIXEL - avctx->width / 2;
+v += pic->linesize[2] / BYTES_PER_PIXEL - avctx->width / 2;
+}
+}
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index f545e43c6c..16e8810271 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -26,15 +26,25 @@
 #include "internal.h"
 #include "v210enc.h"
 
-#define CLIP(v, depth) av_clip(v, 1 << (depth-8), ((1 << depth)-(1 << 
(depth-8)) -1))
-#define WRITE_PIXELS(a, b, c, depth)  \
-do {  \
-val  =  CLIP(*a++, depth)  << (10-depth); \
-val |=  (CLIP(*b++, depth) << (20-depth)) |   \
-(CLIP(*c++, depth) << (30-depth));\
-AV_WL32(dst, val);\
-dst += 4; \
-} while (0)
+#define TYPE uint8_t
+#define DEPTH 8
+#define BYTES_PER_PIXEL 1
+#define RENAME(a) a ## _ ## 8
+#include "v210_template.c"
+#undef RENAME
+#undef DEPTH
+#undef BYTES_PER_PIXEL
+#undef TYPE
+
+#define TYPE uint16_t
+#define DEPTH 10
+#define BYTES_PER_PIXEL 2
+#define RENAME(a) a ## _ ## 10
+#include "v210_template.c"
+#undef RENAME
+#undef DEPTH
+#undef BYTES_PER_PIXEL
+#undef TYPE
 
 static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
  const uint8_t *v, uint8_t *dst,
@@ -108,12 +118,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 const AVFrame *pic, int *got_packet)
 {
-V210EncContext *s = avctx->priv_data;
 int aligned_width = ((avctx->width + 47) / 48) * 48;
 int stride = aligned_width * 8 / 3;
-int line_padding = stride - ((avctx->width * 8 + 11) / 12) * 4;
 AVFrameSideData *side_data;
-i

[FFmpeg-devel] [PATCH v2 1/4] avutil/avstring: support input path is a null pointer or empty string

2019-09-16 Thread lance . lmwang
From: Limin Wang 

Reviewed-by: Tomas Härdin 
Reviewed-by: Liu Steven 
Signed-off-by: Limin Wang 
---
 libavutil/avstring.c | 12 
 libavutil/avstring.h | 13 +
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index 4c068f5bc5..551ca5daee 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -257,8 +257,12 @@ char *av_strireplace(const char *str, const char *from, 
const char *to)
 
 const char *av_basename(const char *path)
 {
-char *p = strrchr(path, '/');
+char *p;
+
+if (!path || *path == '\0')
+return ".";
 
+p = strrchr(path, '/');
 #if HAVE_DOS_PATHS
 char *q = strrchr(path, '\\');
 char *d = strchr(path, ':');
@@ -274,11 +278,11 @@ const char *av_basename(const char *path)
 
 const char *av_dirname(char *path)
 {
-char *p = strrchr(path, '/');
+char *p = path ? strrchr(path, '/') : NULL;
 
 #if HAVE_DOS_PATHS
-char *q = strrchr(path, '\\');
-char *d = strchr(path, ':');
+char *q = path ? strrchr(path, '\\') : NULL;
+char *d = path ? strchr(path, ':')  : NULL;
 
 d = d ? d + 1 : d;
 
diff --git a/libavutil/avstring.h b/libavutil/avstring.h
index 37dd4e2da0..274335cfb9 100644
--- a/libavutil/avstring.h
+++ b/libavutil/avstring.h
@@ -274,16 +274,21 @@ char *av_strireplace(const char *str, const char *from, 
const char *to);
 
 /**
  * Thread safe basename.
- * @param path the path, on DOS both \ and / are considered separators.
+ * @param path the string to parse, on DOS both \ and / are considered 
separators.
  * @return pointer to the basename substring.
+ * If path does not contain a slash, the function returns a copy of path.
+ * If path is a NULL pointer or points to an empty string, a pointer
+ * to a string "." is returned.
  */
 const char *av_basename(const char *path);
 
 /**
  * Thread safe dirname.
- * @param path the path, on DOS both \ and / are considered separators.
- * @return the path with the separator replaced by the string terminator or 
".".
- * @note the function may change the input string.
+ * @param path the string to parse, on DOS both \ and / are considered 
separators.
+ * @return A pointer to a string that's the parent directory of path.
+ * If path is a NULL pointer or points to an empty string, a pointer
+ * to a string "." is returned.
+ * @note the function may modify the contents of the path, so copies should be 
passed.
  */
 const char *av_dirname(char *path);
 
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".