Re: [libav-devel] [PATCH] utils: Add av_stream_add_side_data()

2016-11-22 Thread James Almer
On 11/21/2016 8:49 PM, Vittorio Giovara wrote:
> From: James Almer 
> 
> Functionally similar to av_packet_add_side_data(). Allows the use of an
> already allocated buffer as stream side data.
> 
> Signed-off-by: James Almer 
> Signed-off-by: Vittorio Giovara 
> ---
> Needed to clean up the new side data additions in mov.c
> Vittorio
> 
>  doc/APIchanges |  3 +++
>  libavformat/avformat.h | 15 +++
>  libavformat/utils.c| 32 +++-
>  libavformat/version.h  |  2 +-
>  4 files changed, 42 insertions(+), 10 deletions(-)

You could squash this with commits 0ffea35 (making the return codes
consistent with av_packet_add_side_data) and 0b8df0c (fixing an
embarrassing mistake introduced by the previous commit).

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


Re: [libav-devel] [PATCH] utils: Add av_stream_add_side_data()

2016-11-22 Thread James Almer
On 11/22/2016 5:32 PM, Vittorio Giovara wrote:
> On Tue, Nov 22, 2016 at 10:04 AM, James Almer  wrote:
>> On 11/21/2016 8:49 PM, Vittorio Giovara wrote:
>>> From: James Almer 
>>>
>>> Functionally similar to av_packet_add_side_data(). Allows the use of an
>>> already allocated buffer as stream side data.
>>>
>>> Signed-off-by: James Almer 
>>> Signed-off-by: Vittorio Giovara 
>>> ---
>>> Needed to clean up the new side data additions in mov.c
>>> Vittorio
>>>
>>>  doc/APIchanges |  3 +++
>>>  libavformat/avformat.h | 15 +++
>>>  libavformat/utils.c| 32 +++-
>>>  libavformat/version.h  |  2 +-
>>>  4 files changed, 42 insertions(+), 10 deletions(-)
>>
>> You could squash this with commits 0ffea35 (making the return codes
>> consistent with av_packet_add_side_data) and 0b8df0c (fixing an
>> embarrassing mistake introduced by the previous commit).
> 
> I squashed 0ffea35, and I had already squashed the err/ret change, but
> I couldn't find 0b8df0c, which one are you referring to?
> Thank you
> 

https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=0b8df0ce48e6e3d3263f20ec0ce20fe72bdae318

It depends on 0ffea35, of course, since it fixes a regression introduced
by it.

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


Re: [libav-devel] [PATCH] utils: Add av_stream_add_side_data()

2016-11-22 Thread James Almer
On 11/23/2016 12:39 AM, Luca Barbato wrote:
> On 22/11/2016 23:16, Vittorio Giovara wrote:
>> -tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, 
>> sizeof(*tmp));
>> +if ((unsigned) st->nb_side_data + 1 >= INT_MAX / sizeof(*st->side_data))
>> +return AVERROR(ERANGE);
>> +
>> +tmp = av_realloc(st->side_data, (st->nb_side_data + 1) * sizeof(*tmp));
> 
> Why that?

To make av_stream_add_side_data return error codes consistent with
av_packet_add_side_data's.

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


Re: [libav-devel] [PATCH 02/14] aac_adtstoasc_bsf: convert to the new API

2016-11-24 Thread James Almer
On 3/19/2016 1:02 PM, Anton Khirnov wrote:
> Quoting Luca Barbato (2016-03-07 09:10:14)
>> On 07/03/16 08:59, Luca Barbato wrote:
>>> On 04/03/16 09:15, Anton Khirnov wrote:
>>>> ---
>>>>  libavcodec/aac_adtstoasc_bsf.c | 95 
>>>> ++
>>>>  libavcodec/allcodecs.c |  1 -
>>>>  libavcodec/bitstream_filters.c |  5 +++
>>>>  3 files changed, 65 insertions(+), 36 deletions(-)
>>>>
>>>
>>> Possibly Ok.
>>>
>>
>> Reading the others, why the par_out->extradata is not set?
> 
> Because it's set as side data in the first packet. Actually it should be
> actively unset from the output parameters.

This is not what should be done. If the stream has extradata during .init()
then it means it's ASC and not ADTS or even LATM. Deleting it unconditionally
breaks passthrough use cases.

The .init function should validate the extradata and let av_bsf_init() pass
it down the filter chain. See the attached patch.

>From 5f07937db0a12b6176bfc0414c530716cfb382e7 Mon Sep 17 00:00:00 2001
From: James Almer 
Date: Thu, 24 Nov 2016 21:10:47 -0300
Subject: [PATCH] aac_adtstoasc_bsf: validate and forward extradata if the
 stream is already ASC

Fixes AAC AudioSpecificConfig passthrough.

Signed-off-by: James Almer 
---
 libavcodec/aac_adtstoasc_bsf.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c
index 9168e2b..08d60eb 100644
--- a/libavcodec/aac_adtstoasc_bsf.c
+++ b/libavcodec/aac_adtstoasc_bsf.c
@@ -135,8 +135,16 @@ fail:
 
 static int aac_adtstoasc_init(AVBSFContext *ctx)
 {
-av_freep(&ctx->par_out->extradata);
-ctx->par_out->extradata_size = 0;
+/* Validate the extradata if the stream is already MPEG-4 AudioSpecificConfig */
+if (ctx->par_in->extradata) {
+MPEG4AudioConfig mp4ac;
+int ret = avpriv_mpeg4audio_get_config(&mp4ac, ctx->par_in->extradata,
+   ctx->par_in->extradata_size * 8, 1);
+if (ret < 0) {
+av_log(ctx, AV_LOG_ERROR, "Error parsing AudioSpecificConfig extradata!\n");
+return ret;
+}
+}
 
 return 0;
 }
-- 
2.10.2

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

[libav-devel] [PATCH] mpeg4audio: correctly propagate meaningful error values

2016-11-30 Thread James Almer
Signed-off-by: James Almer 
---
Needed since 45d199d5 because av_bsf_init() should return actual
AVERROR values.

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

diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c
index 2363cb6..af8e655 100644
--- a/libavcodec/mpeg4audio.c
+++ b/libavcodec/mpeg4audio.c
@@ -33,10 +33,10 @@
 static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c)
 {
 if (get_bits_left(gb) < 112)
-return -1;
+return AVERROR_INVALIDDATA;
 
 if (get_bits_long(gb, 32) != MKBETAG('A','L','S','\0'))
-return -1;
+return AVERROR_INVALIDDATA;
 
 // override AudioSpecificConfig channel configuration and sample rate
 // which are buggy in old ALS conformance files
@@ -116,8 +116,9 @@ int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const 
uint8_t *buf,
 
 specific_config_bitindex = get_bits_count(&gb);
 
-if (parse_config_ALS(&gb, c))
-return -1;
+ret = parse_config_ALS(&gb, c);
+if (ret < 0)
+return ret;
 }
 
 if (c->ext_object_type != AOT_SBR && sync_extension) {
-- 
2.10.2

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


Re: [libav-devel] [PATCH] avutil/tests: Add the cpu_init.c test

2016-12-01 Thread James Almer
On 12/1/2016 3:47 PM, Diego Biurrun wrote:
> On Thu, Dec 01, 2016 at 10:22:24AM -0800, Wan-Teh Chang wrote:
>> --- /dev/null
>> +++ b/libavutil/tests/cpu_init.c
>> @@ -0,0 +1,72 @@
>> +int main(int argc, char **argv)
> 
> argc and argv are unused.
> 
>> +{
>> +#if HAVE_PTHREADS
>> +int cpu_flags1;
>> +int cpu_flags2;
>> +int ret;
>> +pthread_t thread1;
>> +pthread_t thread2;
>> +
>> +if ((ret = pthread_create(&thread1, NULL, thread_main, &cpu_flags1))) {
>> +fprintf(stderr, "pthread_create failed: %s.\n", strerror(ret));
>> +return 1;
>> +}
>> +if ((ret = pthread_create(&thread2, NULL, thread_main, &cpu_flags2))) {
>> +fprintf(stderr, "pthread_create failed: %s.\n", strerror(ret));
>> +return 1;
>> +}
>> +pthread_join(thread1, NULL);
>> +pthread_join(thread2, NULL);
>> +
>> +if (cpu_flags1 < 0)
>> +return 2;
>> +if (cpu_flags2 < 0)
>> +return 2;
>> +if (cpu_flags1 != cpu_flags2)
>> +return 3;
>> +#endif
>> +
>> +return 0;
>> +}
> 
> It seems a bit silly to have an empty test in the no pthreads case.
> I'd suggest building and running the test conditional on pthreads
> instead.
> 
> Diego

It also should check for threads, not just pthreads. It's using functions
the w32threads and os2threads compat wrappers provide.

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


Re: [libav-devel] [PATCH] compat/atomics: add support for the new memory model aware gcc built-ins

2016-12-02 Thread James Almer
On 12/1/2016 4:11 PM, Wan-Teh Chang wrote:
> From: James Almer 
> 
> __sync built-ins are considered legacy and will be deprecated.
> These new memory model aware built-ins have been available since GCC 4.7.0
> 
> Use them by default when available except for __atomic_compare_exchange_n(),
> which is slower, and is instead implemented as a fallback for when and if gcc
> removes the legacy __sync built-ins.
> 
> This patch merges FFmpeg commit faa9d2982969c999ab0e443a226eff116f7f8e4b.
> 
> Signed-off-by: Wan-Teh Chang 
> ---
>  compat/atomics/gcc/stdatomic.h | 22 ++
>  configure  |  4 +++-
>  2 files changed, 25 insertions(+), 1 deletion(-)

I agree with Anton, this is extra complexity for no real gain anymore.

This patch became superfluous once the c11 atomics set was committed. I was
in fact going to revert it on ffmpeg by the time the c11 set was to be merged.

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


[libav-devel] [PATCH] dump: be more verbose when printing spherical metadata information

2016-12-15 Thread James Almer
Signed-off-by: James Almer 
---
This prints

spherical: equirectangular, yaw=0.00, pitch=0.00, roll=0.00

Instead of

spherical: equirectangular (0.00/0.00/0.00)

 libavformat/dump.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/dump.c b/libavformat/dump.c
index 660df0a..ed48746 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -318,9 +318,9 @@ static void dump_spherical(void *ctx, AVPacketSideData *sd)
 }
 
 if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR)
-av_log(ctx, AV_LOG_INFO, "equirectangular ");
+av_log(ctx, AV_LOG_INFO, "equirectangular, ");
 else if (spherical->projection == AV_SPHERICAL_CUBEMAP)
-av_log(ctx, AV_LOG_INFO, "cubemap ");
+av_log(ctx, AV_LOG_INFO, "cubemap, ");
 else {
 av_log(ctx, AV_LOG_WARNING, "unknown");
 return;
@@ -329,7 +329,7 @@ static void dump_spherical(void *ctx, AVPacketSideData *sd)
 yaw = ((double)spherical->yaw) / (1 << 16);
 pitch = ((double)spherical->pitch) / (1 << 16);
 roll = ((double)spherical->roll) / (1 << 16);
-av_log(ctx, AV_LOG_INFO, "(%f/%f/%f) ", yaw, pitch, roll);
+av_log(ctx, AV_LOG_INFO, "yaw=%f, pitch=%f, roll=%f ", yaw, pitch, roll);
 }
 
 static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
-- 
2.10.2

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


Re: [libav-devel] [PATCH 1/5] avconv: dxva2: factorize some code that can be common with d3d11va

2016-12-15 Thread James Almer
On 12/15/2016 2:52 PM, Diego Biurrun wrote:
> On Thu, Dec 15, 2016 at 06:01:42PM +0100, Steve Lhomme wrote:
>> From: Steve Lhomme 
>>
>> avconv_dxva.h has to be included and misc. typedefs have to be set to use the
>> proper DXVA2 structures.
>>
>> initguid.h is included in avconv_dxva.h so any includes after that will also
>> define GUIDs locally.
>> ---
>>  avconv_dxva.h  | 294 
>> +
>>  avconv_dxva2.c | 277 +
>>  2 files changed, 340 insertions(+), 231 deletions(-)
>>  create mode 100644 avconv_dxva.h
> 
> Does this pass "make check"?
> 
>> --- /dev/null
>> +++ b/avconv_dxva.h
>> @@ -0,0 +1,294 @@
>> +
>> +#ifndef AVCONV_DXVA_H
>> +#define AVCONV_DXVA_H
> 
> Probably dxva2.h would be a better file name.

It's meant to be shared between dxva2 and d3d11, so avconv_dxva.[hc] IMO
works fine as a generic middle ground.

> 
>> +static int dxva_get_decoder_configuration(AVCodecContext *s,
>> +  const DXVA_DECODER_CONFIG 
>> *cfg_list,
>> +  unsigned cfg_count,
>> +  DXVA_DECODER_CONFIG *config)
> 
> You are putting static functions in a header file. They will be duplicated
> in the object code if you #include this from the d3d11va code as well.
> 
>> --- a/avconv_dxva2.c
>> +++ b/avconv_dxva2.c
>> @@ -43,52 +43,6 @@
>>  #include "libavutil/hwcontext.h"
>>  #include "libavutil/hwcontext_dxva2.h"
>>  
>> -/* define all the GUIDs used directly here,
>> -   to avoid problems with inconsistent dxva2api.h versions in mingw-w64 and 
>> different MSVC version */
>> -#include 
>> -DEFINE_GUID(IID_IDirectXVideoDecoderService, 
>> 0xfc51a551,0xd5e7,0x11d9,0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02);
>> -
>> @@ -102,55 +56,24 @@ typedef struct DXVA2Context {
>>  AVBufferRef *hw_frames_ctx;
>>  } DXVA2Context;
>>  
>> +typedef DXVA2_ConfigPictureDecode   DXVA_DECODER_CONFIG;
>> +typedef D3DFORMAT   DXVA_SURFACE_FORMAT;
>> +typedef DXVA2ContextDXVA_CONTEXT;
>> +typedef struct dxva_context DXVA_AV_CONTEXT;
>> +typedef IDirectXVideoDecoderService *DXVA_DECODER_SERVICE;
>> +#include "avconv_dxva.h"
> 
> Why is the #include down here? And please at least leave an empty line above 
> it.
> 
>> +DEFINE_GUID(IID_IDirectXVideoDecoderService, 
>> 0xfc51a551,0xd5e7,0x11d9,0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02);
> 
> Why do you move this DEFINE down?
> 
> Diego
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
> 

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


Re: [libav-devel] [PATCH] dump: be more verbose when printing spherical metadata information

2016-12-16 Thread James Almer
On 12/16/2016 1:04 PM, Vittorio Giovara wrote:
> On Thu, Dec 15, 2016 at 5:56 PM, James Almer  wrote:
>> Signed-off-by: James Almer 
>> ---
>> This prints
>>
>> spherical: equirectangular, yaw=0.00, pitch=0.00, roll=0.00
>>
>> Instead of
>>
>> spherical: equirectangular (0.00/0.00/0.00)
> 
> Hey James,
> I wasn't too verbose in dump.c because i thought that this should be a
> summary of what the metadata is, not a full description, and I didn't
> want to leave the possibility of letting parsing the output of the
> command. For more descriptive naming one should use any of the -of
> options. Do you think it makes sense? If not, why do you think this is
> necessary?
> Cheers

I don't think it's necessary, i just thought it would be nicer to know
what those values actually mean.
ReplayGain, Mastering Display and such all show the name for the values
they print, so i figured Spherical should do the same.

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


Re: [libav-devel] [PATCH] build: Move build-system-related helper files to a separate subdirectory

2016-12-24 Thread James Almer
On 12/22/2016 9:07 AM, Diego Biurrun wrote:
> This unclutters the top-level directory and groups related files together.
> ---
> 
> Now with "avbuild" as directory to store files in instead of "build".

Shouldn't it the the other way around? The build system is what should
be in the top level directory, and everything else moved instead.
What almost every other project does is keep the build system in the
top level, and place the actual library and cli source files inside a
src/ folder.

In libav's case, it would look something like

libav/
libav/Changelog
libav/configure
libav/Makefile
libav/README
...
libav/compat/
libav/doc/
libav/tests/
libav/tools/
libav/src/
libav/src/av{conv,play,probe}.*
libav/src/cmdutils.*
libav/src/libavcodec/
libav/src/libavformat/
...

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


Re: [libav-devel] [PATCH 4/6] h264dec: be more explicit in handling container cropping

2017-01-10 Thread James Almer
On 1/10/2017 6:26 AM, wm4 wrote:
> On Tue, 10 Jan 2017 09:01:12 +0100
> Anton Khirnov  wrote:
> 
>> The current condition can trigger in cases where it shouldn't, with
>> unexpected results.
>> Make sure that:
>> - container cropping is really based on the original dimensions from the
>>   caller
>> - those dimenions are discarded on size change
>>
>> The code is still quite hacky and eventually should be deprecated and
>> removed, with the decision about which cropping is used delegated to the
>> caller.
>> ---
>>  libavcodec/h264_slice.c | 15 +++
>>  libavcodec/h264dec.c|  3 +++
>>  libavcodec/h264dec.h|  5 +
>>  3 files changed, 19 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
>> index 1b35c2b..a54d381 100644
>> --- a/libavcodec/h264_slice.c
>> +++ b/libavcodec/h264_slice.c
>> @@ -378,6 +378,8 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
>>  h->avctx->coded_width   = h1->avctx->coded_width;
>>  h->avctx->width = h1->avctx->width;
>>  h->avctx->height= h1->avctx->height;
>> +h->width_from_caller= h1->width_from_caller;
>> +h->height_from_caller   = h1->height_from_caller;
>>  h->coded_picture_number = h1->coded_picture_number;
>>  h->first_field  = h1->first_field;
>>  h->picture_structure= h1->picture_structure;
>> @@ -797,10 +799,15 @@ static int init_dimensions(H264Context *h)
>>  int height = h->height - (sps->crop_top   + sps->crop_bottom);
>>  
>>  /* handle container cropping */
>> -if (FFALIGN(h->avctx->width,  16) == FFALIGN(width,  16) &&
>> -FFALIGN(h->avctx->height, 16) == FFALIGN(height, 16)) {
>> -width  = h->avctx->width;
>> -height = h->avctx->height;
>> +if (h->width_from_caller > 0 && h->height_from_caller > 0 &&
>> +!sps->crop_top && !sps->crop_left &&
>> +FFALIGN(h->width_from_caller,  16) == FFALIGN(width,  16) &&
>> +FFALIGN(h->height_from_caller, 16) == FFALIGN(height, 16)) {
>> +width  = h->width_from_caller;
>> +height = h->height_from_caller;
>> +} else {
>> +h->width_from_caller  = 0;
>> +h->height_from_caller = 0;
>>  }
>>  
>>  h->avctx->coded_width  = h->width;
>> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
>> index e111d40..3209c1d 100644
>> --- a/libavcodec/h264dec.c
>> +++ b/libavcodec/h264dec.c
>> @@ -285,6 +285,9 @@ static int h264_init_context(AVCodecContext *avctx, 
>> H264Context *h)
>>  
>>  h->avctx = avctx;
>>  
>> +h->width_from_caller = avctx->width;
>> +h->height_from_caller= avctx->height;
>> +
>>  h->picture_structure = PICT_FRAME;
>>  h->workaround_bugs   = avctx->workaround_bugs;
>>  h->flags = avctx->flags;
>> diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
>> index 5957e79..0a9896a 100644
>> --- a/libavcodec/h264dec.h
>> +++ b/libavcodec/h264dec.h
>> @@ -514,6 +514,11 @@ typedef struct H264Context {
>>   * the slice data */
>>  int field_started;
>>  
>> +/* original AVCodecContext dimensions, used to handle container
>> + * cropping */
>> +int width_from_caller;
>> +int height_from_caller;
>> +
>>  AVFrame *output_frame;
>>  
>>  int enable_er;
> 
> Is this kind of cropping even commonly used? Which containers?

Matroska.

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

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

Re: [libav-devel] [PATCH 5/5] mkv: Export bounds and padding from spherical metadata

2017-02-10 Thread James Almer
On 2/10/2017 6:08 PM, Vittorio Giovara wrote:
> ---
>  libavformat/matroskadec.c | 34 +-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index a44ceeb..ebfd414 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -1601,17 +1601,34 @@ static int mkv_parse_video_projection(AVStream *st, 
> const MatroskaTrack *track)
>  AVSphericalMapping *spherical;
>  enum AVSphericalProjection projection;
>  size_t spherical_size;
> +size_t l, t, r, b;
> +size_t padding = 0;
>  int ret;
> +GetByteContext gb;
> +
> +bytestream2_init(&gb, track->video.projection.private.data,
> + track->video.projection.private.size);
>  
>  switch (track->video.projection.type) {
>  case MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR:
> -projection = AV_SPHERICAL_EQUIRECTANGULAR;
> +if (track->video.projection.private.size == 0)
> +projection = AV_SPHERICAL_EQUIRECTANGULAR;
> +else {
> +projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE;
> +bytestream2_skip(&gb, 4); // version + flags

Since now we care about the contents of ProjectPrivate, better check
that version == 0 and track->video.projection.private.size == 20, and
abort warning about unsupported version or invalid data otherwise.

> +t = bytestream2_get_be32(&gb);
> +b = bytestream2_get_be32(&gb);
> +l = bytestream2_get_be32(&gb);
> +r = bytestream2_get_be32(&gb);
> +}
>  break;
>  case MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP:
>  if (track->video.projection.private.size < 4) {
>  av_log(NULL, AV_LOG_ERROR, "Missing projection private 
> properties\n");
>  return AVERROR_INVALIDDATA;
>  }
> +bytestream2_skip(&gb, 4); // layout

First 4 bytes are version + flags. And like with equi, make sure
version == 0 and size == 12, and abort otherwise.

> +padding = bytestream2_get_be32(&gb);
>  projection = AV_SPHERICAL_CUBEMAP;
>  break;
>  default:
> @@ -1627,6 +1644,21 @@ static int mkv_parse_video_projection(AVStream *st, 
> const MatroskaTrack *track)
>  spherical->pitch = (int32_t)(track->video.projection.pitch * (1 << 16));
>  spherical->roll  = (int32_t)(track->video.projection.roll  * (1 << 16));
>  
> +spherical->padding = padding;
> +
> +if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
> +/* conversion from 0.32 coordinates to pixels */
> +uint32_t max_coord = (uint32_t) -1;

UINT32_MAX?

> +size_t orig_width  = (size_t) track->video.pixel_width  * max_coord 
> / (max_coord - r - l);
> +size_t orig_height = (size_t) track->video.pixel_height * max_coord 
> / (max_coord - b - t);
> +
> +/* add a (max_coord - 1) to round up integer division */
> +spherical->left_bound   = (orig_width  * l + max_coord - 1) / 
> max_coord;
> +spherical->top_bound= (orig_height * t + max_coord - 1) / 
> max_coord;
> +spherical->right_bound  = orig_width  - track->video.pixel_width  - 
> spherical->left_bound;
> +spherical->bottom_bound = orig_height - track->video.pixel_height - 
> spherical->top_bound;
> +}
> +
>  ret = av_stream_add_side_data(st, AV_PKT_DATA_SPHERICAL, (uint8_t 
> *)spherical,
>spherical_size);
>  if (ret < 0)
> 

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

Re: [libav-devel] [PATCH 5/5] mkv: Export bounds and padding from spherical metadata

2017-02-10 Thread James Almer
On 2/10/2017 6:37 PM, James Almer wrote:
> On 2/10/2017 6:08 PM, Vittorio Giovara wrote:
>> ---
>>  libavformat/matroskadec.c | 34 +-
>>  1 file changed, 33 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> index a44ceeb..ebfd414 100644
>> --- a/libavformat/matroskadec.c
>> +++ b/libavformat/matroskadec.c
>> @@ -1601,17 +1601,34 @@ static int mkv_parse_video_projection(AVStream *st, 
>> const MatroskaTrack *track)
>>  AVSphericalMapping *spherical;
>>  enum AVSphericalProjection projection;
>>  size_t spherical_size;
>> +size_t l, t, r, b;
>> +size_t padding = 0;
>>  int ret;
>> +GetByteContext gb;
>> +
>> +bytestream2_init(&gb, track->video.projection.private.data,
>> + track->video.projection.private.size);
>>  
>>  switch (track->video.projection.type) {
>>  case MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR:
>> -projection = AV_SPHERICAL_EQUIRECTANGULAR;
>> +if (track->video.projection.private.size == 0)
>> +projection = AV_SPHERICAL_EQUIRECTANGULAR;
>> +else {
>> +projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE;
>> +bytestream2_skip(&gb, 4); // version + flags
> 
> Since now we care about the contents of ProjectPrivate, better check
> that version == 0 and track->video.projection.private.size == 20, and
> abort warning about unsupported version or invalid data otherwise.
> 
>> +t = bytestream2_get_be32(&gb);
>> +b = bytestream2_get_be32(&gb);
>> +l = bytestream2_get_be32(&gb);
>> +r = bytestream2_get_be32(&gb);

I forgot. t, b, l and r may be zero, so you must check for that like
you did with the mov demuxer. If they are, then this is a non tiled
equi projection created by a muxer that didn't know/care it could skip
this element for such projection.

>> +}
>>  break;
>>  case MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP:
>>  if (track->video.projection.private.size < 4) {
>>  av_log(NULL, AV_LOG_ERROR, "Missing projection private 
>> properties\n");
>>  return AVERROR_INVALIDDATA;
>>  }
>> +bytestream2_skip(&gb, 4); // layout
> 
> First 4 bytes are version + flags. And like with equi, make sure
> version == 0 and size == 12, and abort otherwise.
> 
>> +padding = bytestream2_get_be32(&gb);
>>  projection = AV_SPHERICAL_CUBEMAP;
>>  break;
>>  default:
>> @@ -1627,6 +1644,21 @@ static int mkv_parse_video_projection(AVStream *st, 
>> const MatroskaTrack *track)
>>  spherical->pitch = (int32_t)(track->video.projection.pitch * (1 << 16));
>>  spherical->roll  = (int32_t)(track->video.projection.roll  * (1 << 16));
>>  
>> +spherical->padding = padding;
>> +
>> +if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
>> +/* conversion from 0.32 coordinates to pixels */
>> +uint32_t max_coord = (uint32_t) -1;
> 
> UINT32_MAX?
> 
>> +size_t orig_width  = (size_t) track->video.pixel_width  * max_coord 
>> / (max_coord - r - l);
>> +size_t orig_height = (size_t) track->video.pixel_height * max_coord 
>> / (max_coord - b - t);
>> +
>> +/* add a (max_coord - 1) to round up integer division */
>> +spherical->left_bound   = (orig_width  * l + max_coord - 1) / 
>> max_coord;
>> +spherical->top_bound= (orig_height * t + max_coord - 1) / 
>> max_coord;
>> +spherical->right_bound  = orig_width  - track->video.pixel_width  - 
>> spherical->left_bound;
>> +spherical->bottom_bound = orig_height - track->video.pixel_height - 
>> spherical->top_bound;
>> +}
>> +
>>  ret = av_stream_add_side_data(st, AV_PKT_DATA_SPHERICAL, (uint8_t 
>> *)spherical,
>>spherical_size);
>>  if (ret < 0)
>>
> 

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

[libav-devel] [PATCH 2/2] apetag: account for header size if present when returning the start position

2017-02-10 Thread James Almer
The size field in the header/footer accounts for the entire APE tag
structure except the 32 bytes from header, for compatibility with
APEv1.

Signed-off-by: James Almer 
---
 libavformat/apetag.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 93a4fb343..a7cf8530f 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -31,6 +31,7 @@
 
 #define APE_TAG_VERSION   2000
 #define APE_TAG_FOOTER_BYTES  32
+#define APE_TAG_HEADER_BYTES  32
 #define APE_TAG_FLAG_CONTAINS_HEADER  (1 << 31)
 #define APE_TAG_FLAG_LACKS_FOOTER (1 << 30)
 #define APE_TAG_FLAG_IS_HEADER(1 << 29)
@@ -154,7 +155,6 @@ int64_t ff_ape_parse_tag(AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "Invalid tag size %"PRIu32".\n", tag_bytes);
 return 0;
 }
-tag_start = file_size - tag_bytes - APE_TAG_FOOTER_BYTES;
 
 fields = avio_rl32(pb);/* number of fields */
 if (fields > 65536) {
@@ -170,6 +170,11 @@ int64_t ff_ape_parse_tag(AVFormatContext *s)
 
 avio_seek(pb, file_size - tag_bytes, SEEK_SET);
 
+if (val & APE_TAG_FLAG_CONTAINS_HEADER)
+tag_bytes += APE_TAG_HEADER_BYTES;
+
+tag_start = file_size - tag_bytes;
+
 for (i=0; ihttps://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 1/2] apetag: fix flag value to signal footer presence

2017-02-10 Thread James Almer
According to the spec[1], a value of 0 means the footer is present and a value
of 1 means it's absent, the exact opposite of header presence flag where 1
means present and 0 absent.
The reason for this is compatibility with APEv1 tags, where there's no header,
footer presence was mandatory for all files, and the flags field was a zeroed
reserved field.

[1] http://wiki.hydrogenaud.io/index.php?title=Ape_Tags_Flags

Signed-off-by: James Almer 
---
Files already created are obviously wrong, but fortunately having the flag
mistakenly reporting there's no footer is harmless in APEv2 tags stored at
the end of the file (The only kind we can read and write), since footer is
mandatory in those and as such no software really bothers looking at the
flag.

I renamed the constant just to have it as reference, or until someone feels
like adding support for APEv2 tags at the beginning of a file, where footer
becomes optional.

 libavformat/apetag.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 05430dd9b..93a4fb343 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -32,7 +32,7 @@
 #define APE_TAG_VERSION   2000
 #define APE_TAG_FOOTER_BYTES  32
 #define APE_TAG_FLAG_CONTAINS_HEADER  (1 << 31)
-#define APE_TAG_FLAG_CONTAINS_FOOTER  (1 << 30)
+#define APE_TAG_FLAG_LACKS_FOOTER (1 << 30)
 #define APE_TAG_FLAG_IS_HEADER(1 << 29)
 #define APE_TAG_FLAG_IS_BINARY(1 << 1)
 
@@ -194,8 +194,7 @@ int ff_ape_write_tag(AVFormatContext *s)
 avio_wl32(s->pb, 0);// reserve space for tag count
 
 // flags
-avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | 
APE_TAG_FLAG_CONTAINS_FOOTER |
- APE_TAG_FLAG_IS_HEADER);
+avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_IS_HEADER);
 ffio_fill(s->pb, 0, 8); // reserved
 
 while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
@@ -217,7 +216,7 @@ int ff_ape_write_tag(AVFormatContext *s)
 avio_wl32(s->pb, count);// tag count
 
 // flags
-avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | 
APE_TAG_FLAG_CONTAINS_FOOTER);
+avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER);
 ffio_fill(s->pb, 0, 8); // reserved
 
 // update values in the header
-- 
2.11.0

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

Re: [libav-devel] [PATCH 2/5] matroskadec: add support for Spherical Video elements

2017-02-15 Thread James Almer
On 2/15/2017 4:28 AM, Anton Khirnov wrote:
> Quoting Vittorio Giovara (2017-02-10 22:08:08)
>> From: James Almer 
>>
>> Signed-off-by: James Almer 
>> Signed-off-by: Vittorio Giovara 
>> ---
>>  libavformat/matroska.h| 14 +++
>>  libavformat/matroskadec.c | 63 
>> +++
>>  2 files changed, 77 insertions(+)
>>
> 
> I don't see this in the spec. Is this standard?

Yes, https://matroska.org/technical/specs/index.html is outdated.

See instead
https://github.com/Matroska-Org/matroska-specification
https://github.com/Matroska-Org/libmatroska

> 
>> diff --git a/libavformat/matroska.h b/libavformat/matroska.h
>> index 91bb978..4e9f96e 100644
>> --- a/libavformat/matroska.h
>> +++ b/libavformat/matroska.h
>> @@ -118,6 +118,13 @@
>>  #define MATROSKA_ID_VIDEOASPECTRATIO 0x54B3
>>  #define MATROSKA_ID_VIDEOCOLORSPACE 0x2EB524
>>  
>> +#define MATROSKA_ID_VIDEOPROJECTION 0x7670
>> +#define MATROSKA_ID_VIDEOPROJECTIONTYPE 0x7671
>> +#define MATROSKA_ID_VIDEOPROJECTIONPRIVATE 0x7672
>> +#define MATROSKA_ID_VIDEOPROJECTIONPOSEYAW 0x7673
>> +#define MATROSKA_ID_VIDEOPROJECTIONPOSEPITCH 0x7674
>> +#define MATROSKA_ID_VIDEOPROJECTIONPOSEROLL 0x7675
>> +
>>  /* IDs in the trackaudio master */
>>  #define MATROSKA_ID_AUDIOSAMPLINGFREQ 0xB5
>>  #define MATROSKA_ID_AUDIOOUTSAMPLINGFREQ 0x78B5
>> @@ -256,6 +263,13 @@ typedef enum {
>>MATROSKA_VIDEO_STEREOMODE_TYPE_NB,
>>  } MatroskaVideoStereoModeType;
>>  
>> +typedef enum {
>> +  MATROSKA_VIDEO_PROJECTION_TYPE_RECTANGULAR= 0,
>> +  MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR= 1,
>> +  MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP= 2,
>> +  MATROSKA_VIDEO_PROJECTION_TYPE_MESH   = 3,
>> +} MatroskaVideoProjectionType;
>> +
>>  /*
>>   * Matroska Codec IDs, strings
>>   */
>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> index 4e121b6..a44ceeb 100644
>> --- a/libavformat/matroskadec.c
>> +++ b/libavformat/matroskadec.c
>> @@ -45,6 +45,7 @@
>>  #include "libavutil/intreadwrite.h"
>>  #include "libavutil/lzo.h"
>>  #include "libavutil/mathematics.h"
>> +#include "libavutil/spherical.h"
>>  
>>  #include "libavcodec/bytestream.h"
>>  #include "libavcodec/flac.h"
>> @@ -116,6 +117,14 @@ typedef struct MatroskaTrackEncoding {
>>  MatroskaTrackCompression compression;
>>  } MatroskaTrackEncoding;
>>  
>> +typedef struct MatroskaTrackVideoProjection {
>> +uint64_t type;
>> +EbmlBin private;
>> +double yaw;
>> +double pitch;
>> +double roll;
>> +} MatroskaTrackVideoProjection;
>> +
>>  typedef struct MatroskaTrackVideo {
>>  double   frame_rate;
>>  uint64_t display_width;
>> @@ -126,6 +135,7 @@ typedef struct MatroskaTrackVideo {
>>  uint64_t interlaced;
>>  uint64_t field_order;
>>  uint64_t stereo_mode;
>> +MatroskaTrackVideoProjection projection;
>>  } MatroskaTrackVideo;
>>  
>>  typedef struct MatroskaTrackAudio {
>> @@ -309,6 +319,15 @@ static EbmlSyntax matroska_info[] = {
>>  { 0 }
>>  };
>>  
>> +static const EbmlSyntax matroska_track_video_projection[] = {
>> +{ MATROSKA_ID_VIDEOPROJECTIONTYPE,  EBML_UINT,  0, 
>> offsetof(MatroskaTrackVideoProjection, type), { .u = 
>> MATROSKA_VIDEO_PROJECTION_TYPE_RECTANGULAR } },
>> +{ MATROSKA_ID_VIDEOPROJECTIONPRIVATE,   EBML_BIN,   0, 
>> offsetof(MatroskaTrackVideoProjection, private) },
>> +{ MATROSKA_ID_VIDEOPROJECTIONPOSEYAW,   EBML_FLOAT, 0, 
>> offsetof(MatroskaTrackVideoProjection, yaw), { .f=0.0 } },
>> +{ MATROSKA_ID_VIDEOPROJECTIONPOSEPITCH, EBML_FLOAT, 0, 
>> offsetof(MatroskaTrackVideoProjection, pitch), { .f=0.0 } },
>> +{ MATROSKA_ID_VIDEOPROJECTIONPOSEROLL,  EBML_FLOAT, 0, 
>> offsetof(MatroskaTrackVideoProjection, roll), { .f=0.0 } },
>> +{ 0 }
>> +};
>> +
>>  static EbmlSyntax matroska_track_video[] = {
>>  { MATROSKA_ID_VIDEOFRAMERATE,  EBML_FLOAT, 0, 
>> offsetof(MatroskaTrackVideo, frame_rate) },
>>  { MATROSKA_ID_VIDEODISPLAYWIDTH,   EBML_UINT,  0, 
>> offsetof(MatroskaTrackVideo, display_width) },
>> @@ -316,6 +335,7 @@ static EbmlSyntax matroska_track_video[] = {
>>  { MATROSKA_ID_VIDEOPIXELWIDTH, EBML_UINT,  0, 
>> offsetof(MatroskaTrackVideo, pixel_width) },
>>  { MATROSK

[libav-devel] [PATCH] matroskaenc: add support for Spherical Video elements

2017-03-09 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/matroskaenc.c | 81 +++
 libavformat/version.h |  2 +-
 2 files changed, 82 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 2fe6e0ed4..fb1b86168 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -24,6 +24,7 @@
 #include "avc.h"
 #include "hevc.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include "avlanguage.h"
 #include "flacenc.h"
 #include "internal.h"
@@ -44,6 +45,7 @@
 #include "libavutil/random_seed.h"
 #include "libavutil/samplefmt.h"
 #include "libavutil/stereo3d.h"
+#include "libavutil/spherical.h"
 
 #include "libavcodec/xiph.h"
 #include "libavcodec/mpeg4audio.h"
@@ -646,6 +648,82 @@ static int mkv_write_codecprivate(AVFormatContext *s, 
AVIOContext *pb,
 return ret;
 }
 
+static int mkv_write_video_projection(AVFormatContext *s, AVIOContext *pb, 
AVStream *st)
+{
+int side_data_size = 0;
+const AVSphericalMapping *spherical =
+(const AVSphericalMapping*) av_stream_get_side_data(st, 
AV_PKT_DATA_SPHERICAL,
+&side_data_size);
+
+if (side_data_size) {
+AVIOContext *dyn_cp;
+uint8_t *projection_ptr;
+int ret, projection_size;
+
+ret = avio_open_dyn_buf(&dyn_cp);
+if (ret < 0)
+return ret;
+
+switch (spherical->projection) {
+case AV_SPHERICAL_EQUIRECTANGULAR:
+put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONTYPE,
+  MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR);
+break;
+case AV_SPHERICAL_EQUIRECTANGULAR_TILE:
+{
+AVIOContext b;
+uint8_t private[20];
+ffio_init_context(&b, private, sizeof(private),
+  1, NULL, NULL, NULL, NULL);
+put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONTYPE,
+  MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR);
+avio_wb32(&b, 0); // version + flags
+avio_wb32(&b, spherical->bound_top);
+avio_wb32(&b, spherical->bound_bottom);
+avio_wb32(&b, spherical->bound_left);
+avio_wb32(&b, spherical->bound_right);
+put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE, 
private, sizeof(private));
+break;
+}
+case AV_SPHERICAL_CUBEMAP:
+{
+AVIOContext b;
+uint8_t private[12];
+ffio_init_context(&b, private, sizeof(private),
+  1, NULL, NULL, NULL, NULL);
+put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONTYPE,
+  MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP);
+avio_wb32(&b, 0); // version + flags
+avio_wb32(&b, 0); // layout
+avio_wb32(&b, spherical->padding);
+put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE, 
private, sizeof(private));
+break;
+}
+default:
+av_log(s, AV_LOG_WARNING, "Unknown projection type\n");
+goto end;
+}
+
+if (spherical->yaw)
+put_ebml_float(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPOSEYAW,   
(double)spherical->yaw   / (1 << 16));
+if (spherical->pitch)
+put_ebml_float(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPOSEPITCH, 
(double)spherical->pitch / (1 << 16));
+if (spherical->roll)
+put_ebml_float(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPOSEROLL,  
(double)spherical->roll  / (1 << 16));
+
+end:
+projection_size = avio_close_dyn_buf(dyn_cp, &projection_ptr);
+if (projection_size) {
+ebml_master projection = start_ebml_master(pb, 
MATROSKA_ID_VIDEOPROJECTION, projection_size);
+avio_write(pb, projection_ptr, projection_size);
+end_ebml_master(pb, projection);
+}
+av_freep(&projection_ptr);
+}
+
+return 0;
+}
+
 static void mkv_write_field_order(AVIOContext *pb,
   enum AVFieldOrder field_order)
 {
@@ -897,6 +975,9 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 ret = mkv_write_stereo_mode(s, pb, st, mkv->mode);
 if (ret < 0)
 return ret;
+ret = mkv_write_video_projection(s, pb, st);
+if (ret < 0)
+return ret;
 
 end_ebml_master(pb, subinfo);
 break;
diff --git a/libavformat/version.h b/libavformat/version.h
index 3e28cc280..34650f6ec 100644
--- a/libavformat/version.h
+++ b/libavfo

[libav-devel] [PATCH 1/3] avutil/spherical: add functions to retrieve and request projection names

2017-04-04 Thread James Almer
Signed-off-by: James Almer 
---
 doc/APIchanges|  4 
 libavutil/spherical.c | 28 
 libavutil/spherical.h | 18 ++
 libavutil/version.h   |  2 +-
 4 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index a0ca3b7ac..09b4b3155 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2017-03-23
 
 API changes, most recent first:
 
+2017-04-xx - xxx - lavu 56.1.0 - spherical.h
+  Add av_spherical_projection_name().
+  Add av_spherical_from_name().
+
 2017-03-xx - xxx - lavc 57.37.0 - avcodec.h
   Add AVCodecContext.hwaccel_flags field. This will control some hwaccels at
   a later point.
diff --git a/libavutil/spherical.c b/libavutil/spherical.c
index f5accc487..7b03b09da 100644
--- a/libavutil/spherical.c
+++ b/libavutil/spherical.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "common.h"
 #include "mem.h"
 #include "spherical.h"
 
@@ -50,3 +51,30 @@ void av_spherical_tile_bounds(AVSphericalMapping *map,
 *right  = orig_width  - width  - *left;
 *bottom = orig_height - height - *top;
 }
+
+static const char *spherical_projection_names[] = {
+[AV_SPHERICAL_EQUIRECTANGULAR]  = "equirectangular",
+[AV_SPHERICAL_CUBEMAP]  = "cubemap",
+[AV_SPHERICAL_EQUIRECTANGULAR_TILE] = "tiled equirectangular",
+};
+
+const char *av_spherical_projection_name(enum AVSphericalProjection projection)
+{
+if ((unsigned)projection >= FF_ARRAY_ELEMS(spherical_projection_names))
+return "unknown";
+
+return spherical_projection_names[projection];
+}
+
+int av_spherical_from_name(const char *name)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(spherical_projection_names); i++) {
+size_t len = strlen(spherical_projection_names[i]);
+if (!strncmp(spherical_projection_names[i], name, len))
+return i;
+}
+
+return -1;
+}
diff --git a/libavutil/spherical.h b/libavutil/spherical.h
index fd662cf67..caa023fd4 100644
--- a/libavutil/spherical.h
+++ b/libavutil/spherical.h
@@ -206,6 +206,24 @@ void av_spherical_tile_bounds(AVSphericalMapping *map,
   size_t width, size_t height,
   size_t *left, size_t *top,
   size_t *right, size_t *bottom);
+
+/**
+ * Provide a human-readable name of a given AVSphericalProjection.
+ *
+ * @param projection The input AVSphericalProjection.
+ *
+ * @return The name of the AVSphericalProjection, or "unknown".
+ */
+const char *av_spherical_projection_name(enum AVSphericalProjection 
projection);
+
+/**
+ * Get the AVSphericalProjection form a human-readable name.
+ *
+ * @param name The input string.
+ *
+ * @return The AVSphericalProjection value, or -1 if not found.
+ */
+int av_spherical_from_name(const char *name);
 /**
  * @}
  * @}
diff --git a/libavutil/version.h b/libavutil/version.h
index b8425ea2c..fd72ff431 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR  0
+#define LIBAVUTIL_VERSION_MINOR  1
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.12.1

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

[libav-devel] [PATCH 2/3] dump: use av_spherical_projection_name() to print spherical projection names

2017-04-04 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/dump.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/libavformat/dump.c b/libavformat/dump.c
index c56895628..261e21efd 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -317,16 +317,7 @@ static void dump_spherical(void *ctx, AVCodecParameters 
*par, AVPacketSideData *
 return;
 }
 
-if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR)
-av_log(ctx, AV_LOG_INFO, "equirectangular ");
-else if (spherical->projection == AV_SPHERICAL_CUBEMAP)
-av_log(ctx, AV_LOG_INFO, "cubemap ");
-else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE)
-av_log(ctx, AV_LOG_INFO, "tiled equirectangular ");
-else {
-av_log(ctx, AV_LOG_WARNING, "unknown");
-return;
-}
+av_log(ctx, AV_LOG_INFO, "%s ", 
av_spherical_projection_name(spherical->projection));
 
 yaw = ((double)spherical->yaw) / (1 << 16);
 pitch = ((double)spherical->pitch) / (1 << 16);
-- 
2.12.1

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

[libav-devel] [PATCH 3/3] avprobe: use av_spherical_projection_name() to print spherical projection names

2017-04-04 Thread James Almer
Signed-off-by: James Almer 
---
 avtools/avprobe.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/avtools/avprobe.c b/avtools/avprobe.c
index 68f19220c..690c1397b 100644
--- a/avtools/avprobe.c
+++ b/avtools/avprobe.c
@@ -791,25 +791,21 @@ static void show_stream(InputFile *ifile, InputStream 
*ist)
 case AV_PKT_DATA_SPHERICAL:
 spherical = (AVSphericalMapping *)sd->data;
 probe_object_header("spherical");
+probe_str("projection", 
av_spherical_projection_name(spherical->projection));
 
-if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR) {
-probe_str("projection", "equirectangular");
-} else if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
-probe_str("projection", "cubemap");
+if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
 probe_int("padding", spherical->padding);
 } else if (spherical->projection == 
AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
 size_t l, t, r, b;
 av_spherical_tile_bounds(spherical, par->width, 
par->height,
  &l, &t, &r, &b);
-probe_str("projection", "tiled equirectangular");
 probe_object_header("bounding");
 probe_int("left", l);
 probe_int("top", t);
 probe_int("right", r);
 probe_int("bottom", b);
 probe_object_footer("bounding");
-} else
-probe_str("projection", "unknown");
+}
 
 probe_object_header("orientation");
 probe_int("yaw", (double) spherical->yaw / (1 << 16));
-- 
2.12.1

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

[libav-devel] [PATCH] matroskaenc: fix writing ProjectionPrivate element on Cubemap projections

2017-04-06 Thread James Almer
Calling put_ebml_binary() with sizeof(private) as argument is currently
only valid for Equirectangular projections.

Signed-off-by: James Almer 
---
Please, be more careful when making cosmetic changes to make sure they
don't also change how the code works.
Not only this was writing invalid Cubemap files, but also dumping
uninitialized data from stack in them.

 libavformat/matroskaenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 34d983324..f6dade751 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -696,7 +696,7 @@ static int mkv_write_video_projection(AVFormatContext *s, 
AVIOContext *pb,
 avio_wb32(&b, 0); // layout
 avio_wb32(&b, spherical->padding);
 put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
-private, sizeof(private));
+private, 12);
 break;
 default:
 av_log(s, AV_LOG_WARNING, "Unknown projection type\n");
-- 
2.12.1

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

Re: [libav-devel] [PATCH] matroska: Read only the data written in the scratch buffer

2017-04-07 Thread James Almer
On 4/7/2017 6:43 AM, Luca Barbato wrote:
> The private buffer is 20bytes but depending on the type only 12 bytes
> are actually filled.
> ---
> 
> Like this, in case somebody does a similar copy+paste.
> 
>  libavformat/matroskaenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 34d9833..b8c434a 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -686,7 +686,7 @@ static int mkv_write_video_projection(AVFormatContext *s, 
> AVIOContext *pb,
>  avio_wb32(&b, spherical->bound_left);
>  avio_wb32(&b, spherical->bound_right);
>  put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
> -private, sizeof(private));
> +private, avio_tell(&b));
>  break;
>  case AV_SPHERICAL_CUBEMAP:
>  ffio_init_context(&b, private, 12, 1, NULL, NULL, NULL, NULL);
> @@ -696,7 +696,7 @@ static int mkv_write_video_projection(AVFormatContext *s, 
> AVIOContext *pb,
>  avio_wb32(&b, 0); // layout
>  avio_wb32(&b, spherical->padding);
>  put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
> -private, sizeof(private));
> +private, avio_tell(&b));
>  break;
>  default:
>  av_log(s, AV_LOG_WARNING, "Unknown projection type\n");
> --
> 2.9.2

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

[libav-devel] [PATCH 1/3 v2] avutil/spherical: add functions to retrieve and request projection names

2017-04-07 Thread James Almer
Signed-off-by: James Almer 
---
 doc/APIchanges|  4 
 libavutil/spherical.c | 28 
 libavutil/spherical.h | 24 
 libavutil/version.h   |  2 +-
 4 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index a0ca3b7ac..bafac8b4a 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2017-03-23
 
 API changes, most recent first:
 
+2017-04-xx - xxx - lavu 56.1.0 - spherical.h
+  Add AV_SPHERICAL_UNKNOWN, av_spherical_projection_name(),
+  av_spherical_from_name().
+
 2017-03-xx - xxx - lavc 57.37.0 - avcodec.h
   Add AVCodecContext.hwaccel_flags field. This will control some hwaccels at
   a later point.
diff --git a/libavutil/spherical.c b/libavutil/spherical.c
index f5accc487..127d7e5b8 100644
--- a/libavutil/spherical.c
+++ b/libavutil/spherical.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "common.h"
 #include "mem.h"
 #include "spherical.h"
 
@@ -50,3 +51,30 @@ void av_spherical_tile_bounds(AVSphericalMapping *map,
 *right  = orig_width  - width  - *left;
 *bottom = orig_height - height - *top;
 }
+
+static const char *spherical_projection_names[] = {
+[AV_SPHERICAL_EQUIRECTANGULAR]  = "equirectangular",
+[AV_SPHERICAL_CUBEMAP]  = "cubemap",
+[AV_SPHERICAL_EQUIRECTANGULAR_TILE] = "tiled equirectangular",
+};
+
+const char *av_spherical_projection_name(enum AVSphericalProjection projection)
+{
+if ((unsigned)projection >= FF_ARRAY_ELEMS(spherical_projection_names))
+return "unknown";
+
+return spherical_projection_names[projection];
+}
+
+int av_spherical_from_name(const char *name)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(spherical_projection_names); i++) {
+size_t len = strlen(spherical_projection_names[i]);
+if (!strncmp(spherical_projection_names[i], name, len))
+return i;
+}
+
+return AV_SPHERICAL_UNKNOWN;
+}
diff --git a/libavutil/spherical.h b/libavutil/spherical.h
index fd662cf67..ffd52c69c 100644
--- a/libavutil/spherical.h
+++ b/libavutil/spherical.h
@@ -50,6 +50,11 @@
  */
 enum AVSphericalProjection {
 /**
+ * Unknown projection.
+ */
+AV_SPHERICAL_UNKNOWN = -1,
+
+/**
  * Video represents a sphere mapped on a flat surface using
  * equirectangular projection.
  */
@@ -206,6 +211,25 @@ void av_spherical_tile_bounds(AVSphericalMapping *map,
   size_t width, size_t height,
   size_t *left, size_t *top,
   size_t *right, size_t *bottom);
+
+/**
+ * Provide a human-readable name of a given AVSphericalProjection.
+ *
+ * @param projection The input AVSphericalProjection.
+ *
+ * @return The name of the AVSphericalProjection, or "unknown".
+ */
+const char *av_spherical_projection_name(enum AVSphericalProjection 
projection);
+
+/**
+ * Get the AVSphericalProjection form a human-readable name.
+ *
+ * @param name The input string.
+ *
+ * @return The AVSphericalProjection value if found, AV_SPHERICAL_UNKNOWN
+ * otherwise.
+ */
+int av_spherical_from_name(const char *name);
 /**
  * @}
  * @}
diff --git a/libavutil/version.h b/libavutil/version.h
index b8425ea2c..fd72ff431 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR  0
+#define LIBAVUTIL_VERSION_MINOR  1
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.12.1

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

Re: [libav-devel] [PATCH 2/8] libavutil: add mastering display metadata sidedata

2017-04-07 Thread James Almer
On 4/7/2017 1:48 PM, Vittorio Giovara wrote:
> On Fri, Apr 7, 2017 at 2:27 PM, Steve Lhomme  wrote:
>> + * @note The struct should be allocated with 
>> av_mastering_display_metadata_alloc()
>> + *   and its size is not a part of the public ABI.
>> + */
>> +typedef struct AVMasteringDisplayMetadata {
>> +} AVMasteringDisplayMetadata;
>> +
>> +/**
>> + * Allocate an AVMasteringDisplayMetadata structure and set its fields to
>> + * default values. The resulting struct can be freed using av_freep().
>> + *
>> + * @return An AVMasteringDisplayMetadata filled with default values or NULL
>> + * on failure.
>> + */
>> +AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
> 
> This signature might be problematic, it should host a size_t* which
> should be filled with the size of the struct, like it's done for other
> side data (except stereo3d for historical reasons).

That will mean different signature between projects.

And for that matter, why were you against me trying to add a replacement
alloc function with this parameter, then?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 2/8] libavutil: add mastering display metadata sidedata

2017-04-07 Thread James Almer
On 4/7/2017 3:20 PM, Vittorio Giovara wrote:
> On Fri, Apr 7, 2017 at 8:13 PM, James Almer  wrote:
>> On 4/7/2017 1:48 PM, Vittorio Giovara wrote:
>>> On Fri, Apr 7, 2017 at 2:27 PM, Steve Lhomme  wrote:
>>>> + * @note The struct should be allocated with 
>>>> av_mastering_display_metadata_alloc()
>>>> + *   and its size is not a part of the public ABI.
>>>> + */
>>>> +typedef struct AVMasteringDisplayMetadata {
>>>> +} AVMasteringDisplayMetadata;
>>>> +
>>>> +/**
>>>> + * Allocate an AVMasteringDisplayMetadata structure and set its fields to
>>>> + * default values. The resulting struct can be freed using av_freep().
>>>> + *
>>>> + * @return An AVMasteringDisplayMetadata filled with default values or 
>>>> NULL
>>>> + * on failure.
>>>> + */
>>>> +AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
>>>
>>> This signature might be problematic, it should host a size_t* which
>>> should be filled with the size of the struct, like it's done for other
>>> side data (except stereo3d for historical reasons).
>>
>> That will mean different signature between projects.
>>
>> And for that matter, why were you against me trying to add a replacement
>> alloc function with this parameter, then?
> 
> Because I don't think it's an issue big enough to warrant an API
> change over existing code.
> 
> On the other hand this new code in Libav so hopefully the code should
> be fixed before committing and there is no need to break anything.
> It's unfortunate that the signature will be different but either
> documentation or ABI is currently violated in ffmpeg, there is no need
> to replicate this behaviour in libav, in my opinion.

We could add a function that returns size for this and every other
similar struct, even if they already have an alloc function that
also returns the struct size like Spherical.
Something like that is in any case needed for av_*_new_side_data(),
as those function do their own memory allocation.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/3 v2] avutil/spherical: add functions to retrieve and request projection names

2017-04-10 Thread James Almer
On 4/10/2017 10:56 AM, Vittorio Giovara wrote:
> On Fri, Apr 7, 2017 at 10:22 AM, Luca Barbato  wrote:
>> On 07/04/2017 16:09, James Almer wrote:
>>> +int av_spherical_from_name(const char *name);
>>
>> It can directly output the enum now, it is fine both ways to me.
> 
> Wait a minute, I don't think PROJECTION_UNKNOWN makes much sense to
> me, given the API and the spec it's based on, and -1 seems not really
> informative anyway.

The doxy in the original patch states -1 means not found. It's also
what the same function in stereo3d returns.

> In my opinion it would be enough to return int and
> just AVERROR(EINVAL) in case it's not found. James would you be ok
> with that, or do you have any preference?

IMO, PROJECTION_UNKNOWN is an interesting addition.

Assume for example a projection we don't currently support shows up in
a file in the future, both the mov and matroska demuxers would ignore
it and report the file as having no spherical metadata whatsoever.
With PROJECTION_UNKNOWN the demuxers could report the presence of said
metadata (and the generic values yaw/pitch/roll) while clearly stating
it's unknown.
Muxers would of course keep behaving the same and just not mux unknown
spherical metadata.

But in any case, either -1 or EINVAL are ok with me if you don't like
the above.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/3 v2] avutil/spherical: add functions to retrieve and request projection names

2017-04-10 Thread James Almer
On 4/10/2017 1:20 PM, Vittorio Giovara wrote:
> On Mon, Apr 10, 2017 at 11:49 AM, James Almer  wrote:
>>> In my opinion it would be enough to return int and
>>> just AVERROR(EINVAL) in case it's not found. James would you be ok
>>> with that, or do you have any preference?
>>
>> IMO, PROJECTION_UNKNOWN is an interesting addition.
>>
>> Assume for example a projection we don't currently support shows up in
>> a file in the future, both the mov and matroska demuxers would ignore
>> it and report the file as having no spherical metadata whatsoever.
>> With PROJECTION_UNKNOWN the demuxers could report the presence of said
>> metadata (and the generic values yaw/pitch/roll) while clearly stating
>> it's unknown.
> 
> I mean, if it's unknown, no demuxer can parse correctly any field:
> nothing guarantees that future projections will keep y/p/r in the same
> place.

y/p/r are part of the prhd box in ISOBMFF. If that were to change,
the version field would be updated (We're currently skipping the
version field, so maybe we should add a check right now).
Projection specific boxes are currently cbmp, equi and mesh, which
makes me realize that we don't even need to think of hypothetical
future projections. For mesh files the unknown projection enum would
come in handy today.

In Matroska, y/p/r are standalone elements that may or may not be
present somewhere inside the Spherical master.

> Even so, what's the user going to do with knowing the fact that
> the video contains spherical metadata it can't parse correctly/fully
> support? So, I'm hesitant to add a new type for this uncertain
> behaviour, wouldn't you agree?

No, because that's the whole point of avprobe, the dump.c code, and
other tools using the libraries: Informing the user of the contents
and characteristics of their files.
avconv and similar tools are what attempt to do something with them,
and for unknown projections they would do nothing.

libavformat as it is right now will be aware that there's spherical
information in such files, but purposely pretend it's not there.
I personally think that's not the best behavior.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH] extract_extradata_bsf: make sure all needed parameter set NALUs were found

2017-04-14 Thread James Almer
This mimics the behavior of the now unused h264/hevc parser's split()
function and fixes decoding some files when extract_extradata bsf is
enabled.

Signed-off-by: James Almer 
---
 libavcodec/extract_extradata_bsf.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavcodec/extract_extradata_bsf.c 
b/libavcodec/extract_extradata_bsf.c
index 20b30803b..20840bd6a 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -65,7 +65,7 @@ static int extract_extradata_h2645(AVBSFContext *ctx, 
AVPacket *pkt,
 int extradata_size = 0;
 const int *extradata_nal_types;
 int nb_extradata_nal_types;
-int i, ret = 0;
+int i, has_sps = 0, has_vps = 0, ret = 0;
 
 if (ctx->par_in->codec_id == AV_CODEC_ID_HEVC) {
 extradata_nal_types= extradata_nal_types_hevc;
@@ -82,11 +82,20 @@ static int extract_extradata_h2645(AVBSFContext *ctx, 
AVPacket *pkt,
 
 for (i = 0; i < h2645_pkt.nb_nals; i++) {
 H2645NAL *nal = &h2645_pkt.nals[i];
-if (val_in_array(extradata_nal_types, nb_extradata_nal_types, 
nal->type))
+if (val_in_array(extradata_nal_types, nb_extradata_nal_types, 
nal->type)) {
 extradata_size += nal->raw_size + 3;
+if (ctx->par_in->codec_id == AV_CODEC_ID_HEVC) {
+if (nal->type == HEVC_NAL_SPS) has_sps = 1;
+if (nal->type == HEVC_NAL_VPS) has_vps = 1;
+} else {
+if (nal->type == H264_NAL_SPS) has_sps = 1;
+}
+}
 }
 
-if (extradata_size) {
+if (extradata_size &&
+((ctx->par_in->codec_id == AV_CODEC_ID_HEVC && has_sps && has_vps) ||
+ (ctx->par_in->codec_id == AV_CODEC_ID_H264 && has_sps))) {
 AVBufferRef *filtered_buf;
 uint8_t *extradata, *filtered_data;
 
-- 
2.12.1

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

[libav-devel] [PATCH] matroskaenc: don't warn about unknown spherical metadata when there isn't any

2017-04-14 Thread James Almer
The same warning is issued when actual unknown spherical metadata is
found further down in the function.

Signed-off-by: James Almer 
---
 libavformat/matroskaenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index b8c434a66..ab83acfff 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -662,10 +662,8 @@ static int mkv_write_video_projection(AVFormatContext *s, 
AVIOContext *pb,
 (const AVSphericalMapping *)av_stream_get_side_data(st, 
AV_PKT_DATA_SPHERICAL,
 &side_data_size);
 
-if (!side_data_size) {
-av_log(NULL, AV_LOG_WARNING, "Unknown spherical metadata\n");
+if (!side_data_size)
 return 0;
-}
 
 ret = avio_open_dyn_buf(&dyn_cp);
 if (ret < 0)
-- 
2.12.1

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

Re: [libav-devel] [PATCH] extract_extradata_bsf: make sure all needed parameter set NALUs were found

2017-04-17 Thread James Almer
On 4/17/2017 8:48 AM, Luca Barbato wrote:
> On 14/04/2017 15:53, James Almer wrote:
>> This mimics the behavior of the now unused h264/hevc parser's split()
>> function and fixes decoding some files when extract_extradata bsf is
>> enabled.
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/extract_extradata_bsf.c | 15 ---
>>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> Do you have a small sample to use?
> 
> lu

https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4544/globo%20hd%2020120424%20champions%20league%20paulonline_cut.ts

20mb so not exactly small, but it can be cut even further if you want to
make a fate test for it since the problem is that extract_extradata takes
a bunch of useless NALUs out of the first complete frame instead of waiting
until it finds an SPS.

Couldn't find any hevc sample that fails without this patch, but it should
be a matter of finding a badly cut mpegts file out there.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [RFC] [PATCH] pixdesc: Change color property name APIs return type

2017-04-22 Thread James Almer

On 4/21/2017 7:05 AM, Diego Biurrun wrote:

On Fri, Apr 21, 2017 at 07:06:04AM +0200, wm4 wrote:

On Thu, 20 Apr 2017 11:26:10 -0400
Vittorio Giovara  wrote:


This should make these APIs simpler to use, and less error prone
in case the caller does not check they are valid, and makes them
more similar to other naming APIs.
---
This should help in the bug in avprobe found by Luca.
Sending as RFC since I believe we are allowed to break this API as we
did the version bump, but I'd like to be sure.

  libavutil/pixdesc.c | 10 +-
  libavutil/pixdesc.h | 10 +-
  2 files changed, 10 insertions(+), 10 deletions(-)


This is a serious API change and needs to go through the entire
deprecation circus.


We're still in the bump period...

Diego


That gives you free reign to play with offsets in public structs and 
with symbol availability, but not to change the signature or return 
value of functions in a way that existing downstream code will break. 
API breaks are not the same as ABI breaks.
As a library user i expect av_color_space_name() to return NULL when 
it's feed an out of range AVCOL_SPC_ value. This patchset will make code 
like


if (!av_color_space_name(somevalue)) return EINVAL;

never return on out of range values, thus it's an API break. Regardless 
of me linking my program with libavutil 54, 55 or 56, the behavior 
should be the same.
Changing a -1 return value to AVERROR() is "acceptable" since a < 0 
check would work on both, although still technically not a very nice 
thing to do. But if you want to change NULL into "unknown", then a 
different function with a different signature needs to be introduced.

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

Re: [libav-devel] [RFC] [PATCH] stereo3d: Update the naming API to be more consistent

2017-04-23 Thread James Almer

On 4/20/2017 12:34 PM, Vittorio Giovara wrote:

Change input type of the type->str function and return a proper
error code for the str->type function.
---
Similar reasoning to the previous patch.
Vittorio

  libavutil/stereo3d.c | 6 +++---
  libavutil/stereo3d.h | 2 +-
  2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
index 5dc902e909..6e2f9f3ad2 100644
--- a/libavutil/stereo3d.c
+++ b/libavutil/stereo3d.c
@@ -54,9 +54,9 @@ static const char * const stereo3d_type_names[] = {
  [AV_STEREO3D_COLUMNS] = "interleaved columns",
  };
  
-const char *av_stereo3d_type_name(unsigned int type)

+const char *av_stereo3d_type_name(enum AVStereo3DType type)
  {
-if (type >= FF_ARRAY_ELEMS(stereo3d_type_names))
+if ((unsigned) type >= FF_ARRAY_ELEMS(stereo3d_type_names))
  return "unknown";
  
  return stereo3d_type_names[type];

@@ -72,5 +72,5 @@ int av_stereo3d_from_name(const char *name)
  return i;
  }
  
-return -1;

+return AVERROR(EINVAL);


Why EINVAL here but ENOSYS for spherical?

Also, while changing -1 to AVERROR() isn't a considerable API break as 
changing NULL on failure to a string on failure, it's still one and 
really makes me wonder if it's worth doing.
While most users probably just check for < 0, in which case both return 
values would work the same, anyone instead checking explicitly for -1 (a 
completely valid check as per the documentation, which you for that 
matter did not update in this patch) will instead break.



  }
diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h
index 0fa9f63a2c..cbf138faef 100644
--- a/libavutil/stereo3d.h
+++ b/libavutil/stereo3d.h
@@ -190,7 +190,7 @@ AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame);
   *
   * @return The name of the stereo3d value, or "unknown".
   */
-const char *av_stereo3d_type_name(unsigned int type);
+const char *av_stereo3d_type_name(enum AVStereo3DType type);
  
  /**

   * Get the AVStereo3DType form a human-readable name.



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

Re: [libav-devel] [PATCH] Add ClearVideo decoder

2017-04-24 Thread James Almer
On 4/24/2017 11:13 AM, Diego Biurrun wrote:
> On Sat, Apr 22, 2017 at 01:05:01PM +0200, Diego Biurrun wrote:
>> --- /dev/null
>> +++ b/libavcodec/clearvideo.c
>> @@ -0,0 +1,387 @@
>> +static int clv_decode_frame(AVCodecContext *avctx, void *data,
>> +int *got_frame, AVPacket *avpkt)
>> +{
>> +if (frame_type & 0x2) {
>> +} else {
>> +/* Only I-frames are supported for now. */
>> +}
> 
> Here I might use avpriv_report_missing_feature() and return
> AVERROR_PATCHWELCOME instead. This would of course result in a lot
> of console spam. Thoughts?
> 
> Diego

Add an did_warn variable to CLVContext, and set it to true after the
warning is printed the first time.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [RFC] [PATCH] stereo3d: Update the naming API to be more consistent

2017-04-24 Thread James Almer
On 4/24/2017 11:55 AM, Vittorio Giovara wrote:
> On Sun, Apr 23, 2017 at 11:31 PM, James Almer  wrote:
>> On 4/20/2017 12:34 PM, Vittorio Giovara wrote:
>>>
>>> Change input type of the type->str function and return a proper
>>> error code for the str->type function.
>>> ---
>>> Similar reasoning to the previous patch.
>>> Vittorio
>>>
>>>   libavutil/stereo3d.c | 6 +++---
>>>   libavutil/stereo3d.h | 2 +-
>>>   2 files changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
>>> index 5dc902e909..6e2f9f3ad2 100644
>>> --- a/libavutil/stereo3d.c
>>> +++ b/libavutil/stereo3d.c
>>> @@ -54,9 +54,9 @@ static const char * const stereo3d_type_names[] = {
>>>   [AV_STEREO3D_COLUMNS] = "interleaved columns",
>>>   };
>>>   -const char *av_stereo3d_type_name(unsigned int type)
>>> +const char *av_stereo3d_type_name(enum AVStereo3DType type)
>>>   {
>>> -if (type >= FF_ARRAY_ELEMS(stereo3d_type_names))
>>> +if ((unsigned) type >= FF_ARRAY_ELEMS(stereo3d_type_names))
>>>   return "unknown";
>>> return stereo3d_type_names[type];
>>> @@ -72,5 +72,5 @@ int av_stereo3d_from_name(const char *name)
>>>   return i;
>>>   }
>>>   -return -1;
>>> +return AVERROR(EINVAL);
>>
>>
>> Why EINVAL here but ENOSYS for spherical?
> 
> no reason, i can switch to enonsys

I was thinking EINVAL is more correct for both cases.

> 
>> Also, while changing -1 to AVERROR() isn't a considerable API break as
>> changing NULL on failure to a string on failure, it's still one and really
>> makes me wonder if it's worth doing.
>> While most users probably just check for < 0, in which case both return
>> values would work the same, anyone instead checking explicitly for -1 (a
>> completely valid check as per the documentation, which you for that matter
>> did not update in this patch) will instead break.
> 
> besides the fact that we're in the "break period" after the version
> bump, there should be no reason to explicitly check for -1 so I don't
> think that's a case that it's worth considering
> 

As Anton already stated, there is no such thing as an API breaking
season, only ABI breaking season. You can't change a function signature
or return value/type on a whim if it can break downstream code.
The documentation states the function returns -1 on failure. Explicitly
checking for said value is a correct and completely valid way to check
for failure. This patch would break such downstream code that follows
the documentation to the letter.

Changing unsigned int to enum AVStereo3DType as parameter type in
av_stereo3d_type_name() however should be ok. No API user will be
affected by that.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] aac: Split function to parse ADTS header data into public and private part

2017-04-26 Thread James Almer
On 4/26/2017 2:02 PM, Diego Biurrun wrote:
> This makes the currently semi-public avpriv_aac_parse_header() function
> private to libavcodec and adds a proper public API function to return
> the parts of the ADTS header required in libavformat.
> ---
> 
> This eliminates one more ABI issue with the new bitstream reader.
> 
>  configure |  8 ++-
>  doc/developer.texi|  2 +-
>  libavcodec/Makefile   | 15 +++---
>  libavcodec/aac_adtstoasc_bsf.c|  5 +-
>  libavcodec/aac_parser.c   |  3 +-
>  libavcodec/{aacadtsdec.c => aacadts_header.c} |  4 +-
>  libavcodec/{aacadtsdec.h => aacadts_header.h} |  9 ++--
>  libavcodec/aacadtsdec.c   | 71 
> +--
>  libavcodec/aacadtsdec.h   | 29 +++
>  libavcodec/aacdec.c   |  4 +-
>  libavformat/spdifdec.c| 22 +
>  libavformat/spdifenc.c| 15 +++---
>  12 files changed, 79 insertions(+), 108 deletions(-)
>  copy libavcodec/{aacadtsdec.c => aacadts_header.c} (96%)
>  copy libavcodec/{aacadtsdec.h => aacadts_header.h} (90%)
> 
[...]

> diff --git a/libavcodec/aacadtsdec.h b/libavcodec/aacadtsdec.h
> index 6319efc..5d601c2 100644
> --- a/libavcodec/aacadtsdec.h
> +++ b/libavcodec/aacadtsdec.h

This has become an adts parser header. Maybe the name should reflect
that, especially now that it will be installed.
It would be more in line with ac3_parser.h and vorbis_parser.h as well.

> @@ -23,32 +23,19 @@
>  #ifndef AVCODEC_AACADTSDEC_H
>  #define AVCODEC_AACADTSDEC_H
>  
> +#include 
>  #include 
> -#include "get_bits.h"
>  
>  #define AAC_ADTS_HEADER_SIZE 7
>  
> -typedef struct AACADTSHeaderInfo {
> -uint32_t sample_rate;
> -uint32_t samples;
> -uint32_t bit_rate;
> -uint8_t  crc_absent;
> -uint8_t  object_type;
> -uint8_t  sampling_index;
> -uint8_t  chan_config;
> -uint8_t  num_aac_frames;
> -} AACADTSHeaderInfo;
> -
>  /**
> - * Parse AAC frame header.
> - * Parse the ADTS frame header to the end of the variable header, which is
> - * the first 54 bits.
> - * @param[in]  gbc BitContext containing the first 54 bits of the frame.
> - * @param[out] hdr Pointer to struct where header info is written.
> - * @return Returns 0 on success, -1 if there is a sync word mismatch,
> - * -2 if the version element is invalid, -3 if the sample rate
> - * element is invalid, or -4 if the bit rate element is invalid.
> + * Extract the number of samples and frames from AAC data.
> + * @param[in]  buf pointer to AAC data buffer
> + * @param[out] samples Pointer to where number of samples is written
> + * @param[out] frames  Pointer to where number of frames is written
> + * @return Returns 0 on success, error code on failure.
>   */
> -int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr);
> +int av_aacadts_header_parse(const uint8_t *buf, uint32_t *samples,

Why change it to _header_parse()? AC3's parse function was left as
_parse_header() when it was made public. Better keep it consistent.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 1/2] hevcdec: remove HEVCContext usage from hevc_sei

2017-04-30 Thread James Almer
Based on the H264 SEI implementation.

This will be mainly useful once support for SEI messages that can be
used by the hevc parser are implemented, like Picture Timing.

Signed-off-by: James Almer 
---
 libavcodec/hevc_sei.c | 77 +--
 libavcodec/hevcdec.c  | 49 +---
 libavcodec/hevcdec.h  | 44 ++---
 3 files changed, 92 insertions(+), 78 deletions(-)

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 1f8554ad5..bb4980085 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -53,10 +53,10 @@ enum HEVC_SEI_TYPE {
 SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
 };
 
-static int decode_nal_sei_decoded_picture_hash(HEVCContext *s)
+static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
GetBitContext *gb,
+   void *logctx)
 {
 int cIdx, i;
-GetBitContext *gb = &s->HEVClc.gb;
 uint8_t hash_type = get_bits(gb, 8);
 
 for (cIdx = 0; cIdx < 3; cIdx++) {
@@ -75,15 +75,15 @@ static int decode_nal_sei_decoded_picture_hash(HEVCContext 
*s)
 return 0;
 }
 
-static int decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
+static int decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking *s,
+GetBitContext *gb,
+void *logctx)
 {
-GetBitContext *gb = &s->HEVClc.gb;
-
 get_ue_golomb(gb);  // frame_packing_arrangement_id
-s->sei_frame_packing_present = !get_bits1(gb);
+s->present = !get_bits1(gb);
 
-if (s->sei_frame_packing_present) {
-s->frame_packing_arrangement_type = get_bits(gb, 7);
+if (s->present) {
+s->arrangement_type   = get_bits(gb, 7);
 s->quincunx_subsampling   = get_bits1(gb);
 s->content_interpretation_type= get_bits(gb, 6);
 
@@ -92,7 +92,7 @@ static int 
decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
 // frame0_self_contained_flag frame1_self_contained_flag
 skip_bits(gb, 6);
 
-if (!s->quincunx_subsampling && s->frame_packing_arrangement_type != 5)
+if (!s->quincunx_subsampling && s->arrangement_type != 5)
 skip_bits(gb, 16);  // frame[01]_grid_position_[xy]
 skip_bits(gb, 8);   // frame_packing_arrangement_reserved_byte
 skip_bits1(gb); // frame_packing_arrangement_persistence_flag
@@ -101,63 +101,61 @@ static int 
decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
 return 0;
 }
 
-static int decode_nal_sei_display_orientation(HEVCContext *s)
+static int decode_nal_sei_display_orientation(HEVCSEIDisplayOrientation *s, 
GetBitContext *gb,
+  void *logctx)
 {
-GetBitContext *gb = &s->HEVClc.gb;
-
-s->sei_display_orientation_present = !get_bits1(gb);
+s->present = !get_bits1(gb);
 
-if (s->sei_display_orientation_present) {
-s->sei_hflip = get_bits1(gb); // hor_flip
-s->sei_vflip = get_bits1(gb); // ver_flip
+if (s->present) {
+s->hflip = get_bits1(gb); // hor_flip
+s->vflip = get_bits1(gb); // ver_flip
 
-s->sei_anticlockwise_rotation = get_bits(gb, 16);
+s->anticlockwise_rotation = get_bits(gb, 16);
 skip_bits1(gb); // display_orientation_persistence_flag
 }
 
 return 0;
 }
 
-static int decode_nal_sei_prefix(HEVCContext *s, int type, int size)
+static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, 
HEVCSEIContext *s,
+ int type, int size)
 {
-GetBitContext *gb = &s->HEVClc.gb;
-
 switch (type) {
 case 256:  // Mismatched value from HM 8.1
-return decode_nal_sei_decoded_picture_hash(s);
+return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb, 
logctx);
 case SEI_TYPE_FRAME_PACKING:
-return decode_nal_sei_frame_packing_arrangement(s);
+return decode_nal_sei_frame_packing_arrangement(&s->frame_packing,
+gb, logctx);
 case SEI_TYPE_DISPLAY_ORIENTATION:
-return decode_nal_sei_display_orientation(s);
+return decode_nal_sei_display_orientation(&s->display_orientation,
+  gb, logctx);
 default:
-av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
+av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 skip_bits_long(gb, 8 * size);
 return 0;
 }
 }
 
-static int decode_nal_sei_suffix(HEVCContext *s, int type, int size)
+static int decode_nal_sei_suffix(GetBitContext *gb, void *logctx, 
HEVCSEIContext *s,
+ 

[libav-devel] [PATCH 2/2] hevcdec: move SEI message parsing into a separate header

2017-04-30 Thread James Almer
It doesn't depend on hevcdec anymore.

Signed-off-by: James Almer 
---
The two patches could be squashed into one, but i figured this way would be
easier to read/review.

 libavcodec/hevc_sei.c | 37 +++---
 libavcodec/hevc_sei.h | 88 +++
 libavcodec/hevcdec.h  | 29 +
 3 files changed, 94 insertions(+), 60 deletions(-)
 create mode 100644 libavcodec/hevc_sei.h

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index bb4980085..0e7f0ccb0 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -23,35 +23,8 @@
  */
 
 #include "golomb_legacy.h"
-#include "hevcdec.h"
-
-enum HEVC_SEI_TYPE {
-SEI_TYPE_BUFFERING_PERIOD = 0,
-SEI_TYPE_PICTURE_TIMING   = 1,
-SEI_TYPE_PAN_SCAN_RECT= 2,
-SEI_TYPE_FILLER_PAYLOAD   = 3,
-SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35   = 4,
-SEI_TYPE_USER_DATA_UNREGISTERED   = 5,
-SEI_TYPE_RECOVERY_POINT   = 6,
-SEI_TYPE_SCENE_INFO   = 9,
-SEI_TYPE_FULL_FRAME_SNAPSHOT  = 15,
-SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
-SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
-SEI_TYPE_FILM_GRAIN_CHARACTERISTICS   = 19,
-SEI_TYPE_POST_FILTER_HINT = 22,
-SEI_TYPE_TONE_MAPPING_INFO= 23,
-SEI_TYPE_FRAME_PACKING= 45,
-SEI_TYPE_DISPLAY_ORIENTATION  = 47,
-SEI_TYPE_SOP_DESCRIPTION  = 128,
-SEI_TYPE_ACTIVE_PARAMETER_SETS= 129,
-SEI_TYPE_DECODING_UNIT_INFO   = 130,
-SEI_TYPE_TEMPORAL_LEVEL0_INDEX= 131,
-SEI_TYPE_DECODED_PICTURE_HASH = 132,
-SEI_TYPE_SCALABLE_NESTING = 133,
-SEI_TYPE_REGION_REFRESH_INFO  = 134,
-SEI_TYPE_MASTERING_DISPLAY_INFO   = 137,
-SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
-};
+#include "hevc.h"
+#include "hevc_sei.h"
 
 static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
GetBitContext *gb,
void *logctx)
@@ -123,10 +96,10 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void 
*logctx, HEVCSEIContext
 switch (type) {
 case 256:  // Mismatched value from HM 8.1
 return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb, 
logctx);
-case SEI_TYPE_FRAME_PACKING:
+case HEVC_SEI_TYPE_FRAME_PACKING:
 return decode_nal_sei_frame_packing_arrangement(&s->frame_packing,
 gb, logctx);
-case SEI_TYPE_DISPLAY_ORIENTATION:
+case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
 return decode_nal_sei_display_orientation(&s->display_orientation,
   gb, logctx);
 default:
@@ -140,7 +113,7 @@ static int decode_nal_sei_suffix(GetBitContext *gb, void 
*logctx, HEVCSEIContext
  int type, int size)
 {
 switch (type) {
-case SEI_TYPE_DECODED_PICTURE_HASH:
+case HEVC_SEI_TYPE_DECODED_PICTURE_HASH:
 return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb, 
logctx);
 default:
 av_log(logctx, AV_LOG_DEBUG, "Skipped SUFFIX SEI %d\n", type);
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
new file mode 100644
index 0..c2bc4f9f0
--- /dev/null
+++ b/libavcodec/hevc_sei.h
@@ -0,0 +1,88 @@
+/*
+ * HEVC Supplementary Enhancement Information messages
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_HEVC_SEI_H
+#define AVCODEC_HEVC_SEI_H
+
+#include 
+
+#include "libavutil/md5.h"
+#include "get_bits.h"
+
+/**
+ * SEI message types
+ */
+typedef enum {
+HEVC_SEI_TYPE_BUFFERING_PERIOD = 0,
+HEVC_SEI_TYPE_PICTURE_TIMING   = 1,
+HEVC_SEI_TYPE_PAN_SCAN_RECT= 2,
+HEVC_SEI_TYPE_FILLER_PAYLOAD   = 3,

[libav-devel] [PATCH] configure: rename hevc_ps to hevcparse

2017-05-02 Thread James Almer
Build h2645_parse.o with it, as every hevc_ps dependency also needs it.
This is more in line with h264's h264parse module.

Signed-off-by: James Almer 
---
 configure   | 10 +-
 libavcodec/Makefile |  8 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index c7d036361..1c85438a5 100755
--- a/configure
+++ b/configure
@@ -1750,7 +1750,7 @@ CONFIG_EXTRA="
 h264parse
 h264pred
 h264qpel
-hevc_ps
+hevcparse
 hpeldsp
 huffman
 huffyuvdsp
@@ -1953,7 +1953,7 @@ error_resilience_select="me_cmp"
 faandct_deps="faan fdctdsp"
 faanidct_deps="faan idctdsp"
 h264dsp_select="startcode"
-hevc_ps_select="golomb"
+hevcparse_select="golomb"
 intrax8_select="blockdsp idctdsp"
 mdct_select="fft"
 rdft_select="fft"
@@ -2038,7 +2038,7 @@ h264_decoder_suggest="error_resilience"
 hap_decoder_select="snappy texturedsp"
 hap_encoder_deps="libsnappy"
 hap_encoder_select="texturedspenc"
-hevc_decoder_select="bswapdsp cabac hevc_ps videodsp"
+hevc_decoder_select="bswapdsp cabac hevcparse videodsp"
 huffyuv_decoder_select="bswapdsp huffyuvdsp"
 huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp"
 iac_decoder_select="imc_decoder"
@@ -2253,7 +2253,7 @@ hevc_nvenc_encoder_deps="nvenc"
 hevc_qsv_decoder_deps="libmfx"
 hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser hevc_qsv_hwaccel 
qsvdec"
 hevc_qsv_encoder_deps="libmfx"
-hevc_qsv_encoder_select="hevc_ps qsvenc"
+hevc_qsv_encoder_select="hevcparse qsvenc"
 hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
 hevc_vaapi_encoder_select="vaapi_encode golomb"
 mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
@@ -2281,7 +2281,7 @@ nvenc_hevc_encoder_select="hevc_nvenc_encoder"
 
 # parsers
 h264_parser_select="golomb h264dsp h264parse"
-hevc_parser_select="hevc_ps"
+hevc_parser_select="hevcparse"
 mpegaudio_parser_select="mpegaudioheader"
 mpegvideo_parser_select="mpegvideo"
 mpeg4video_parser_select="error_resilience h263dsp mpegvideo qpeldsp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b60ba5ef9..8e4f1d3a0 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -67,7 +67,7 @@ OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o
 OBJS-$(CONFIG_H264PARSE)   += h264_parse.o h2645_parse.o h264_ps.o
 OBJS-$(CONFIG_H264PRED)+= h264pred.o
 OBJS-$(CONFIG_H264QPEL)+= h264qpel.o
-OBJS-$(CONFIG_HEVC_PS) += hevc_ps.o
+OBJS-$(CONFIG_HEVCPARSE)   += h2645_parse.o hevc_ps.o
 OBJS-$(CONFIG_HPELDSP) += hpeldsp.o
 OBJS-$(CONFIG_HUFFMAN) += huffman.o
 OBJS-$(CONFIG_HUFFYUVDSP)  += huffyuvdsp.o
@@ -273,11 +273,11 @@ OBJS-$(CONFIG_HAP_DECODER) += hapdec.o hap.o
 OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o hap.o
 OBJS-$(CONFIG_HEVC_DECODER)+= hevcdec.o hevc_mvs.o hevc_sei.o \
   hevc_cabac.o hevc_refs.o hevcpred.o  
  \
-  hevcdsp.o hevc_filter.o 
h2645_parse.o hevc_data.o
+  hevcdsp.o hevc_filter.o hevc_data.o
 OBJS-$(CONFIG_HEVC_NVENC_ENCODER)  += nvenc_hevc.o
 OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec_h2645.o
 OBJS-$(CONFIG_HEVC_QSV_ENCODER)+= qsvenc_hevc.o hevc_ps_enc.o   \
-  h2645_parse.o hevc_data.o
+  hevc_data.o
 OBJS-$(CONFIG_HEVC_VAAPI_ENCODER)  += vaapi_encode_h265.o 
vaapi_encode_h26x.o
 OBJS-$(CONFIG_HNM4_VIDEO_DECODER)  += hnm4video.o
 OBJS-$(CONFIG_HQ_HQA_DECODER)  += hq_hqa.o hq_hqadata.o hq_hqadsp.o \
@@ -739,7 +739,7 @@ OBJS-$(CONFIG_GSM_PARSER)  += gsm_parser.o
 OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
 OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
 OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264_sei.o h264data.o
-OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o h2645_parse.o 
hevc_data.o
+OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o
 OBJS-$(CONFIG_MJPEG_PARSER)+= mjpeg_parser.o
 OBJS-$(CONFIG_MLP_PARSER)  += mlp_parser.o mlp.o
 OBJS-$(CONFIG_MPEG4VIDEO_PARSER)   += mpeg4video_parser.o h263.o \
-- 
2.12.1

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

Re: [libav-devel] [PATCH 1/2] hevcdec: remove HEVCContext usage from hevc_sei

2017-05-05 Thread James Almer
On 4/30/2017 12:35 PM, James Almer wrote:
> Based on the H264 SEI implementation.
> 
> This will be mainly useful once support for SEI messages that can be
> used by the hevc parser are implemented, like Picture Timing.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/hevc_sei.c | 77 
> +--
>  libavcodec/hevcdec.c  | 49 +---
>  libavcodec/hevcdec.h  | 44 ++---
>  3 files changed, 92 insertions(+), 78 deletions(-)

Ping for set.

> 
> diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
> index 1f8554ad5..bb4980085 100644
> --- a/libavcodec/hevc_sei.c
> +++ b/libavcodec/hevc_sei.c
> @@ -53,10 +53,10 @@ enum HEVC_SEI_TYPE {
>  SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
>  };
>  
> -static int decode_nal_sei_decoded_picture_hash(HEVCContext *s)
> +static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
> GetBitContext *gb,
> +   void *logctx)

Btw, I could send a new version removing the logctx parameter, since i
noticed after sending that it's unused in a bunch of these functions.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 3/200] lavc: deprecate channel count/layout changing side data

2017-05-05 Thread James Almer
On 5/5/2017 11:20 PM, Vittorio Giovara wrote:
> From: Anton Khirnov 
> 
> They are incompatible with the new channel layout scheme and no decoder
> uses them.
> 
> Signed-off-by: Vittorio Giovara 
> ---
>  libavcodec/avcodec.h | 5 +
>  libavcodec/decode.c  | 4 
>  libavformat/dump.c   | 9 -
>  libavformat/utils.c  | 9 +
>  4 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 162f1abe4b..4089c08a24 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1165,8 +1165,13 @@ typedef struct AVPacket {
>  #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
>  
>  enum AVSideDataParamChangeFlags {
> +#if FF_API_OLD_CHANNEL_LAYOUT
> +/**
> + * @deprecated those are not used by any decoder

Perhaps __attribute__((deprecated))

For enum values it's GCC >= 6 only, so it will need an addition to
attributes.h

> + */
>  AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT  = 0x0001,
>  AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
> +#endif
>  AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE= 0x0004,
>  AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
>  };
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/2] hevcdec: remove HEVCContext usage from hevc_sei

2017-05-06 Thread James Almer
On 5/5/2017 5:32 PM, Luca Barbato wrote:
> On 5/5/17 8:56 PM, James Almer wrote:
>> On 4/30/2017 12:35 PM, James Almer wrote:
>>> Based on the H264 SEI implementation.
>>>
>>> This will be mainly useful once support for SEI messages that can be
>>> used by the hevc parser are implemented, like Picture Timing.
>>>
>>> Signed-off-by: James Almer 
>>> ---
>>>  libavcodec/hevc_sei.c | 77 
>>> +--
>>>  libavcodec/hevcdec.c  | 49 +---
>>>  libavcodec/hevcdec.h  | 44 ++---
>>>  3 files changed, 92 insertions(+), 78 deletions(-)
>>
>> Ping for set.
> 
> HEVCSEIContext doesn't seem a context though, probably HEVCSEIInfo might
> be a better name.

How about ATMMachine or PINNumber? :P

Jokes aside, I personally agree with Hendrik. HEVCSEIContext is
consistent with h264's naming. But if you insist i can change it to for
example HEVCSEI, following the existing HEVCSPS/HEVCPPS/HEVCVPS structs
for the corresponding NALUs.

> 
> Beside that seems fine to me.
> 
>> Btw, I could send a new version removing the logctx parameter, since i
>> noticed after sending that it's unused in a bunch of these functions.
> 
> Sounds a good idea.
> 
> lu
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
> 

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

[libav-devel] [PATCH v2 1/2] hevcdec: remove HEVCContext usage from hevc_sei

2017-05-07 Thread James Almer
Based on the H264 SEI implementation.

This will be mainly useful once support for SEI messages that can be
used by the hevc parser are implemented, like Picture Timing.

Signed-off-by: James Almer 
---
Changes since last version:

Removed unused logctx parameters in some functions.
Renamed HEVCSEIContext to HEVCSEI.
  
 libavcodec/hevc_sei.c | 71 +++
 libavcodec/hevcdec.c  | 49 ++-
 libavcodec/hevcdec.h  | 45 
 3 files changed, 86 insertions(+), 79 deletions(-)

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 1f8554ad5..b2a0d6788 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -53,10 +53,9 @@ enum HEVC_SEI_TYPE {
 SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
 };
 
-static int decode_nal_sei_decoded_picture_hash(HEVCContext *s)
+static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
GetBitContext *gb)
 {
 int cIdx, i;
-GetBitContext *gb = &s->HEVClc.gb;
 uint8_t hash_type = get_bits(gb, 8);
 
 for (cIdx = 0; cIdx < 3; cIdx++) {
@@ -75,15 +74,13 @@ static int decode_nal_sei_decoded_picture_hash(HEVCContext 
*s)
 return 0;
 }
 
-static int decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
+static int decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking *s, 
GetBitContext *gb)
 {
-GetBitContext *gb = &s->HEVClc.gb;
-
 get_ue_golomb(gb);  // frame_packing_arrangement_id
-s->sei_frame_packing_present = !get_bits1(gb);
+s->present = !get_bits1(gb);
 
-if (s->sei_frame_packing_present) {
-s->frame_packing_arrangement_type = get_bits(gb, 7);
+if (s->present) {
+s->arrangement_type   = get_bits(gb, 7);
 s->quincunx_subsampling   = get_bits1(gb);
 s->content_interpretation_type= get_bits(gb, 6);
 
@@ -92,7 +89,7 @@ static int 
decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
 // frame0_self_contained_flag frame1_self_contained_flag
 skip_bits(gb, 6);
 
-if (!s->quincunx_subsampling && s->frame_packing_arrangement_type != 5)
+if (!s->quincunx_subsampling && s->arrangement_type != 5)
 skip_bits(gb, 16);  // frame[01]_grid_position_[xy]
 skip_bits(gb, 8);   // frame_packing_arrangement_reserved_byte
 skip_bits1(gb); // frame_packing_arrangement_persistence_flag
@@ -101,63 +98,58 @@ static int 
decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
 return 0;
 }
 
-static int decode_nal_sei_display_orientation(HEVCContext *s)
+static int decode_nal_sei_display_orientation(HEVCSEIDisplayOrientation *s, 
GetBitContext *gb)
 {
-GetBitContext *gb = &s->HEVClc.gb;
-
-s->sei_display_orientation_present = !get_bits1(gb);
+s->present = !get_bits1(gb);
 
-if (s->sei_display_orientation_present) {
-s->sei_hflip = get_bits1(gb); // hor_flip
-s->sei_vflip = get_bits1(gb); // ver_flip
+if (s->present) {
+s->hflip = get_bits1(gb); // hor_flip
+s->vflip = get_bits1(gb); // ver_flip
 
-s->sei_anticlockwise_rotation = get_bits(gb, 16);
+s->anticlockwise_rotation = get_bits(gb, 16);
 skip_bits1(gb); // display_orientation_persistence_flag
 }
 
 return 0;
 }
 
-static int decode_nal_sei_prefix(HEVCContext *s, int type, int size)
+static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s,
+ int type, int size)
 {
-GetBitContext *gb = &s->HEVClc.gb;
-
 switch (type) {
 case 256:  // Mismatched value from HM 8.1
-return decode_nal_sei_decoded_picture_hash(s);
+return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb);
 case SEI_TYPE_FRAME_PACKING:
-return decode_nal_sei_frame_packing_arrangement(s);
+return decode_nal_sei_frame_packing_arrangement(&s->frame_packing, gb);
 case SEI_TYPE_DISPLAY_ORIENTATION:
-return decode_nal_sei_display_orientation(s);
+return decode_nal_sei_display_orientation(&s->display_orientation, gb);
 default:
-av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
+av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 skip_bits_long(gb, 8 * size);
 return 0;
 }
 }
 
-static int decode_nal_sei_suffix(HEVCContext *s, int type, int size)
+static int decode_nal_sei_suffix(GetBitContext *gb, void *logctx, HEVCSEI *s,
+ int type, int size)
 {
-GetBitContext *gb = &s->HEVClc.gb;
-
 switch (type) {
 case SEI_TYPE_DECODED_PICTURE_HASH:
-return decode_nal_sei_decoded_picture_hash(s);
+return decode_nal_sei_decoded_picture_hash(&s-&g

[libav-devel] [PATCH v2 2/2] hevcdec: move SEI message parsing into a separate header

2017-05-07 Thread James Almer
It doesn't depend on hevcdec anymore.

Signed-off-by: James Almer 
---
Adapted after the changes from patch 1/1 v2.

 libavcodec/hevc_sei.c | 37 +++--
 libavcodec/hevc_sei.h | 89 +++
 libavcodec/hevcdec.h  | 30 +
 3 files changed, 95 insertions(+), 61 deletions(-)
 create mode 100644 libavcodec/hevc_sei.h

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index b2a0d6788..153d211b4 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -23,35 +23,8 @@
  */
 
 #include "golomb_legacy.h"
-#include "hevcdec.h"
-
-enum HEVC_SEI_TYPE {
-SEI_TYPE_BUFFERING_PERIOD = 0,
-SEI_TYPE_PICTURE_TIMING   = 1,
-SEI_TYPE_PAN_SCAN_RECT= 2,
-SEI_TYPE_FILLER_PAYLOAD   = 3,
-SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35   = 4,
-SEI_TYPE_USER_DATA_UNREGISTERED   = 5,
-SEI_TYPE_RECOVERY_POINT   = 6,
-SEI_TYPE_SCENE_INFO   = 9,
-SEI_TYPE_FULL_FRAME_SNAPSHOT  = 15,
-SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
-SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
-SEI_TYPE_FILM_GRAIN_CHARACTERISTICS   = 19,
-SEI_TYPE_POST_FILTER_HINT = 22,
-SEI_TYPE_TONE_MAPPING_INFO= 23,
-SEI_TYPE_FRAME_PACKING= 45,
-SEI_TYPE_DISPLAY_ORIENTATION  = 47,
-SEI_TYPE_SOP_DESCRIPTION  = 128,
-SEI_TYPE_ACTIVE_PARAMETER_SETS= 129,
-SEI_TYPE_DECODING_UNIT_INFO   = 130,
-SEI_TYPE_TEMPORAL_LEVEL0_INDEX= 131,
-SEI_TYPE_DECODED_PICTURE_HASH = 132,
-SEI_TYPE_SCALABLE_NESTING = 133,
-SEI_TYPE_REGION_REFRESH_INFO  = 134,
-SEI_TYPE_MASTERING_DISPLAY_INFO   = 137,
-SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
-};
+#include "hevc.h"
+#include "hevc_sei.h"
 
 static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
GetBitContext *gb)
 {
@@ -119,9 +92,9 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void 
*logctx, HEVCSEI *s,
 switch (type) {
 case 256:  // Mismatched value from HM 8.1
 return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb);
-case SEI_TYPE_FRAME_PACKING:
+case HEVC_SEI_TYPE_FRAME_PACKING:
 return decode_nal_sei_frame_packing_arrangement(&s->frame_packing, gb);
-case SEI_TYPE_DISPLAY_ORIENTATION:
+case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
 return decode_nal_sei_display_orientation(&s->display_orientation, gb);
 default:
 av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
@@ -134,7 +107,7 @@ static int decode_nal_sei_suffix(GetBitContext *gb, void 
*logctx, HEVCSEI *s,
  int type, int size)
 {
 switch (type) {
-case SEI_TYPE_DECODED_PICTURE_HASH:
+case HEVC_SEI_TYPE_DECODED_PICTURE_HASH:
 return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb);
 default:
 av_log(logctx, AV_LOG_DEBUG, "Skipped SUFFIX SEI %d\n", type);
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
new file mode 100644
index 0..bdc283adb
--- /dev/null
+++ b/libavcodec/hevc_sei.h
@@ -0,0 +1,89 @@
+/*
+ * HEVC Supplementary Enhancement Information messages
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_HEVC_SEI_H
+#define AVCODEC_HEVC_SEI_H
+
+#include 
+
+#include "libavutil/md5.h"
+
+#include "get_bits.h"
+
+/**
+ * SEI message types
+ */
+typedef enum {
+HEVC_SEI_TYPE_BUFFERING_PERIOD = 0,
+HEVC_SEI_TYPE_PICTURE_TIMING   = 1,
+HEVC_SEI_TYPE_PAN_SCAN_RECT= 2,
+HEVC_SEI_TYPE_FILLER_PAYLOAD   = 3,
+HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35   = 4,
+HEVC_SEI_TYPE_USER_DATA_UNREGISTERED   = 5,
+HEVC_SEI_TYPE_RECOVERY_POINT  

Re: [libav-devel] [PATCH 02/14] h264: Move SEI types to common header

2017-05-14 Thread James Almer
On 5/14/2017 6:24 PM, Mark Thompson wrote:
> Also add a namespace prefix.
> ---
>  libavcodec/h264.h  | 12 
>  libavcodec/h264_sei.c  | 14 +++---
>  libavcodec/h264_sei.h  | 14 +-
>  libavcodec/vaapi_encode_h264.c |  6 +++---
>  4 files changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
> index eb3805c06..ae6b3577d 100644
> --- a/libavcodec/h264.h
> +++ b/libavcodec/h264.h
> @@ -44,4 +44,16 @@ enum {
>  H264_NAL_AUXILIARY_SLICE = 19,
>  };
>  
> +/* SEI message types */
> +enum {
> +H264_SEI_TYPE_BUFFERING_PERIOD   = 0,   ///< buffering period 
> (H.264, D.1.1)
> +H264_SEI_TYPE_PIC_TIMING = 1,   ///< picture timing
> +H264_SEI_TYPE_FILLER_PAYLOAD = 3,   ///< filler data
> +H264_SEI_TYPE_USER_DATA_REGISTERED   = 4,   ///< registered user data as 
> specified by Rec. ITU-T T.35
> +H264_SEI_TYPE_USER_DATA_UNREGISTERED = 5,   ///< unregistered user data
> +H264_SEI_TYPE_RECOVERY_POINT = 6,   ///< recovery point (frame # 
> to decoder sync)
> +H264_SEI_TYPE_FRAME_PACKING  = 45,  ///< frame packing 
> arrangement
> +H264_SEI_TYPE_DISPLAY_ORIENTATION= 47,  ///< display orientation
> +};

Why? They were in a standalone SEI specific header, so why move them
here? You're not untangling anything by moving them here, and saving one
include line per file doesn't seem like a good reason to me.

The namespace prefix change is good, though.

> +
>  #endif /* AVCODEC_H264_H */
> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> index 17f89cec6..357df03ea 100644
> --- a/libavcodec/h264_sei.c
> +++ b/libavcodec/h264_sei.c
> @@ -375,25 +375,25 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext 
> *gb,
>  }
>  
>  switch (type) {
> -case SEI_TYPE_PIC_TIMING: // Picture timing SEI
> +case H264_SEI_TYPE_PIC_TIMING: // Picture timing SEI
>  ret = decode_picture_timing(&h->picture_timing, gb, ps->sps, 
> logctx);
>  break;
> -case SEI_TYPE_USER_DATA_REGISTERED:
> +case H264_SEI_TYPE_USER_DATA_REGISTERED:
>  ret = decode_registered_user_data(h, gb, logctx, size);
>  break;
> -case SEI_TYPE_USER_DATA_UNREGISTERED:
> +case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
>  ret = decode_unregistered_user_data(&h->unregistered, gb, 
> logctx, size);
>  break;
> -case SEI_TYPE_RECOVERY_POINT:
> +case H264_SEI_TYPE_RECOVERY_POINT:
>  ret = decode_recovery_point(&h->recovery_point, gb);
>  break;
> -case SEI_TYPE_BUFFERING_PERIOD:
> +case H264_SEI_TYPE_BUFFERING_PERIOD:
>  ret = decode_buffering_period(&h->buffering_period, gb, ps, 
> logctx);
>  break;
> -case SEI_TYPE_FRAME_PACKING:
> +case H264_SEI_TYPE_FRAME_PACKING:
>  ret = decode_frame_packing_arrangement(&h->frame_packing, gb);
>  break;
> -case SEI_TYPE_DISPLAY_ORIENTATION:
> +case H264_SEI_TYPE_DISPLAY_ORIENTATION:
>  ret = decode_display_orientation(&h->display_orientation, gb);
>  break;
>  default:
> diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
> index 8815aa389..c4517caab 100644
> --- a/libavcodec/h264_sei.h
> +++ b/libavcodec/h264_sei.h
> @@ -20,19 +20,7 @@
>  #define AVCODEC_H264_SEI_H
>  
>  #include "get_bits.h"
> -
> -/**
> - * SEI message types
> - */
> -typedef enum {
> -SEI_TYPE_BUFFERING_PERIOD   = 0,   ///< buffering period (H.264, 
> D.1.1)
> -SEI_TYPE_PIC_TIMING = 1,   ///< picture timing
> -SEI_TYPE_USER_DATA_REGISTERED   = 4,   ///< registered user data as 
> specified by Rec. ITU-T T.35
> -SEI_TYPE_USER_DATA_UNREGISTERED = 5,   ///< unregistered user data
> -SEI_TYPE_RECOVERY_POINT = 6,   ///< recovery point (frame # to 
> decoder sync)
> -SEI_TYPE_FRAME_PACKING  = 45,  ///< frame packing arrangement
> -SEI_TYPE_DISPLAY_ORIENTATION= 47,  ///< display orientation
> -} SEI_Type;
> +#include "h264.h"
>  
>  /**
>   * pic_struct in picture timing SEI message
> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index 0c3ac3441..7583a20c1 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -650,18 +650,18 @@ static void vaapi_encode_h264_write_sei(PutBitContext 
> *pbc,
>  
>  for (payload_type = 0; payload_type < 64; payload_type++) {
>  switch (payload_type) {
> -case SEI_TYPE_BUFFERING_PERIOD:
> +case H264_SEI_TYPE_BUFFERING_PERIOD:
>  if (!priv->send_timing_sei ||
>  pic->type != PICTURE_TYPE_IDR)
>  continue;
>  write_payload = &vaapi_encode_h264_write_buffering_period;
>  break;
> -case SEI_TYPE_PIC_TIMING:
> +case H2

Re: [libav-devel] [PATCH 02/14] h264: Move SEI types to common header

2017-05-15 Thread James Almer
On 5/15/2017 4:47 AM, Mark Thompson wrote:
> On 15/05/17 02:25, James Almer wrote:
>> On 5/14/2017 6:24 PM, Mark Thompson wrote:
>>> Also add a namespace prefix.
>>> ---
>>>  libavcodec/h264.h  | 12 
>>>  libavcodec/h264_sei.c  | 14 +++---
>>>  libavcodec/h264_sei.h  | 14 +-
>>>  libavcodec/vaapi_encode_h264.c |  6 +++---
>>>  4 files changed, 23 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
>>> index eb3805c06..ae6b3577d 100644
>>> --- a/libavcodec/h264.h
>>> +++ b/libavcodec/h264.h
>>> @@ -44,4 +44,16 @@ enum {
>>>  H264_NAL_AUXILIARY_SLICE = 19,
>>>  };
>>>  
>>> +/* SEI message types */
>>> +enum {
>>> +H264_SEI_TYPE_BUFFERING_PERIOD   = 0,   ///< buffering period 
>>> (H.264, D.1.1)
>>> +H264_SEI_TYPE_PIC_TIMING = 1,   ///< picture timing
>>> +H264_SEI_TYPE_FILLER_PAYLOAD = 3,   ///< filler data
>>> +H264_SEI_TYPE_USER_DATA_REGISTERED   = 4,   ///< registered user data 
>>> as specified by Rec. ITU-T T.35
>>> +H264_SEI_TYPE_USER_DATA_UNREGISTERED = 5,   ///< unregistered user data
>>> +H264_SEI_TYPE_RECOVERY_POINT = 6,   ///< recovery point (frame 
>>> # to decoder sync)
>>> +H264_SEI_TYPE_FRAME_PACKING  = 45,  ///< frame packing 
>>> arrangement
>>> +H264_SEI_TYPE_DISPLAY_ORIENTATION= 47,  ///< display orientation
>>> +};
>>
>> Why? They were in a standalone SEI specific header, so why move them
>> here? You're not untangling anything by moving them here, and saving one
>> include line per file doesn't seem like a good reason to me.
> 
> It gets included in cbs_h2645.c, which will contain H.265 SEI stuff as well 
> (that part isn't yet done).  Only the SEI types are wanted, not anything else 
> in the file.
> 
> Alternative approach would be to add the namespace prefix to everything else 
> in h264_sei.h which doesn't currently have it (actually looking, all that is 
> is the pic_struct enum immediately below) - would you prefer that?

That'd be better, yes. Thanks.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 06/14] lavc: Add coded bitstream read/write support for H.265

2017-05-15 Thread James Almer
On 5/14/2017 6:24 PM, Mark Thompson wrote:
> +static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw,
> +H265RawVUI *current)
> +{
> +CodedBitstreamH265Context *h265 = ctx->priv_data;
> +const H265RawSPS *sps = h265->active_sps;

As i mentioned on irc, this is segfaulting when you try to dereference
sps. You should do the same you did with h264 instead.

> +int err;
> +
> +flag(aspect_ratio_info_present_flag);
> +if (current->aspect_ratio_info_present_flag) {
> +u(8, aspect_ratio_idc, 0, 255);
> +if (current->aspect_ratio_idc == 255) {
> +u(16, sar_width,  0, 65535);
> +u(16, sar_height, 0, 65535);
> +}
> +} else {
> +infer(aspect_ratio_idc, 0);
> +}
> +
> +flag(overscan_info_present_flag);
> +if (current->overscan_info_present_flag)
> +flag(overscan_appropriate_flag);
> +
> +flag(video_signal_type_present_flag);
> +if (current->video_signal_type_present_flag) {
> +u(3, video_format, 0, 7);
> +flag(video_full_range_flag);
> +flag(colour_description_present_flag);
> +if (current->colour_description_present_flag) {
> +u(8, colour_primaries, 0, 255);
> +u(8, transfer_characteristics, 0, 255);
> +u(8, matrix_coefficients,  0, 255);
> +} else {
> +infer(colour_primaries, 2);
> +infer(transfer_characteristics, 2);
> +infer(matrix_coefficients,  2);
> +}
> +} else {
> +infer(video_format, 5);
> +infer(video_full_range_flag,0);
> +infer(colour_primaries, 2);
> +infer(transfer_characteristics, 2);
> +infer(matrix_coefficients,  2);
> +}
> +
> +flag(chroma_loc_info_present_flag);
> +if (current->chroma_loc_info_present_flag) {
> +ue(chroma_sample_loc_type_top_field,0, 5);
> +ue(chroma_sample_loc_type_bottom_field, 0, 5);
> +} else {
> +infer(chroma_sample_loc_type_top_field,0);
> +infer(chroma_sample_loc_type_bottom_field, 0);
> +}
> +
> +flag(neutral_chroma_indication_flag);
> +flag(field_seq_flag);
> +flag(frame_field_info_present_flag);
> +
> +flag(default_display_window_flag);
> +if (current->default_display_window_flag) {
> +ue(def_disp_win_left_offset,   0, 16384);
> +ue(def_disp_win_right_offset,  0, 16384);
> +ue(def_disp_win_top_offset,0, 16384);
> +ue(def_disp_win_bottom_offset, 0, 16384);
> +}
> +
> +flag(vui_timing_info_present_flag);
> +if (current->vui_timing_info_present_flag) {
> +u(32, vui_num_units_in_tick, 1, UINT32_MAX);
> +u(32, vui_time_scale,1, UINT32_MAX);
> +flag(vui_poc_proportional_to_timing_flag);
> +if (current->vui_poc_proportional_to_timing_flag)
> +ue(vui_num_ticks_poc_diff_one_minus1, 0, UINT32_MAX - 1);
> +
> +flag(vui_hrd_parameters_present_flag);
> +if (current->vui_hrd_parameters_present_flag) {
> +CHECK(FUNC(hrd_parameters)(ctx, rw, ¤t->hrd_parameters,
> +   1, sps->sps_max_sub_layers_minus1));
> +}
> +}
> +
> +flag(bitstream_restriction_flag);
> +if (current->bitstream_restriction_flag) {
> +flag(tiles_fixed_structure_flag);
> +flag(motion_vectors_over_pic_boundaries_flag);
> +flag(restricted_ref_pic_lists_flag);
> +ue(min_spatial_segmentation_idc,  0, 4095);
> +ue(max_bytes_per_pic_denom,   0, 16);
> +ue(max_bits_per_min_cu_denom, 0, 16);
> +ue(log2_max_mv_length_horizontal, 0, 16);
> +ue(log2_max_mv_length_vertical,   0, 16);
> +} else {
> +infer(tiles_fixed_structure_flag,0);
> +infer(motion_vectors_over_pic_boundaries_flag, 1);
> +infer(min_spatial_segmentation_idc,  0);
> +infer(max_bytes_per_pic_denom,   2);
> +infer(max_bits_per_min_cu_denom, 1);
> +infer(log2_max_mv_length_horizontal, 15);
> +infer(log2_max_mv_length_vertical,   15);
> +}
> +
> +return 0;
> +}
> +
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 02/14] h264_sei: Add namespace prefix to all SEI values

2017-05-15 Thread James Almer
On 5/15/2017 6:51 PM, Mark Thompson wrote:
> This avoids confusion with equivalent H.265 SEI values when both are
> being used at the same time.
> ---
> On 15/05/17 14:22, James Almer wrote:
>> On 5/15/2017 4:47 AM, Mark Thompson wrote:
>>> On 15/05/17 02:25, James Almer wrote:
>>>> On 5/14/2017 6:24 PM, Mark Thompson wrote:
>>>>> Also add a namespace prefix.
>>>>> ---
>>>>>  libavcodec/h264.h  | 12 
>>>>>  libavcodec/h264_sei.c  | 14 +++---
>>>>>  libavcodec/h264_sei.h  | 14 +-
>>>>>  libavcodec/vaapi_encode_h264.c |  6 +++---
>>>>>  4 files changed, 23 insertions(+), 23 deletions(-)
>>>>>
>>>>> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
>>>>> index eb3805c06..ae6b3577d 100644
>>>>> --- a/libavcodec/h264.h
>>>>> +++ b/libavcodec/h264.h
>>>>> @@ -44,4 +44,16 @@ enum {
>>>>>  H264_NAL_AUXILIARY_SLICE = 19,
>>>>>  };
>>>>>  
>>>>> +/* SEI message types */
>>>>> +enum {
>>>>> +H264_SEI_TYPE_BUFFERING_PERIOD   = 0,   ///< buffering period 
>>>>> (H.264, D.1.1)
>>>>> +H264_SEI_TYPE_PIC_TIMING = 1,   ///< picture timing
>>>>> +H264_SEI_TYPE_FILLER_PAYLOAD = 3,   ///< filler data
>>>>> +H264_SEI_TYPE_USER_DATA_REGISTERED   = 4,   ///< registered user 
>>>>> data as specified by Rec. ITU-T T.35
>>>>> +H264_SEI_TYPE_USER_DATA_UNREGISTERED = 5,   ///< unregistered user 
>>>>> data
>>>>> +H264_SEI_TYPE_RECOVERY_POINT = 6,   ///< recovery point 
>>>>> (frame # to decoder sync)
>>>>> +H264_SEI_TYPE_FRAME_PACKING  = 45,  ///< frame packing 
>>>>> arrangement
>>>>> +H264_SEI_TYPE_DISPLAY_ORIENTATION= 47,  ///< display orientation
>>>>> +};
>>>>
>>>> Why? They were in a standalone SEI specific header, so why move them
>>>> here? You're not untangling anything by moving them here, and saving one
>>>> include line per file doesn't seem like a good reason to me.
>>>
>>> It gets included in cbs_h2645.c, which will contain H.265 SEI stuff as well 
>>> (that part isn't yet done).  Only the SEI types are wanted, not anything 
>>> else in the file.
>>>
>>> Alternative approach would be to add the namespace prefix to everything 
>>> else in h264_sei.h which doesn't currently have it (actually looking, all 
>>> that is is the pic_struct enum immediately below) - would you prefer that?
>>
>> That'd be better, yes. Thanks.
> 
> How about this, then?
> 
> (Replaces previous 2/14.)
> 
> Thanks,
> 
> - Mark

Yeah, this is better. Can go in without the rest of the patchset (Same
as 3/14) IMO.

> 
> 
>  libavcodec/h264_parser.c   | 26 +-
>  libavcodec/h264_sei.c  | 16 
>  libavcodec/h264_sei.h  | 39 ---
>  libavcodec/h264_slice.c| 24 
>  libavcodec/vaapi_encode_h264.c |  6 +++---
>  5 files changed, 56 insertions(+), 55 deletions(-)
> 
> diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
> index 22153bd4e..0bb78e09c 100644
> --- a/libavcodec/h264_parser.c
> +++ b/libavcodec/h264_parser.c
> @@ -404,23 +404,23 @@ static inline int parse_nal_units(AVCodecParserContext 
> *s,
>  
>  if (sps->pic_struct_present_flag && 
> p->sei.picture_timing.present) {
>  switch (p->sei.picture_timing.pic_struct) {
> -case SEI_PIC_STRUCT_TOP_FIELD:
> -case SEI_PIC_STRUCT_BOTTOM_FIELD:
> +case H264_SEI_PIC_STRUCT_TOP_FIELD:
> +case H264_SEI_PIC_STRUCT_BOTTOM_FIELD:
>  s->repeat_pict = 0;
>  break;
> -case SEI_PIC_STRUCT_FRAME:
> -case SEI_PIC_STRUCT_TOP_BOTTOM:
> -case SEI_PIC_STRUCT_BOTTOM_TOP:
> +case H264_SEI_PIC_STRUCT_FRAME:
> +case H264_SEI_PIC_STRUCT_TOP_BOTTOM:
> +case H264_SEI_PIC_STRUCT_BOTTOM_TOP:
>  s->repeat_pict = 1;
>  break;
> -case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
> -case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
> +ca

Re: [libav-devel] [PATCH 2/4] h264_sei: parse the picture timing SEIs correctly

2017-05-19 Thread James Almer
On 5/19/2017 10:47 AM, Anton Khirnov wrote:
> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> index 2e52227..9bbec1b 100644
> --- a/libavcodec/h264_sei.c
> +++ b/libavcodec/h264_sei.c
> @@ -31,6 +31,7 @@
>  #include "h264_ps.h"
>  #include "h264_sei.h"
>  #include "internal.h"
> +#include "put_bits.h"
>  
>  static const uint8_t sei_num_clock_ts_table[9] = {
>  1, 1, 1, 2, 2, 3, 3, 2, 3
> @@ -54,21 +55,22 @@ void ff_h264_sei_uninit(H264SEIContext *h)
>  av_freep(&h->a53_caption.a53_caption);
>  }
>  
> -static int decode_picture_timing(H264SEIPictureTiming *h, GetBitContext *gb,
> - const SPS *sps, void *logctx)
> +int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS 
> *sps,
> +   void *logctx)
>  {
> -if (!sps)
> -return AVERROR_INVALIDDATA;
> +GetBitContext gb;

GetBitContext gbc, *gb = &gbc;
init_get_bits(gb, h->payload, sizeof(h->payload));

That way you don't have to replace all the lines below.

> +
> +init_get_bits(&gb, h->payload, sizeof(h->payload));
>  
>  if (sps->nal_hrd_parameters_present_flag ||
>  sps->vcl_hrd_parameters_present_flag) {
> -h->cpb_removal_delay = get_bits(gb, sps->cpb_removal_delay_length);
> -h->dpb_output_delay  = get_bits(gb, sps->dpb_output_delay_length);
> +h->cpb_removal_delay = get_bits(&gb, sps->cpb_removal_delay_length);
> +h->dpb_output_delay  = get_bits(&gb, sps->dpb_output_delay_length);

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

Re: [libav-devel] [PATCH 2/4] h264_sei: parse the picture timing SEIs correctly

2017-05-19 Thread James Almer
On 5/19/2017 11:52 AM, Diego Biurrun wrote:
> On Fri, May 19, 2017 at 11:13:26AM -0300, James Almer wrote:
>> On 5/19/2017 10:47 AM, Anton Khirnov wrote:
>>> --- a/libavcodec/h264_sei.c
>>> +++ b/libavcodec/h264_sei.c
>>> @@ -54,21 +55,22 @@ void ff_h264_sei_uninit(H264SEIContext *h)
>>>  
>>> -static int decode_picture_timing(H264SEIPictureTiming *h, GetBitContext 
>>> *gb,
>>> - const SPS *sps, void *logctx)
>>> +int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS 
>>> *sps,
>>> +   void *logctx)
>>>  {
>>> -if (!sps)
>>> -return AVERROR_INVALIDDATA;
>>> +GetBitContext gb;
>>
>> GetBitContext gbc, *gb = &gbc;
>> init_get_bits(gb, h->payload, sizeof(h->payload));
>>
>> That way you don't have to replace all the lines below.
> 
> Seems pointless IMO, replacing the variables does not hurt anything...
> 
> Diego

Bigger patch that makes the change seem more complex than it really is
for no gain, affects git blame output, etc.

It's a nit anyway, so do as you prefer.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/2] configure: Default to _WIN32_WINNT=0x0501 as minimum, for legacy mingw

2017-05-31 Thread James Almer
On 5/31/2017 7:21 AM, Martin Storsjö wrote:
> This makes the getaddrinfo functions visible, which aren't normally
> by default on legacy mingw.
> 
> We already force __MSVCRT_VERSION__ to an XP version.
> ---
>  configure | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/configure b/configure
> index fb3920a261..77926bb85b 100755
> --- a/configure
> +++ b/configure
> @@ -4133,6 +4133,8 @@ probe_libc(){
>  add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
>  check_${pfx}cpp_condition _mingw.h "__MSVCRT_VERSION__ < 0x0700" &&
>  add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700
> +check_${pfx}cpp_condition windows.h "_WIN32_WINNT < 0x0501" &&

defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501

Or 0x0502 as Hendrik suggested.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/2] configure: Default to _WIN32_WINNT=0x0501 as minimum, for legacy mingw

2017-05-31 Thread James Almer
On 5/31/2017 9:31 AM, Martin Storsjö wrote:
> On Wed, 31 May 2017, James Almer wrote:
> 
>> On 5/31/2017 7:21 AM, Martin Storsjö wrote:
>>> This makes the getaddrinfo functions visible, which aren't normally
>>> by default on legacy mingw.
>>>
>>> We already force __MSVCRT_VERSION__ to an XP version.
>>> ---
>>>  configure | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/configure b/configure
>>> index fb3920a261..77926bb85b 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -4133,6 +4133,8 @@ probe_libc(){
>>>  add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
>>>  check_${pfx}cpp_condition _mingw.h "__MSVCRT_VERSION__ <
>>> 0x0700" &&
>>>  add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700
>>> +check_${pfx}cpp_condition windows.h "_WIN32_WINNT < 0x0501" &&
>>
>> defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501
> 
> Well, after including windows.h, I would expect that it is defined
> already, but sure, I can add the extra defined().
> 
> I intentionally picked windows.h because e.g. legacy mingw32 defines the
> default in windef.h + winver.h, while mingw-w64 defines it in _mingw.h.
> This codeblock should only be used for legacy mingw32, but despite that
> I wanted to have a test that should work as intended even outside of that.
> 
> Hendrik mentioned that you might have something similiar in ffmpeg
> already, and I found 69f7aad5710 authored by you. There I noticed that
> you only check _mingw.h, but at least in my old mingw32 version,
> _mingw.h doesn't actually define _WIN32_WINNT at all, so the test there
> probably doesn't really check what you intended.

The check

"defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0502" || add_${pfx}cppflags
-D_WIN32_WINNT=0x0502

will succeed if _WIN32_WINNT is not defined, or if it's defined by the
header or the user with for example --extra-cflags with a value lower
than 0x0502. That way said value is forced as a minimum.
If what you say is true then it would only be a problem if a mingw32
toolchain at some point starts defaulting to for example 0x0601, in
which case it would wrongly supersede it, but i don't see that ever
happening. Including windows.h may be a good idea anyway to prevent that.

I didn't test that commit but others did before i pushed it, and it was
reportedly working as intended.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH] configure: fix assignment of assembler specific flags

2017-06-23 Thread James Almer
If the first assembler to be probed is an old nasm build, X86ASM_DEPFLAGS
will be set and remain so after yasm is ultimately used as fallback.
This results in yasm being called with said nasm specific flags and failing
during actual object assembly but not with configure sanity checks.

Regression since adfd7892e3b8b40e7a1620f7254459d8e096a9a1

Signed-off-by: James Almer 
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index ce0f6c919..3a6df98a9 100755
--- a/configure
+++ b/configure
@@ -4515,12 +4515,10 @@ EOF
 x86asmexe=$x86asmexe_probe
 x86asm_type=nasm
 x86asm_debug="-g -F dwarf"
-X86ASM_DEPFLAGS='-MD $(@:.o=.d)'
 elif check_cmd $x86asmexe_probe --version; then
 x86asmexe=$x86asmexe_probe
 x86asm_type=yasm
 x86asm_debug="-g dwarf2"
-X86ASMDEP='$(DEPX86ASM) $(X86ASMFLAGS) -M $(X86ASM_O) $< > 
$(@:.o=.d)'
 fi
 check_x86asm "movbe ecx, [5]" && enable x86asm
 }
@@ -4531,6 +4529,8 @@ EOF
 probe_x86asm $program && break
 done
 disabled x86asm && die "nasm/yasm not found or too old. Use 
--disable-x86asm for a crippled build."
+test $x86asm_type = 'nasm' && X86ASM_DEPFLAGS='-MD $(@:.o=.d)'
+test $x86asm_type = 'yasm' && X86ASMDEP='$(DEPX86ASM) $(X86ASMFLAGS) 
-M $(X86ASM_O) $< > $(@:.o=.d)'
 X86ASMFLAGS="-f $objformat"
 enabled pic   && append X86ASMFLAGS "-DPIC"
 test -n "$extern_prefix"  && append X86ASMFLAGS "-DPREFIX"
-- 
2.13.0

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

Re: [libav-devel] [PATCH 01/15] h264: Add stream constraint values to the common header

2017-06-24 Thread James Almer
On 6/23/2017 8:39 PM, Mark Thompson wrote:
> With comments describing the derivation of each value.
> ---
>  libavcodec/h264.h | 45 +
>  1 file changed, 45 insertions(+)
> 
> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
> index eb3805c06..aa137b5b5 100644
> --- a/libavcodec/h264.h
> +++ b/libavcodec/h264.h
> @@ -44,4 +44,49 @@ enum {
>  H264_NAL_AUXILIARY_SLICE = 19,
>  };
>  
> +
> +enum {

enum seems like a weird choice for this to be honest. Same with the
following patch.

What's wrong with using #define?

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

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

Re: [libav-devel] [PATCH] configure: Reset X86ASM_DEPFLAGS when probing for Yasm assembler

2017-06-24 Thread James Almer
On 6/24/2017 3:14 PM, Diego Biurrun wrote:
> These flags might be set from a previous probe for NASM, but Yasm does
> not grok the flags, resulting in errors during assembling.
> ---
> 
> James, please test.
> 
>  configure | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/configure b/configure
> index ce0f6c9..7ff329b 100755
> --- a/configure
> +++ b/configure
> @@ -4521,6 +4521,7 @@ EOF
>  x86asm_type=yasm
>  x86asm_debug="-g dwarf2"
>  X86ASMDEP='$(DEPX86ASM) $(X86ASMFLAGS) -M $(X86ASM_O) $< > 
> $(@:.o=.d)'
> +X86ASM_DEPFLAGS=
>  fi
>  check_x86asm "movbe ecx, [5]" && enable x86asm
>  }

Reset X86ASMDEP as well when probing for nasm and it should be good.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [RFC] JPEG2000: optimisation of mct using SSE instructions

2017-06-27 Thread James Almer
On 6/27/2017 11:32 AM, maxime taisant wrote:
> From: Maxime Taisant 
> 
> This code aim to improve the performances of the mct using SSE instructions.
> It was submitted by Nicolas Bertrand a while ago and was rejected.
> I would like to have some informations on what needs to be modified or 
> improved.
> Thank you.

It was rejected because x86 intrinsics are not allowed.

See
https://lists.libav.org/pipermail/libav-devel/2015-November/073179.html
where a nasm syntax port is linked.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] caf: add an Opus tag

2017-07-21 Thread James Almer
On 7/21/2017 9:19 AM, Anton Khirnov wrote:
> Quoting Anton Khirnov (2017-07-21 13:59:41)
>> CC: libav-sta...@libav.org
>> ---
>>  libavformat/caf.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/libavformat/caf.c b/libavformat/caf.c
>> index cf128d5..c299cad 100644
>> --- a/libavformat/caf.c
>> +++ b/libavformat/caf.c
>> @@ -49,6 +49,7 @@ const AVCodecTag ff_codec_caf_tags[] = {
>>  { AV_CODEC_ID_QCELP,   MKBETAG('Q','c','l','p') },
>>  { AV_CODEC_ID_QDM2,MKBETAG('Q','D','M','2') },
>>  { AV_CODEC_ID_QDM2,MKBETAG('Q','D','M','C') },
>> +{ AV_CODEC_ID_OPUS,MKBETAG('o','p','u','s') },
>>/* currently unsupported codecs */
>>/*{ AC-3 over S/PDIF  MKBETAG('c','a','c','3') },*/
>>/*{ MPEG4CELP MKBETAG('c','e','l','p') },*/
>> -- 
>> 2.0.0
>>
> 
> Please disregard, seems I didn't test this properly back when I wrote
> it.
> Sorry for the noise.

Were you able to figure out the full contents of the kuki chunk for Opus
files?
I looked at it briefly on two files, one stereo and one mono. First
value was 2048 on both (no idea its meaning), second was sample rate
(Apparently fixed to 48000 and not original sample rate as in OpusHead),
third was the same value as frames_per_packet from the desc chunk,
fourth was -1000 on both files as well (also no idea), and fifth was
channel count.

Other formats would just dump the contents from the relevant ISOM box in
the kuki chunk, but for some reason Opus doesn't. None of the values
looked like pre_skip to me, so i don't think we could manually create a
meaningful OpusHead to fill the stream's extradata.

The user that created the two files i checked also said he couldn't
create a multichannel one, and demuxing/decoding seemed to work fine
when i left extradata empty (the decoder fills it with defaults if
channels <= 2).
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 2/2] avcodec: add libdcadec decoder

2015-03-23 Thread James Almer
On 23/03/15 10:23 AM, Luca Barbato wrote:
> On 23/03/15 12:45, Hendrik Leppkes wrote:
>> ---
>>  configure  |   4 +
>>  libavcodec/Makefile|   1 +
>>  libavcodec/allcodecs.c |   1 +
>>  libavcodec/libdcadec.c | 197 
>> +
>>  4 files changed, 203 insertions(+)
>>  create mode 100644 libavcodec/libdcadec.c
>>
>> diff --git a/configure b/configure
>> index 3c38a8c..6eaac29 100755
>> --- a/configure
>> +++ b/configure
>> @@ -184,6 +184,7 @@ External library support:
>>--enable-libcdio enable audio CD grabbing with libcdio
>>--enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
>> and libraw1394 [no]
>> +  --enable-libdcadec   enable DCA decoding via libdcadec [no]
>>--enable-libfaac enable AAC encoding via libfaac [no]
>>--enable-libfdk-aac  enable AAC de/encoding via libfdk-aac [no]
>>--enable-libfreetype enable libfreetype [no]
>> @@ -1149,6 +1150,7 @@ EXTERNAL_LIBRARY_LIST="
>>  libbs2b
>>  libcdio
>>  libdc1394
>> +libdcadec
>>  libfaac
>>  libfdk_aac
>>  libfontconfig
>> @@ -2004,6 +2006,7 @@ mpeg4video_parser_select="error_resilience h263dsp 
>> mpeg_er mpegvideo qpeldsp"
>>  vc1_parser_select="mpegvideo startcode vc1_decoder"
>>  
>>  # external libraries
>> +libdcadec_decoder_deps="libdcadec"
>>  libfaac_encoder_deps="libfaac"
>>  libfaac_encoder_select="audio_frame_queue"
>>  libfdk_aac_decoder_deps="libfdk_aac"
>> @@ -4206,6 +4209,7 @@ enabled avisynth  && { { check_header 
>> "avisynth/avisynth_c.h" && check_l
>>  enabled frei0r&& { check_header frei0r.h || die "ERROR: 
>> frei0r.h header not found"; }
>>  enabled gnutls&& require_pkg_config gnutls gnutls/gnutls.h 
>> gnutls_global_init
>>  enabled libbs2b   && require_pkg_config libbs2b bs2b.h bs2b_open
>> +enabled libdcadec && require libdcadec libdcadec/dca_context.h 
>> dcadec_context_create -ldcadec
> 
> I'll get libdcadec a pkgconf file =p

It has one already. 
https://github.com/foo86/dcadec/commit/1ddd3b5547c33b36093c0786632c1287714252c6

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


Re: [libav-devel] [PATCH] Canopus HQ/HQA decoder

2015-03-24 Thread James Almer
On 22/03/15 12:49 PM, Vittorio Giovara wrote:
> +// AAN IDCT

If this isn't already in the tree somewhere and it's generic enough that it can 
be reused, 
then it should be shared like faanidct and added to idctdsp.
And if it's HQ/HQA specific, it still could be split into a new hqdsp context 
for potential 
optimizations.

> +
> +#define FIX_1_082 17734
> +#define FIX_1_847 30274
> +#define FIX_1_414 23170
> +#define FIX_2_613 21407 // divided by two to fit the range
> +
> +#define IDCTMUL(a, b) ((a) * (b) >> 16)
> +
> +static inline void idct_row(int16_t *blk)
> +{
> +int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, tmpA;
> +int tmpB, tmpC, tmpD, tmpE, tmpF, tmp10, tmp11, tmp12, tmp13, tmp14;
> +
> +tmp0 = blk[5] - blk[3];
> +tmp1 = blk[5] + blk[3];
> +tmp2 = blk[1] - blk[7];
> +tmp3 = blk[1] + blk[7];
> +tmp4 = tmp3 - tmp1;
> +tmp5 = IDCTMUL(tmp0 + tmp2, FIX_1_847);
> +tmp6 = IDCTMUL(tmp2,FIX_1_082) - tmp5;
> +tmp7 = tmp5 - IDCTMUL(tmp0, FIX_2_613) * 2;
> +tmp8 = tmp3 + tmp1;
> +tmp9 = tmp7 * 4 - tmp8;
> +tmpA = IDCTMUL(tmp4, FIX_1_414) * 4 - tmp9;
> +tmpB = tmp6 * 4 + tmpA;
> +tmpC = blk[2] + blk[6];
> +tmpD = blk[2] - blk[6];
> +tmpE = blk[0] - blk[4];
> +tmpF = blk[0] + blk[4];
> +
> +tmp10 = IDCTMUL(tmpD, FIX_1_414) * 4 - tmpC;
> +tmp11 = tmpE - tmp10;
> +tmp12 = tmpF - tmpC;
> +tmp13 = tmpE + tmp10;
> +tmp14 = tmpF + tmpC;
> +
> +blk[0] = tmp14 + tmp8;
> +blk[1] = tmp13 + tmp9;
> +blk[2] = tmp11 + tmpA;
> +blk[3] = tmp12 - tmpB;
> +blk[4] = tmp12 + tmpB;
> +blk[5] = tmp11 - tmpA;
> +blk[6] = tmp13 - tmp9;
> +blk[7] = tmp14 - tmp8;
> +}
> +
> +static inline void idct_col(int16_t *blk)
> +{
> +int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, tmpA;
> +int tmpB, tmpC, tmpD, tmpE, tmpF, tmp10, tmp11, tmp12, tmp13, tmp14;
> +
> +tmp0 = blk[5 * 8] - blk[3 * 8];
> +tmp1 = blk[5 * 8] + blk[3 * 8];
> +tmp2 = blk[1 * 8] * 2 - (blk[7 * 8] >> 2);
> +tmp3 = blk[1 * 8] * 2 + (blk[7 * 8] >> 2);
> +tmp4 = tmp3 - tmp1;
> +tmp5 = IDCTMUL(tmp0 + tmp2, FIX_1_847);
> +tmp6 = IDCTMUL(tmp2,FIX_1_082) - tmp5;
> +tmp7 = tmp5 - IDCTMUL(tmp0, FIX_2_613) * 2;
> +tmp8 = (tmp3 + tmp1) >> 1;
> +tmp9 = tmp7 * 2 - tmp8;
> +tmpA = IDCTMUL(tmp4, FIX_1_414) * 2 - tmp9;
> +tmpB = tmp6 * 2 + tmpA;
> +tmpC =  blk[2 * 8] + (blk[6 * 8] >> 1) >> 1;
> +tmpD =  blk[2 * 8] - (blk[6 * 8] >> 1);
> +tmpE = (blk[0 * 8] >> 1) - (blk[4 * 8] >> 1) + 0x2020;
> +tmpF = (blk[0 * 8] >> 1) + (blk[4 * 8] >> 1) + 0x2020;
> +
> +tmp10 = IDCTMUL(tmpD, FIX_1_414) * 2 - tmpC;
> +tmp11 = tmpE - tmp10;
> +tmp12 = tmpF - tmpC;
> +tmp13 = tmpE + tmp10;
> +tmp14 = tmpF + tmpC;
> +
> +blk[0 * 8] = (tmp14 + tmp8) >> 6;
> +blk[1 * 8] = (tmp13 + tmp9) >> 6;
> +blk[2 * 8] = (tmp11 + tmpA) >> 6;
> +blk[3 * 8] = (tmp12 - tmpB) >> 6;
> +blk[4 * 8] = (tmp12 + tmpB) >> 6;
> +blk[5 * 8] = (tmp11 - tmpA) >> 6;
> +blk[6 * 8] = (tmp13 - tmp9) >> 6;
> +blk[7 * 8] = (tmp14 - tmp8) >> 6;
> +}
> +
> +static void hq_idct_put(uint8_t *dst, int stride, int16_t *block)
> +{
> +int i, j;
> +
> +for (i = 0; i < 8; i++)
> +idct_row(block + i * 8);
> +for (i = 0; i < 8; i++)
> +idct_col(block + i);
> +
> +// or use IDCTDSPContext.put_pixels_clamped()

Bench and see if it's worth using? There's an optimized version for most 
platforms after 
all.

> +for (i = 0; i < 8; i++) {
> +for (j = 0; j < 8; j++)
> +dst[j] = av_clip_uint8(block[j + i * 8]);
> +dst += stride;
> +}
> +}
> +
> +static inline void put_blocks(HQContext *c, AVFrame *pic,
> +  int plane, int x, int y, int ilace,
> +  int16_t *block0, int16_t *block1)
> +{
> +uint8_t *p = pic->data[plane] + x;
> +
> +hq_idct_put(p + y * pic->linesize[plane],
> +pic->linesize[plane] << ilace, block0);
> +hq_idct_put(p + (y + (ilace ? 1 : 8)) * pic->linesize[plane],
> +pic->linesize[plane] << ilace, block1);
> +}

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


Re: [libav-devel] [PATCH] tiff: Return more meaningful error codes

2015-03-29 Thread James Almer
On 28/03/15 2:52 PM, Justin Ruggles wrote:
> On 03/28/2015 01:42 PM, Himangi Saraogi wrote:
>> ---
>>   libavcodec/tiffenc.c | 11 ++-
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
>> index 169360f..46e4207 100644
>> --- a/libavcodec/tiffenc.c
>> +++ b/libavcodec/tiffenc.c
>> @@ -153,7 +153,8 @@ static int add_entry1(TiffEncoderContext *s,
>>* @param dst Output buffer
>>* @param n Size of input buffer
>>* @param compr Compression method
>> - * @return Number of output bytes. If an output error is encountered, -1 
>> returned
>> + * @return Number of output bytes. If an output error is encountered, a 
>> negative
>> + * value corresponding to an AVERROR error code is returned.
>>*/
>>   static int encode_strip(TiffEncoderContext *s, const int8_t *src,
>>   uint8_t *dst, int n, int compr)
>> @@ -166,14 +167,14 @@ static int encode_strip(TiffEncoderContext *s, const 
>> int8_t *src,
>>   unsigned long zlen = s->buf_size - (*s->buf - s->buf_start);
>>   if (compress(dst, &zlen, src, n) != Z_OK) {
>>   av_log(s->avctx, AV_LOG_ERROR, "Compressing failed\n");
>> -return -1;
>> +return AVERROR_INVALIDDATA;
> 
> This is an unknown error from an external library, so AVERROR_UNKNOWN should 
> be returned.
> 
>>   }
>>   return zlen;
>>   }
>>   #endif
>>   case TIFF_RAW:
>>   if (check_size(s, n))
>> -return -1;
>> +return AVERROR(EINVAL);
>>   memcpy(dst, src, n);
>>   return n;
>>   case TIFF_PACKBITS:
>> @@ -182,7 +183,7 @@ static int encode_strip(TiffEncoderContext *s, const 
>> int8_t *src,
>>   case TIFF_LZW:
>>   return ff_lzw_encode(s->lzws, src, n);
>>   default:
>> -return -1;
>> +return AVERROR_UNKNOWN;
> 
> Should be AVERROR_BUG since compression type is an AVOption that has defined 
> bounds.

No, this should be AVERROR(EINVAL) because even inside the bounds there are 
several values for 
compressions that are not currently supported.
i can do avconv -i INPUT -compression_algo 2 OUTPUT and it wouldn't be a bug, 
it would be an 
invalid argument.

> 
>>   }
>>   }
>>
>> @@ -291,7 +292,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
>> *pkt,
>>   default:
>>   av_log(s->avctx, AV_LOG_ERROR,
>>  "This colors format is not supported\n");
>> -return -1;
>> +return AVERROR_INVALIDDATA;
> 
> This really never should happen in practice, but at any rate the correct 
> error value is AVERROR(EINVAL) because it is an unsupported/invalid field set 
> by the user.
> 
>>   }
>>
>>   if (s->compr == TIFF_DEFLATE   ||
>>
> 
> 
> Thanks,
> Justin
> 
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel

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


[libav-devel] [PATCH] avutil: remove pointless bmi1 define

2015-04-18 Thread James Almer
Signed-off-by: James Almer 
---
 libavutil/cpu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 354d21e..4e8ef61 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -90,8 +90,7 @@ int av_parse_cpu_flags(const char *s)
 #define CPUFLAG_FMA3 (AV_CPU_FLAG_FMA3 | CPUFLAG_AVX)
 #define CPUFLAG_FMA4 (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX)
 #define CPUFLAG_AVX2 (AV_CPU_FLAG_AVX2 | CPUFLAG_AVX)
-#define CPUFLAG_BMI1 (AV_CPU_FLAG_BMI1)
-#define CPUFLAG_BMI2 (AV_CPU_FLAG_BMI2 | CPUFLAG_BMI1)
+#define CPUFLAG_BMI2 (AV_CPU_FLAG_BMI2 | AV_CPU_FLAG_BMI1)
 static const AVOption cpuflags_opts[] = {
 { "flags"   , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, 
INT64_MAX, .unit = "flags" },
 #if   ARCH_PPC
@@ -113,7 +112,7 @@ int av_parse_cpu_flags(const char *s)
 { "fma3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA3
 },.unit = "flags" },
 { "fma4", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA4
 },.unit = "flags" },
 { "avx2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX2
 },.unit = "flags" },
-{ "bmi1", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_BMI1
 },.unit = "flags" },
+{ "bmi1", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_BMI1
 },.unit = "flags" },
 { "bmi2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_BMI2
 },.unit = "flags" },
 { "3dnow"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOW   
 },.unit = "flags" },
 { "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOWEXT
 },.unit = "flags" },
-- 
2.3.5

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


Re: [libav-devel] [PATCH 01/14] Move AVAudioServiceType enum from lavc to lavu

2015-05-02 Thread James Almer
On 02/05/15 5:22 AM, Luca Barbato wrote:
> On 02/05/15 06:23, Anton Khirnov wrote:
>> Quoting Vittorio Giovara (2015-05-02 01:17:08)
>>> The enum is used by lavc, lavf and lavfi, and it is referenced by lavu,
>>> so it sementically belongs to lavu more than any other.
>>>
>>> This change allows to drop an avcodec.h inclusion from avfilter.h.
>>>
>>
>> I would disagree here, since this logic would apply to any side data
>> struct whatsoever. And I don't think they should all be in lavu.
> 
> libav(meta)data ? =)
> 
> Might be nice split libavutil a little so:
> 
> libavu -> mem, basic data types, compat, version machinery
> 
> libavdata -> packet, frame, samples and pixels

Sounds like libavcore.

> 
> libavcomp -> compressors
> 
> libavhash -> hashes

Might as well just drop all these modules and make libgcrypt a mandatory 
dependency if
it comes to this...
I don't think anyone links to lavu exclusively for the crypto modules. A 
library like
this would exist only to be linked against lavc/lavf.

> 
> This is something I'd like to have soon if nobody is strongly against it.
> 
> lu
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
> 

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


[libav-devel] [PATCH] dashenc: replace attribute id with contentType for the AdaptationSet element

2015-05-09 Thread James Almer
id should be an integer, not a string. It is also optional, so use
contentType instead which is the proper attribute for these values.

This fixes an MPD validation error.

Signed-off-by: James Almer 
---
 libavformat/dashenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index fc5c823..f228b86 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -503,7 +503,7 @@ static int write_manifest(AVFormatContext *s, int final)
 }
 
 if (c->has_video) {
-avio_printf(out, "\t\t\n");
+avio_printf(out, "\t\t\n");
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *st = s->streams[i];
 OutputStream *os = &c->streams[i];
@@ -516,7 +516,7 @@ static int write_manifest(AVFormatContext *s, int final)
 avio_printf(out, "\t\t\n");
 }
 if (c->has_audio) {
-avio_printf(out, "\t\t\n");
+avio_printf(out, "\t\t\n");
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *st = s->streams[i];
 OutputStream *os = &c->streams[i];
-- 
2.4.0

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


Re: [libav-devel] [PATCH] avcodec/libx265: use x265 Multi-library Interface to query the API

2015-05-12 Thread James Almer
On 12/05/15 6:00 PM, Luca Barbato wrote:
> On 11/05/15 17:25, Derek Buitenhuis wrote:
>> From: Gopu Govindaswamy 
> 
> 
> The x265pic.bitDepth is set on encode_frame while I assume that this
> information should be used at init now.
> 
> I'm not sure how recent is this api version, I hope it isn't necessary

The API as used and required by this patch is not available on any tagged 
release
right now. It will be in x265 1.7.

> to consider adding a fallback path even if it is easy with a bunch of
> defines since the signatures look the same beside x264 -> ctx->api.
> 
> I'll edit the subject and make it fit in case ti does not tomorrow.
> 
> Thanks for picking it up.
> 
> lu
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
> 

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


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

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

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

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

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

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

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

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

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


[libav-devel] [PATCH] x86/cpu: add AV_CPU_FLAG_AVXSLOW flag

2015-05-22 Thread James Almer
Signed-off-by: James Almer 
---
 doc/APIchanges  |  3 +++
 libavutil/cpu.c |  3 +++
 libavutil/cpu.h |  1 +
 libavutil/version.h |  4 ++--
 libavutil/x86/cpu.c | 17 ++---
 5 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5d39ec6..b126364 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxx - lavu 54.13.0 - cpu.h
+  Add AV_CPU_FLAG_AVXSLOW.
+
 2015-xx-xx - xxx - lavc 56.23.0
   Add av_vda_default_init2.
 
diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 4e8ef61..e24b9dd 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -86,6 +86,7 @@ int av_parse_cpu_flags(const char *s)
 #define CPUFLAG_SSE4 (AV_CPU_FLAG_SSE4 | CPUFLAG_SSSE3)
 #define CPUFLAG_SSE42(AV_CPU_FLAG_SSE42| CPUFLAG_SSE4)
 #define CPUFLAG_AVX  (AV_CPU_FLAG_AVX  | CPUFLAG_SSE42)
+#define CPUFLAG_AVXSLOW  (AV_CPU_FLAG_AVXSLOW  | CPUFLAG_AVX)
 #define CPUFLAG_XOP  (AV_CPU_FLAG_XOP  | CPUFLAG_AVX)
 #define CPUFLAG_FMA3 (AV_CPU_FLAG_FMA3 | CPUFLAG_AVX)
 #define CPUFLAG_FMA4 (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX)
@@ -108,6 +109,7 @@ int av_parse_cpu_flags(const char *s)
 { "sse4.1"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE4
 },.unit = "flags" },
 { "sse4.2"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE42   
 },.unit = "flags" },
 { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX 
 },.unit = "flags" },
+{ "avxslow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVXSLOW 
 },.unit = "flags" },
 { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_XOP 
 },.unit = "flags" },
 { "fma3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA3
 },.unit = "flags" },
 { "fma4", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA4
 },.unit = "flags" },
@@ -219,6 +221,7 @@ static const struct {
 { AV_CPU_FLAG_SSE4,  "sse4.1" },
 { AV_CPU_FLAG_SSE42, "sse4.2" },
 { AV_CPU_FLAG_AVX,   "avx"},
+{ AV_CPU_FLAG_AVXSLOW,   "avxslow"},
 { AV_CPU_FLAG_XOP,   "xop"},
 { AV_CPU_FLAG_FMA3,  "fma3"   },
 { AV_CPU_FLAG_FMA4,  "fma4"   },
diff --git a/libavutil/cpu.h b/libavutil/cpu.h
index 7ce..c9469b3 100644
--- a/libavutil/cpu.h
+++ b/libavutil/cpu.h
@@ -45,6 +45,7 @@
 #define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
 #define AV_CPU_FLAG_SSE420x0200 ///< Nehalem SSE4.2 functions
 #define AV_CPU_FLAG_AVX  0x4000 ///< AVX functions: requires OS 
support even if YMM registers aren't used
+#define AV_CPU_FLAG_AVXSLOW   0x800 ///< AVX supported, but slow when 
using YMM registers (e.g. Bulldozer)
 #define AV_CPU_FLAG_XOP  0x0400 ///< Bulldozer XOP functions
 #define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions
 #define AV_CPU_FLAG_CMOV 0x1000 ///< i686 cmov
diff --git a/libavutil/version.h b/libavutil/version.h
index 9c45e0e..378f7b7 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,8 +54,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 54
-#define LIBAVUTIL_VERSION_MINOR 12
-#define LIBAVUTIL_VERSION_MICRO  1
+#define LIBAVUTIL_VERSION_MINOR 13
+#define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index 8be6d94..098ccf7 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -167,6 +167,7 @@ int ff_get_cpu_flags_x86(void)
 if (ext_caps & (1 << 22))
 rval |= AV_CPU_FLAG_MMXEXT;
 
+if (!strncmp(vendor.c, "AuthenticAMD", 12)) {
 /* Allow for selectively disabling SSE2 functions on AMD processors
with SSE2 support but not SSE4a. This includes Athlon64, some
Opteron, and some Sempron processors. MMX, SSE, or 3DNow! are faster
@@ -174,9 +175,19 @@ int ff_get_cpu_flags_x86(void)
AV_CPU_FLAG_SSE2 and AV_CPU_FLAG_SSE2SLOW are both set in this case
so that SSE2 is used unless explicitly disabled by checking
AV_CPU_FLAG_SSE2SLOW. */
-if (!strncmp(vendor.c, "AuthenticAMD", 12) &&
-rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x0040)) {
-rval |= AV_CPU_FLAG_SSE2SLOW;
+if (rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x0040))
+rval |= AV_CPU_FLAG_SSE2SLOW;
+
+/* Similar to the above but for 

Re: [libav-devel] [PATCH] configure: we don't need d3d11va_lib as avconv doesn't support it

2015-05-25 Thread James Almer
On 25/05/15 11:49 AM, Steve Lhomme wrote:
> ---
>  configure | 5 -
>  1 file changed, 5 deletions(-)
> 
> diff --git a/configure b/configure
> index 18280b9..a9ecad1 100755
> --- a/configure
> +++ b/configure
> @@ -1555,7 +1555,6 @@ HAVE_LIST="
>  atomics_native
>  dos_paths
>  d3d11_cobj
> -d3d11va_lib
>  dxva2_lib
>  libc_msvcrt
>  libdc1394_1
> @@ -4618,10 +4617,6 @@ check_deps $CONFIG_LIST   \
> $HAVE_LIST \
> $ALL_COMPONENTS\
>  
> -enabled_all d3d11va d3d11_cobj CoTaskMemFree &&
> -prepend avconv_libs $($ldflags_filter "-lole32") &&
> -enable d3d11va_lib
> -
>  enabled_all dxva2 CoTaskMemFree &&
>  prepend avconv_libs $($ldflags_filter "-lole32") &&
>  enable dxva2_lib

You could also remove d3d11_cobj and its configure check, then.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: we don't need d3d11va_lib as avconv doesn't support it

2015-05-25 Thread James Almer
On 25/05/15 8:24 PM, James Almer wrote:
> On 25/05/15 11:49 AM, Steve Lhomme wrote:
>> ---
>>  configure | 5 -
>>  1 file changed, 5 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 18280b9..a9ecad1 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1555,7 +1555,6 @@ HAVE_LIST="
>>  atomics_native
>>  dos_paths
>>  d3d11_cobj
>> -d3d11va_lib
>>  dxva2_lib
>>  libc_msvcrt
>>  libdc1394_1
>> @@ -4618,10 +4617,6 @@ check_deps $CONFIG_LIST   \
>> $HAVE_LIST \
>> $ALL_COMPONENTS\
>>  
>> -enabled_all d3d11va d3d11_cobj CoTaskMemFree &&
>> -prepend avconv_libs $($ldflags_filter "-lole32") &&
>> -enable d3d11va_lib
>> -
>>  enabled_all dxva2 CoTaskMemFree &&
>>  prepend avconv_libs $($ldflags_filter "-lole32") &&
>>  enable dxva2_lib
> 
> You could also remove d3d11_cobj and its configure check, then.

Actually no, don't remove the d3d11_cobj check. Repurpose it as it's the only 
check that actually makes
sure things will work: 
https://fate.libav.org/x86_64-mingw-w64-gcc-5.1/20150525105137/compile

CONFIG_D3D11VA, currently checked in libavcodec, is true if d3d11.h and dxva.h 
exist, but those existing
doesn't mean the needed functionality is there, as shown in the above FATE 
client using a recent mingw-w64
version.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] D3D11va: add a Direct3D11 video decoder similar to DXVA2

2015-05-25 Thread James Almer
On 25/05/15 2:31 AM, Steve Lhomme wrote:
> On Sun, May 24, 2015 at 1:13 PM, Luca Barbato  wrote:
>> On 24/05/15 07:59, Steve Lhomme wrote:
>>> Any update on this patch ?
>>>
>>
>> If it works for you I'll merge it Monday. I do not have mean to test it
>> directly I guess.
> 
> Yes, it works. Building may be tricky until my patches are merged into
> wine & mingw-w64, unless you build with the Microsoft SDK.

In addition to the mingw-w64 breakage i mentioned in another thread, this is
making the h264, hevc and other fate tests fail on msvc x86_32.

https://fate.libav.org/x86_32-msvc11-windows-native/20150525152900
https://fate.libav.org/x86_32-msvc12-windows-native/20150525155646

msvc x86_64 seems unaffected.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/2] x86: check for AV_CPU_FLAG_AVXSLOW where useful

2015-05-25 Thread James Almer
Signed-off-by: James Almer 
---
The FMA4 functions from libavresample's audio_mix need to be handled
differently. Disabling them if avxslow is true is pointless since no
CPU out there currently has FMA4 and a fast float execution unit. So
I'm thinking about duplicating them and doing:

FMA3 YMM/XMM for current Intel CPUs (Basically, renaming the existing
functions)
FMA4 XMM for current AMD stuff (Regardless of x86_32 or x86_64).

I'll see about implementing that in the coming days.

 libavcodec/x86/dcadsp_init.c   |  4 ++--
 libavcodec/x86/dct_init.c  |  2 +-
 libavcodec/x86/fft_init.c  |  2 +-
 libavfilter/x86/af_volume_init.c   |  2 +-
 libavresample/x86/audio_convert_init.c | 10 ++
 libavresample/x86/audio_mix_init.c | 10 ++
 libavresample/x86/dither_init.c|  4 ++--
 libavutil/x86/float_dsp_init.c |  2 +-
 libavutil/x86/lls_init.c   |  2 +-
 9 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c
index 9acb818..8deb6d6 100644
--- a/libavcodec/x86/dcadsp_init.c
+++ b/libavcodec/x86/dcadsp_init.c
@@ -98,10 +98,10 @@ av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
 if (EXTERNAL_SSE2(cpu_flags)) {
 s->synth_filter_float = synth_filter_sse2;
 }
-if (EXTERNAL_AVX(cpu_flags)) {
+if (EXTERNAL_AVX(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_AVXSLOW)) {
 s->synth_filter_float = synth_filter_avx;
 }
-if (EXTERNAL_FMA3(cpu_flags)) {
+if (EXTERNAL_FMA3(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_AVXSLOW)) {
 s->synth_filter_float = synth_filter_fma3;
 }
 #endif /* HAVE_YASM */
diff --git a/libavcodec/x86/dct_init.c b/libavcodec/x86/dct_init.c
index 7bda5e8..660d118 100644
--- a/libavcodec/x86/dct_init.c
+++ b/libavcodec/x86/dct_init.c
@@ -34,6 +34,6 @@ av_cold void ff_dct_init_x86(DCTContext *s)
 s->dct32 = ff_dct32_float_sse;
 if (EXTERNAL_SSE2(cpu_flags))
 s->dct32 = ff_dct32_float_sse2;
-if (EXTERNAL_AVX(cpu_flags))
+if (EXTERNAL_AVX(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_AVXSLOW))
 s->dct32 = ff_dct32_float_avx;
 }
diff --git a/libavcodec/x86/fft_init.c b/libavcodec/x86/fft_init.c
index 7ca72c5..840f348 100644
--- a/libavcodec/x86/fft_init.c
+++ b/libavcodec/x86/fft_init.c
@@ -48,7 +48,7 @@ av_cold void ff_fft_init_x86(FFTContext *s)
 s->fft_calc= ff_fft_calc_sse;
 s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
 }
-if (EXTERNAL_AVX(cpu_flags) && s->nbits >= 5) {
+if (EXTERNAL_AVX(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_AVXSLOW) && 
s->nbits >= 5) {
 /* AVX for SB */
 s->imdct_half  = ff_imdct_half_avx;
 s->fft_calc= ff_fft_calc_avx;
diff --git a/libavfilter/x86/af_volume_init.c b/libavfilter/x86/af_volume_init.c
index c59e0ed..f70bafa 100644
--- a/libavfilter/x86/af_volume_init.c
+++ b/libavfilter/x86/af_volume_init.c
@@ -52,7 +52,7 @@ av_cold void ff_volume_init_x86(VolumeContext *vol)
 vol->scale_samples = ff_scale_samples_s32_ssse3_atom;
 vol->samples_align = 4;
 }
-if (EXTERNAL_AVX(cpu_flags)) {
+if (EXTERNAL_AVX(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_AVXSLOW)) {
 vol->scale_samples = ff_scale_samples_s32_avx;
 vol->samples_align = 8;
 }
diff --git a/libavresample/x86/audio_convert_init.c 
b/libavresample/x86/audio_convert_init.c
index d85ca84..1aab0f7 100644
--- a/libavresample/x86/audio_convert_init.c
+++ b/libavresample/x86/audio_convert_init.c
@@ -227,10 +227,12 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
   6, 16, 4, "SSE4", 
ff_conv_fltp_to_flt_6ch_sse4);
 }
 if (EXTERNAL_AVX(cpu_flags)) {
-ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
-  0, 32, 16, "AVX", ff_conv_s32_to_flt_avx);
-ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
-  0, 32, 32, "AVX", ff_conv_flt_to_s32_avx);
+if (!(cpu_flags & AV_CPU_FLAG_AVXSLOW)) {
+ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
+  0, 32, 16, "AVX", 
ff_conv_s32_to_flt_avx);
+ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
+  0, 32, 32, "AVX", 
ff_conv_flt_to_s32_avx);
+}
 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
   2, 16, 16, "AVX", 
ff_conv_s16p_to_s16_2ch_avx);
 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
diff --git a/libavresam

[libav-devel] [PATCH 1/2] x86/cpu: add AV_CPU_FLAG_AVXSLOW flag

2015-05-25 Thread James Almer
Signed-off-by: James Almer 
---
Updated with a new libavutil version after the d3d11 patch.

 doc/APIchanges  |  3 +++
 libavutil/cpu.c |  3 +++
 libavutil/cpu.h |  1 +
 libavutil/version.h |  4 ++--
 libavutil/x86/cpu.c | 17 ++---
 5 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5d39ec6..2c443b0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxx - lavu 54.14.0 - cpu.h
+  Add AV_CPU_FLAG_AVXSLOW.
+
 2015-xx-xx - xxx - lavc 56.23.0
   Add av_vda_default_init2.
 
diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 4e8ef61..e24b9dd 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -86,6 +86,7 @@ int av_parse_cpu_flags(const char *s)
 #define CPUFLAG_SSE4 (AV_CPU_FLAG_SSE4 | CPUFLAG_SSSE3)
 #define CPUFLAG_SSE42(AV_CPU_FLAG_SSE42| CPUFLAG_SSE4)
 #define CPUFLAG_AVX  (AV_CPU_FLAG_AVX  | CPUFLAG_SSE42)
+#define CPUFLAG_AVXSLOW  (AV_CPU_FLAG_AVXSLOW  | CPUFLAG_AVX)
 #define CPUFLAG_XOP  (AV_CPU_FLAG_XOP  | CPUFLAG_AVX)
 #define CPUFLAG_FMA3 (AV_CPU_FLAG_FMA3 | CPUFLAG_AVX)
 #define CPUFLAG_FMA4 (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX)
@@ -108,6 +109,7 @@ int av_parse_cpu_flags(const char *s)
 { "sse4.1"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE4
 },.unit = "flags" },
 { "sse4.2"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE42   
 },.unit = "flags" },
 { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX 
 },.unit = "flags" },
+{ "avxslow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVXSLOW 
 },.unit = "flags" },
 { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_XOP 
 },.unit = "flags" },
 { "fma3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA3
 },.unit = "flags" },
 { "fma4", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA4
 },.unit = "flags" },
@@ -219,6 +221,7 @@ static const struct {
 { AV_CPU_FLAG_SSE4,  "sse4.1" },
 { AV_CPU_FLAG_SSE42, "sse4.2" },
 { AV_CPU_FLAG_AVX,   "avx"},
+{ AV_CPU_FLAG_AVXSLOW,   "avxslow"},
 { AV_CPU_FLAG_XOP,   "xop"},
 { AV_CPU_FLAG_FMA3,  "fma3"   },
 { AV_CPU_FLAG_FMA4,  "fma4"   },
diff --git a/libavutil/cpu.h b/libavutil/cpu.h
index 7ce..c9469b3 100644
--- a/libavutil/cpu.h
+++ b/libavutil/cpu.h
@@ -45,6 +45,7 @@
 #define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
 #define AV_CPU_FLAG_SSE420x0200 ///< Nehalem SSE4.2 functions
 #define AV_CPU_FLAG_AVX  0x4000 ///< AVX functions: requires OS 
support even if YMM registers aren't used
+#define AV_CPU_FLAG_AVXSLOW   0x800 ///< AVX supported, but slow when 
using YMM registers (e.g. Bulldozer)
 #define AV_CPU_FLAG_XOP  0x0400 ///< Bulldozer XOP functions
 #define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions
 #define AV_CPU_FLAG_CMOV 0x1000 ///< i686 cmov
diff --git a/libavutil/version.h b/libavutil/version.h
index 13bb6f0..c3342cd 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,8 +54,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 54
-#define LIBAVUTIL_VERSION_MINOR 13
-#define LIBAVUTIL_VERSION_MICRO  1
+#define LIBAVUTIL_VERSION_MINOR 14
+#define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index 8be6d94..098ccf7 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -167,6 +167,7 @@ int ff_get_cpu_flags_x86(void)
 if (ext_caps & (1 << 22))
 rval |= AV_CPU_FLAG_MMXEXT;
 
+if (!strncmp(vendor.c, "AuthenticAMD", 12)) {
 /* Allow for selectively disabling SSE2 functions on AMD processors
with SSE2 support but not SSE4a. This includes Athlon64, some
Opteron, and some Sempron processors. MMX, SSE, or 3DNow! are faster
@@ -174,9 +175,19 @@ int ff_get_cpu_flags_x86(void)
AV_CPU_FLAG_SSE2 and AV_CPU_FLAG_SSE2SLOW are both set in this case
so that SSE2 is used unless explicitly disabled by checking
AV_CPU_FLAG_SSE2SLOW. */
-if (!strncmp(vendor.c, "AuthenticAMD", 12) &&
-rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x0040)) {
-rval |= AV_CPU_FLAG_SSE2SLOW;
+if (rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x0040))
+rval |= AV_C

[libav-devel] [PATCH v2 2/3] x86/cpu: add helper macros to check for slow cpuflags

2015-05-26 Thread James Almer
Signed-off-by: James Almer 
---
 libavutil/cpu_internal.h | 12 
 libavutil/x86/cpu.h  | 18 ++
 2 files changed, 30 insertions(+)

diff --git a/libavutil/cpu_internal.h b/libavutil/cpu_internal.h
index 3bfe8a8..2e9b44b 100644
--- a/libavutil/cpu_internal.h
+++ b/libavutil/cpu_internal.h
@@ -24,8 +24,20 @@
 #define CPUEXT_SUFFIX(flags, suffix, cpuext)\
 (HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext))
 
+#define CPUEXT_SUFFIX_FAST(flags, suffix, cpuext)   \
+(HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext) && \
+ !((flags) & AV_CPU_FLAG_ ## cpuext ## SLOW))
+
+#define CPUEXT_SUFFIX_SLOW(flags, suffix, cpuext)   \
+(HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext) && \
+ ((flags) & AV_CPU_FLAG_ ## cpuext ## SLOW))
+
 #define CPUEXT(flags, cpuext) CPUEXT_SUFFIX(flags, , cpuext)
 
+#define CPUEXT_FAST(flags, cpuext) CPUEXT_SUFFIX_FAST(flags, , cpuext)
+
+#define CPUEXT_SLOW(flags, cpuext) CPUEXT_SUFFIX_SLOW(flags, , cpuext)
+
 int ff_get_cpu_flags_aarch64(void);
 int ff_get_cpu_flags_arm(void);
 int ff_get_cpu_flags_ppc(void);
diff --git a/libavutil/x86/cpu.h b/libavutil/x86/cpu.h
index 50da30e..0695436 100644
--- a/libavutil/x86/cpu.h
+++ b/libavutil/x86/cpu.h
@@ -32,11 +32,17 @@
 #define X86_MMXEXT(flags)   CPUEXT(flags, MMXEXT)
 #define X86_SSE(flags)  CPUEXT(flags, SSE)
 #define X86_SSE2(flags) CPUEXT(flags, SSE2)
+#define X86_SSE2_FAST(flags)CPUEXT_FAST(flags, SSE2)
+#define X86_SSE2_SLOW(flags)CPUEXT_SLOW(flags, SSE2)
 #define X86_SSE3(flags) CPUEXT(flags, SSE3)
+#define X86_SSE3_FAST(flags)CPUEXT_FAST(flags, SSE3)
+#define X86_SSE3_SLOW(flags)CPUEXT_SLOW(flags, SSE3)
 #define X86_SSSE3(flags)CPUEXT(flags, SSSE3)
 #define X86_SSE4(flags) CPUEXT(flags, SSE4)
 #define X86_SSE42(flags)CPUEXT(flags, SSE42)
 #define X86_AVX(flags)  CPUEXT(flags, AVX)
+#define X86_AVX_FAST(flags) CPUEXT_FAST(flags, AVX)
+#define X86_AVX_SLOW(flags) CPUEXT_SLOW(flags, AVX)
 #define X86_XOP(flags)  CPUEXT(flags, XOP)
 #define X86_FMA3(flags) CPUEXT(flags, FMA3)
 #define X86_FMA4(flags) CPUEXT(flags, FMA4)
@@ -48,11 +54,17 @@
 #define EXTERNAL_MMXEXT(flags)  CPUEXT_SUFFIX(flags, _EXTERNAL, MMXEXT)
 #define EXTERNAL_SSE(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE)
 #define EXTERNAL_SSE2(flags)CPUEXT_SUFFIX(flags, _EXTERNAL, SSE2)
+#define EXTERNAL_SSE2_FAST(flags)   CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, SSE2)
+#define EXTERNAL_SSE2_SLOW(flags)   CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, SSE2)
 #define EXTERNAL_SSE3(flags)CPUEXT_SUFFIX(flags, _EXTERNAL, SSE3)
+#define EXTERNAL_SSE3_FAST(flags)   CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, SSE3)
+#define EXTERNAL_SSE3_SLOW(flags)   CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, SSE3)
 #define EXTERNAL_SSSE3(flags)   CPUEXT_SUFFIX(flags, _EXTERNAL, SSSE3)
 #define EXTERNAL_SSE4(flags)CPUEXT_SUFFIX(flags, _EXTERNAL, SSE4)
 #define EXTERNAL_SSE42(flags)   CPUEXT_SUFFIX(flags, _EXTERNAL, SSE42)
 #define EXTERNAL_AVX(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX)
+#define EXTERNAL_AVX_FAST(flags)CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, AVX)
+#define EXTERNAL_AVX_SLOW(flags)CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, AVX)
 #define EXTERNAL_XOP(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, XOP)
 #define EXTERNAL_FMA3(flags)CPUEXT_SUFFIX(flags, _EXTERNAL, FMA3)
 #define EXTERNAL_FMA4(flags)CPUEXT_SUFFIX(flags, _EXTERNAL, FMA4)
@@ -64,11 +76,17 @@
 #define INLINE_MMXEXT(flags)CPUEXT_SUFFIX(flags, _INLINE, MMXEXT)
 #define INLINE_SSE(flags)   CPUEXT_SUFFIX(flags, _INLINE, SSE)
 #define INLINE_SSE2(flags)  CPUEXT_SUFFIX(flags, _INLINE, SSE2)
+#define INLINE_SSE2_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _INLINE, SSE2)
+#define INLINE_SSE2_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _INLINE, SSE2)
 #define INLINE_SSE3(flags)  CPUEXT_SUFFIX(flags, _INLINE, SSE3)
+#define INLINE_SSE3_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _INLINE, SSE3)
+#define INLINE_SSE3_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _INLINE, SSE3)
 #define INLINE_SSSE3(flags) CPUEXT_SUFFIX(flags, _INLINE, SSSE3)
 #define INLINE_SSE4(flags)  CPUEXT_SUFFIX(flags, _INLINE, SSE4)
 #define INLINE_SSE42(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE42)
 #define INLINE_AVX(flags)   CPUEXT_SUFFIX(flags, _INLINE, AVX)
+#define INLINE_AVX_FAST(flags)  CPUEXT_SUFFIX_FAST(flags, _INLINE, AVX)
+#define INLINE_AVX_SLOW(flags)  CPUEXT_SUFFIX_SLOW(flags, _INLINE, AVX)
 #define INLINE_XOP(flags)   CPUEXT_SUFFIX(flags, _INLINE, XOP)
 #define INLINE_FMA3(flags)  CPUEXT_SUFFIX(flags, _INLINE, FMA3)
 #define INLINE_FMA4(f

[libav-devel] [PATCH v2 1/3] x86/cpu: add AV_CPU_FLAG_AVXSLOW flag

2015-05-26 Thread James Almer
Signed-off-by: James Almer 
---
No changes from last revision.

 doc/APIchanges  |  3 +++
 libavutil/cpu.c |  3 +++
 libavutil/cpu.h |  1 +
 libavutil/version.h |  4 ++--
 libavutil/x86/cpu.c | 17 ++---
 5 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5d39ec6..2c443b0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxx - lavu 54.14.0 - cpu.h
+  Add AV_CPU_FLAG_AVXSLOW.
+
 2015-xx-xx - xxx - lavc 56.23.0
   Add av_vda_default_init2.
 
diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 4e8ef61..e24b9dd 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -86,6 +86,7 @@ int av_parse_cpu_flags(const char *s)
 #define CPUFLAG_SSE4 (AV_CPU_FLAG_SSE4 | CPUFLAG_SSSE3)
 #define CPUFLAG_SSE42(AV_CPU_FLAG_SSE42| CPUFLAG_SSE4)
 #define CPUFLAG_AVX  (AV_CPU_FLAG_AVX  | CPUFLAG_SSE42)
+#define CPUFLAG_AVXSLOW  (AV_CPU_FLAG_AVXSLOW  | CPUFLAG_AVX)
 #define CPUFLAG_XOP  (AV_CPU_FLAG_XOP  | CPUFLAG_AVX)
 #define CPUFLAG_FMA3 (AV_CPU_FLAG_FMA3 | CPUFLAG_AVX)
 #define CPUFLAG_FMA4 (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX)
@@ -108,6 +109,7 @@ int av_parse_cpu_flags(const char *s)
 { "sse4.1"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE4
 },.unit = "flags" },
 { "sse4.2"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE42   
 },.unit = "flags" },
 { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX 
 },.unit = "flags" },
+{ "avxslow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVXSLOW 
 },.unit = "flags" },
 { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_XOP 
 },.unit = "flags" },
 { "fma3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA3
 },.unit = "flags" },
 { "fma4", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA4
 },.unit = "flags" },
@@ -219,6 +221,7 @@ static const struct {
 { AV_CPU_FLAG_SSE4,  "sse4.1" },
 { AV_CPU_FLAG_SSE42, "sse4.2" },
 { AV_CPU_FLAG_AVX,   "avx"},
+{ AV_CPU_FLAG_AVXSLOW,   "avxslow"},
 { AV_CPU_FLAG_XOP,   "xop"},
 { AV_CPU_FLAG_FMA3,  "fma3"   },
 { AV_CPU_FLAG_FMA4,  "fma4"   },
diff --git a/libavutil/cpu.h b/libavutil/cpu.h
index 7ce..c9469b3 100644
--- a/libavutil/cpu.h
+++ b/libavutil/cpu.h
@@ -45,6 +45,7 @@
 #define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
 #define AV_CPU_FLAG_SSE420x0200 ///< Nehalem SSE4.2 functions
 #define AV_CPU_FLAG_AVX  0x4000 ///< AVX functions: requires OS 
support even if YMM registers aren't used
+#define AV_CPU_FLAG_AVXSLOW   0x800 ///< AVX supported, but slow when 
using YMM registers (e.g. Bulldozer)
 #define AV_CPU_FLAG_XOP  0x0400 ///< Bulldozer XOP functions
 #define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions
 #define AV_CPU_FLAG_CMOV 0x1000 ///< i686 cmov
diff --git a/libavutil/version.h b/libavutil/version.h
index 13bb6f0..c3342cd 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,8 +54,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 54
-#define LIBAVUTIL_VERSION_MINOR 13
-#define LIBAVUTIL_VERSION_MICRO  1
+#define LIBAVUTIL_VERSION_MINOR 14
+#define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index 8be6d94..098ccf7 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -167,6 +167,7 @@ int ff_get_cpu_flags_x86(void)
 if (ext_caps & (1 << 22))
 rval |= AV_CPU_FLAG_MMXEXT;
 
+if (!strncmp(vendor.c, "AuthenticAMD", 12)) {
 /* Allow for selectively disabling SSE2 functions on AMD processors
with SSE2 support but not SSE4a. This includes Athlon64, some
Opteron, and some Sempron processors. MMX, SSE, or 3DNow! are faster
@@ -174,9 +175,19 @@ int ff_get_cpu_flags_x86(void)
AV_CPU_FLAG_SSE2 and AV_CPU_FLAG_SSE2SLOW are both set in this case
so that SSE2 is used unless explicitly disabled by checking
AV_CPU_FLAG_SSE2SLOW. */
-if (!strncmp(vendor.c, "AuthenticAMD", 12) &&
-rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x0040)) {
-rval |= AV_CPU_FLAG_SSE2SLOW;
+if (rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x0040))
+rval |= AV_CPU_FLAG_

[libav-devel] [PATCH v2 3/3] x86: check for AV_CPU_FLAG_AVXSLOW where useful

2015-05-26 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/x86/dcadsp_init.c   | 4 ++--
 libavcodec/x86/dct_init.c  | 2 +-
 libavcodec/x86/fft_init.c  | 2 +-
 libavfilter/x86/af_volume_init.c   | 2 +-
 libavresample/x86/audio_convert_init.c | 4 +++-
 libavresample/x86/audio_mix_init.c | 4 +++-
 libavresample/x86/dither_init.c| 4 ++--
 libavutil/x86/float_dsp_init.c | 2 +-
 libavutil/x86/lls_init.c   | 2 +-
 9 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c
index 9acb818..7c2bec1 100644
--- a/libavcodec/x86/dcadsp_init.c
+++ b/libavcodec/x86/dcadsp_init.c
@@ -98,10 +98,10 @@ av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
 if (EXTERNAL_SSE2(cpu_flags)) {
 s->synth_filter_float = synth_filter_sse2;
 }
-if (EXTERNAL_AVX(cpu_flags)) {
+if (EXTERNAL_AVX_FAST(cpu_flags)) {
 s->synth_filter_float = synth_filter_avx;
 }
-if (EXTERNAL_FMA3(cpu_flags)) {
+if (EXTERNAL_FMA3(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_AVXSLOW)) {
 s->synth_filter_float = synth_filter_fma3;
 }
 #endif /* HAVE_YASM */
diff --git a/libavcodec/x86/dct_init.c b/libavcodec/x86/dct_init.c
index 7bda5e8..ca9fbc7 100644
--- a/libavcodec/x86/dct_init.c
+++ b/libavcodec/x86/dct_init.c
@@ -34,6 +34,6 @@ av_cold void ff_dct_init_x86(DCTContext *s)
 s->dct32 = ff_dct32_float_sse;
 if (EXTERNAL_SSE2(cpu_flags))
 s->dct32 = ff_dct32_float_sse2;
-if (EXTERNAL_AVX(cpu_flags))
+if (EXTERNAL_AVX_FAST(cpu_flags))
 s->dct32 = ff_dct32_float_avx;
 }
diff --git a/libavcodec/x86/fft_init.c b/libavcodec/x86/fft_init.c
index 7ca72c5..5c0273d 100644
--- a/libavcodec/x86/fft_init.c
+++ b/libavcodec/x86/fft_init.c
@@ -48,7 +48,7 @@ av_cold void ff_fft_init_x86(FFTContext *s)
 s->fft_calc= ff_fft_calc_sse;
 s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
 }
-if (EXTERNAL_AVX(cpu_flags) && s->nbits >= 5) {
+if (EXTERNAL_AVX_FAST(cpu_flags) && s->nbits >= 5) {
 /* AVX for SB */
 s->imdct_half  = ff_imdct_half_avx;
 s->fft_calc= ff_fft_calc_avx;
diff --git a/libavfilter/x86/af_volume_init.c b/libavfilter/x86/af_volume_init.c
index c59e0ed..26605fb 100644
--- a/libavfilter/x86/af_volume_init.c
+++ b/libavfilter/x86/af_volume_init.c
@@ -52,7 +52,7 @@ av_cold void ff_volume_init_x86(VolumeContext *vol)
 vol->scale_samples = ff_scale_samples_s32_ssse3_atom;
 vol->samples_align = 4;
 }
-if (EXTERNAL_AVX(cpu_flags)) {
+if (EXTERNAL_AVX_FAST(cpu_flags)) {
 vol->scale_samples = ff_scale_samples_s32_avx;
 vol->samples_align = 8;
 }
diff --git a/libavresample/x86/audio_convert_init.c 
b/libavresample/x86/audio_convert_init.c
index d85ca84..ae6c319 100644
--- a/libavresample/x86/audio_convert_init.c
+++ b/libavresample/x86/audio_convert_init.c
@@ -226,11 +226,13 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
   6, 16, 4, "SSE4", 
ff_conv_fltp_to_flt_6ch_sse4);
 }
-if (EXTERNAL_AVX(cpu_flags)) {
+if (EXTERNAL_AVX_FAST(cpu_flags)) {
 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
   0, 32, 16, "AVX", ff_conv_s32_to_flt_avx);
 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
   0, 32, 32, "AVX", ff_conv_flt_to_s32_avx);
+}
+if (EXTERNAL_AVX(cpu_flags)) {
 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
   2, 16, 16, "AVX", 
ff_conv_s16p_to_s16_2ch_avx);
 ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
diff --git a/libavresample/x86/audio_mix_init.c 
b/libavresample/x86/audio_mix_init.c
index 7fc530e..e14a540 100644
--- a/libavresample/x86/audio_mix_init.c
+++ b/libavresample/x86/audio_mix_init.c
@@ -195,11 +195,13 @@ av_cold void ff_audio_mix_init_x86(AudioMix *am)
 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
   1, 2, 16, 8, "SSE4", 
ff_mix_1_to_2_s16p_flt_sse4);
 }
-if (EXTERNAL_AVX(cpu_flags)) {
+if (EXTERNAL_AVX_FAST(cpu_flags)) {
 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
   2, 1, 32, 16, "AVX", ff_mix_2_to_1_fltp_flt_avx);
 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
   1, 2, 32, 8, "AVX", ff_mix_1_to_2_fltp_flt_avx);
+}
+if (EXTERNAL_AVX(cpu_flags)) {
 ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_M

Re: [libav-devel] [PATCH] libvpx: Support all pixel formats available in encoding and decoding

2015-05-27 Thread James Almer
On 27/05/15 1:15 PM, Vittorio Giovara wrote:
> Bump the minimum libvpx version to 1.4.0 so that all pixel
> formats are present. Add new VP9 profiles.
> 
> Signed-off-by: Vittorio Giovara 
> ---
> Modified as requested.
> Vittorio
> 
>  configure  | 23 +++--
>  libavcodec/avcodec.h   |  4 
>  libavcodec/libvpx.c| 56 
> ++
>  libavcodec/libvpx.h|  3 ++-
>  libavcodec/libvpxdec.c |  7 ++-
>  libavcodec/libvpxenc.c | 32 +
>  libavcodec/version.h   |  2 +-
>  7 files changed, 97 insertions(+), 30 deletions(-)
> 
> diff --git a/configure b/configure
> index 863e33b..e26fc54 100755
> --- a/configure
> +++ b/configure
> @@ -4274,12 +4274,23 @@ enabled libvo_aacenc  && require libvo_aacenc 
> vo-aacenc/voAAC.h voGetAACEncA
>  enabled libvo_amrwbenc&& require libvo_amrwbenc vo-amrwbenc/enc_if.h 
> E_IF_init -lvo-amrwbenc
>  enabled libvorbis && require libvorbis vorbis/vorbisenc.h 
> vorbis_info_init -lvorbisenc -lvorbis -logg
>  enabled libvpx&& {
> -enabled libvpx_vp8_decoder && { check_lib2 "vpx/vpx_decoder.h 
> vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
> -die "ERROR: libvpx decoder version must 
> be >=0.9.1"; }
> -enabled libvpx_vp8_encoder && { check_lib2 "vpx/vpx_encoder.h 
> vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_CQ" -lvpx ||
> -die "ERROR: libvpx encoder version must 
> be >=0.9.6"; }
> -enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h 
> vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; }
> -enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h 
> vpx/vp8cx.h" "vpx_codec_vp9_cx" -lvpx || disable libvpx_vp9_encoder; } }
> +enabled libvpx_vp8_decoder && {
> +require "vpx >= 1.4.0" vpx/vpx_decoder.h vpx_codec_dec_init_ver 
> -lvpx ||
> +die "ERROR: libvpx encoder version must be >=1.4.0";

As Luca said, require_pkg_config. If you use require, "vpx >= 1.4.0" is just 
used as a name
to report a failure. It does not check for that version.
Also, all require functions terminate configure with an error if the check 
fails, so these
custom die calls are dead code. If you want to use your own custom error, use 
use_pkg_config
instead.

> +}
> +enabled libvpx_vp8_encoder && {
> +require "vpx >= 1.4.0" vpx/vpx_encoder.h vpx_codec_enc_init_ver 
> -lvpx ||
> +die "ERROR: libvpx encoder version must be >=1.4.0";
> +}
> +enabled libvpx_vp9_decoder && {
> +require "vpx >= 1.4.0" vpx/vpx_decoder.h vpx_codec_dec_init_ver 
> -lvpx ||
> +disable libvpx_vp9_decoder;
> +}
> +enabled libvpx_vp9_encoder && {
> +require "vpx >= 1.4.0" vpx/vpx_encoder.h vpx_codec_enc_init_ver 
> -lvpx ||
> +disable libvpx_vp9_encoder;
> +}
> +}
>  enabled libwavpack&& require libwavpack wavpack/wavpack.h 
> WavpackOpenFileOutput  -lwavpack
>  enabled libwebp   && require_pkg_config libwebp webp/encode.h 
> WebPGetEncoderVersion
>  enabled libx264   && require_pkg_config x264 "stdint.h x264.h" 
> x264_encoder_encode &&
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 3440126..16af20c 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2702,6 +2702,10 @@ typedef struct AVCodecContext {
>  #define FF_PROFILE_JPEG2000_DCINEMA_2K  3
>  #define FF_PROFILE_JPEG2000_DCINEMA_4K  4
>  
> +#define FF_PROFILE_VP9_00
> +#define FF_PROFILE_VP9_11
> +#define FF_PROFILE_VP9_22
> +#define FF_PROFILE_VP9_33

Even if it's a simple change, credit where credit is due would be nice.

>  
>  #define FF_PROFILE_HEVC_MAIN1
>  #define FF_PROFILE_HEVC_MAIN_10 2
> diff --git a/libavcodec/libvpx.c b/libavcodec/libvpx.c
> index 20f4484..603ed13 100644
> --- a/libavcodec/libvpx.c
> +++ b/libavcodec/libvpx.c
> @@ -22,14 +22,54 @@
>  
>  #include "libvpx.h"
>  
> -int ff_vp9_check_experimental(AVCodecContext *avctx)
> +enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img)
>  {
> -if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL &&
> -(vpx_codec_version_major() < 1 ||
> - (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))) 
> {
> -av_log(avctx, AV_LOG_ERROR,
> -   "Non-experimental support of VP9 requires libvpx >= 1.3.0\n");
> -return AVERROR_EXPERIMENTAL;
> +switch (img) {
> +case VPX_IMG_FMT_RGB24: return AV_PIX_FMT_RGB24;
> +case VPX_IMG_FMT_RGB565:return AV_PIX_FMT_RGB565BE;
> +case VPX_IMG_FMT_RGB555:return AV_PIX_FMT_RGB555BE;
> +case VPX_IMG_FMT_UYVY:  return AV_PIX_FMT_UYVY422;
> +case VPX_IMG_FMT_YUY2:  return AV_PIX_FMT_YU

Re: [libav-devel] [PATCH] libvpx: Support all pixel formats available in encoding and decoding

2015-05-27 Thread James Almer
On 27/05/15 3:24 PM, James Almer wrote:
> On 27/05/15 1:15 PM, Vittorio Giovara wrote:
>> Bump the minimum libvpx version to 1.4.0 so that all pixel
>> formats are present. Add new VP9 profiles.
>>
>> Signed-off-by: Vittorio Giovara 
>> ---
>> Modified as requested.
>> Vittorio
>>
>>  configure  | 23 +++--
>>  libavcodec/avcodec.h   |  4 
>>  libavcodec/libvpx.c| 56 
>> ++
>>  libavcodec/libvpx.h|  3 ++-
>>  libavcodec/libvpxdec.c |  7 ++-
>>  libavcodec/libvpxenc.c | 32 +
>>  libavcodec/version.h   |  2 +-
>>  7 files changed, 97 insertions(+), 30 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 863e33b..e26fc54 100755
>> --- a/configure
>> +++ b/configure
>> @@ -4274,12 +4274,23 @@ enabled libvo_aacenc  && require libvo_aacenc 
>> vo-aacenc/voAAC.h voGetAACEncA
>>  enabled libvo_amrwbenc&& require libvo_amrwbenc vo-amrwbenc/enc_if.h 
>> E_IF_init -lvo-amrwbenc
>>  enabled libvorbis && require libvorbis vorbis/vorbisenc.h 
>> vorbis_info_init -lvorbisenc -lvorbis -logg
>>  enabled libvpx&& {
>> -enabled libvpx_vp8_decoder && { check_lib2 "vpx/vpx_decoder.h 
>> vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
>> -die "ERROR: libvpx decoder version must 
>> be >=0.9.1"; }
>> -enabled libvpx_vp8_encoder && { check_lib2 "vpx/vpx_encoder.h 
>> vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_CQ" -lvpx ||
>> -die "ERROR: libvpx encoder version must 
>> be >=0.9.6"; }
>> -enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h 
>> vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; }
>> -enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h 
>> vpx/vp8cx.h" "vpx_codec_vp9_cx" -lvpx || disable libvpx_vp9_encoder; } }
>> +enabled libvpx_vp8_decoder && {
>> +require "vpx >= 1.4.0" vpx/vpx_decoder.h vpx_codec_dec_init_ver 
>> -lvpx ||
>> +die "ERROR: libvpx encoder version must be >=1.4.0";
> 
> As Luca said, require_pkg_config. If you use require, "vpx >= 1.4.0" is just 
> used as a name
> to report a failure. It does not check for that version.
> Also, all require functions terminate configure with an error if the check 
> fails, so these
> custom die calls are dead code. If you want to use your own custom error, use 
> use_pkg_config
> instead.

Also, since 1.4.0 is the minimum required version now, you can simplify all 
this into

enabled libvpx&& require_pkg_config "vpx >= 1.4.0" vpx/vpx_codec.h 
vpx_codec_version && {
enabled_any libvpx_vp8_decoder libvpx_vp9_decoder && { check_pkg_config vpx 
"vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver ||
   disable 
libvpx_vp8_decoder libvpx_vp9_decoder; }
enabled_any libvpx_vp8_encoder libvpx_vp9_encoder && { check_pkg_config vpx 
"vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_enc_init_ver ||
   disable 
libvpx_vp8_encoder libvpx_vp9_encoder; } }

Which will check for libvpx 1.4.0 first, then for the decoder and encoding 
headers depending
on enabled components.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] libvpx: Support all pixel formats available in encoding and decoding

2015-05-27 Thread James Almer
On 27/05/15 5:04 PM, Martin Storsjö wrote:
> On Wed, 27 May 2015, Vittorio Giovara wrote:
> 
>> Bump the minimum libvpx version to 1.4.0 so that all pixel
>> formats are present. Add new VP9 profiles.
> 
> Sorry to be a bit late to the party, but how bad would it be to keep compat 
> with older versions? Was there any other argument for dropping older versions 
> than "because we can", and "x265 did it"? Allowing people to build with the 
> earlier versions with the reduced (old/existing) featureset is something that 
> I'd appreciate. I think x265 might have been a bit special case since that 
> involved a bigger API change than this, to the point that keeping compat 
> would be uglier?
> 
> Or would it require some ugly static initialization of the pixfmt list? In 
> that case I guess it can be argued that it's simpler just to bump the 
> requirement.

Yes, that plus a considerable amount of ifdeffery in the code.
It will be ugly, but i also think it's worth keeping compatibility with at 
least 1.3.0

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

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


Re: [libav-devel] [PATCH] libvpx: Support all pixel formats available in encoding and decoding

2015-05-28 Thread James Almer
On 28/05/15 9:11 AM, Vittorio Giovara wrote:
> On Wed, May 27, 2015 at 7:24 PM, James Almer  wrote:
>> As Luca said, require_pkg_config. If you use require, "vpx >= 1.4.0" is just 
>> used as a name
>> to report a failure. It does not check for that version.
> 
> I swear I couldn't get it working with just require_pkg_config, thanks
> for showing how to do that in the next email.

For the record, the example i gave in the other email is only valid if the 
libvpx
requirement is bumped to 1.3.0 or newer. Otherwise, individual tests for each 
component
(like it's done right now) will still be needed.

> 
>>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>>> index 3440126..16af20c 100644
>>> --- a/libavcodec/avcodec.h
>>> +++ b/libavcodec/avcodec.h
>>> @@ -2702,6 +2702,10 @@ typedef struct AVCodecContext {
>>>  #define FF_PROFILE_JPEG2000_DCINEMA_2K  3
>>>  #define FF_PROFILE_JPEG2000_DCINEMA_4K  4
>>>
>>> +#define FF_PROFILE_VP9_00
>>> +#define FF_PROFILE_VP9_11
>>> +#define FF_PROFILE_VP9_22
>>> +#define FF_PROFILE_VP9_33
>>
>> Even if it's a simple change, credit where credit is due would be nice.
> 
> credit to whom and for what?

https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=079b7f6eacc09bc2813fc1ddc230ab05022b69c2
https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=01e59d48ed1a41b88107ed1d4d56ae0cbcd1a60e
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH v2 1/3] x86/cpu: add AV_CPU_FLAG_AVXSLOW flag

2015-05-28 Thread James Almer
On 26/05/15 2:29 PM, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> No changes from last revision.
> 
>  doc/APIchanges  |  3 +++
>  libavutil/cpu.c |  3 +++
>  libavutil/cpu.h |  1 +
>  libavutil/version.h |  4 ++--
>  libavutil/x86/cpu.c | 17 ++---
>  5 files changed, 23 insertions(+), 5 deletions(-)

Ping

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


[libav-devel] [PATCH] configure: don't enable tls protocols if network is disabled

2015-06-01 Thread James Almer
This was a regression introduced with d8ffb2055f0e0fcb5d025bab72eb19c2a886c125.

Signed-off-by: James Almer 
---
 configure | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure b/configure
index cdc5a8d..a29cd38 100755
--- a/configure
+++ b/configure
@@ -2216,6 +2216,8 @@ srtp_protocol_select="rtp_protocol"
 tcp_protocol_select="network"
 tls_gnutls_protocol_deps="gnutls"
 tls_openssl_protocol_deps="openssl !tls_gnutls_protocol"
+tls_gnutls_protocol_select="tcp_protocol"
+tls_openssl_protocol_select="tcp_protocol"
 tls_protocol_deps_any="tls_gnutls_protocol tls_openssl_protocol"
 tls_protocol_select="tcp_protocol"
 udp_protocol_select="network"
-- 
2.4.1

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


Re: [libav-devel] [PATCH 2/4] configure: Require LPDIRECT3DSURFACE9 for dxva2

2015-06-01 Thread James Almer
On 01/06/15 7:54 AM, Martin Storsjö wrote:
> This fixes dxva2 detection (i.e. correctly realizes that it isn't
> available) for WinRT, where dxva2api.h does exist, but these definitions
> are omitted (when targeting the API subsets).
> 
> Ideally we should rather check for e.g. DXVA2_ConfigPictureDecode,
> but configure might fail to find that definition due to _WIN32_WINNT
> not being set to the right value during configure. (libavcodec/dxva2.h
> manually overrides the _WIN32_WINNT define.)

Something like

enabled dxva2api_h && check_type "dxva2api.h" DXVA2_ConfigPictureDecode 
-D_WIN32_WINNT=0x0600 || disable dxva2api_h

Should work then. You can put it above the d3d11_cobj check (Which IMO should 
be removed alongside the d3d11va_lib
check until actual d3d11 support is added to avconv, for that matter).

I see this patch was committed already, so up to you if you prefer the above 
solution or not.

> 
> This allows removing hardcoded --disable-dxva2 from such build
> configurations.
> ---
>  configure | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index cdc5a8d..4c4783c 100755
> --- a/configure
> +++ b/configure
> @@ -1985,7 +1985,7 @@ zmbv_encoder_deps="zlib"
>  
>  # hardware accelerators
>  d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder"
> -dxva2_deps="dxva2api_h"
> +dxva2_deps="dxva2api_h LPDIRECT3DSURFACE9"
>  vaapi_deps="va_va_h"
>  vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
>  vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration 
> -framework QuartzCore"
> @@ -4235,6 +4235,7 @@ check_struct "sys/time.h sys/resource.h" "struct 
> rusage" ru_maxrss
>  
>  check_type "windows.h dxva.h" "DXVA_PicParams_HEVC"
>  check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
> +check_type d3d9.h LPDIRECT3DSURFACE9
>  
>  if ! disabled w32threads && ! enabled pthreads; then
>  check_func_headers "windows.h process.h" _beginthreadex &&
> 

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


Re: [libav-devel] [PATCH] Introduce a TextureDSP module

2015-06-01 Thread James Almer
On 31/05/15 8:41 AM, Vittorio Giovara wrote:
> +/* Solve */
> +max16  = av_clip((at1_r * yy - at2_r * xy) * frb + 0.5f, 0, 31) << 
> 11;
> +max16 |= av_clip((at1_g * yy - at2_g * xy) * fg  + 0.5f, 0, 63) << 5;
> +max16 |= av_clip((at1_b * yy - at2_b * xy) * frb + 0.5f, 0, 31) << 0;
> +
> +min16  = av_clip((at2_r * xx - at1_r * xy) * frb + 0.5f, 0, 31) << 
> 11;
> +min16 |= av_clip((at2_g * xx - at1_g * xy) * fg  + 0.5f, 0, 63) << 5;
> +min16 |= av_clip((at2_b * xx - at1_b * xy) * frb + 0.5f, 0, 31) << 0;

av_clip_uintp2().

[...]

> +/* Alpha compression function */
> +static void compress_alpha(uint8_t *dst, ptrdiff_t stride, const uint8_t 
> *block)
> +{
> +int i, j;
> +int dist, bias, dist4, dist2, bits, mask;
> +int mn, mx;
> +
> +/* Find min/max color */
> +mn = mx = block[3];
> +for (j = 0; j < 4; j++) {
> +for (i = 0; i < 4; i++) {
> +int val = block[3 + i * 4 + j * stride];
> +if (val < mn)
> +mn = val;
> +else if (val > mx)
> +mx = val;
> +}
> +}
> +
> +AV_WL32(dst, 0);
> +AV_WL32(dst + 4, 0);

AV_WL64 or AV_ZERO64?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/4] configure: Require LPDIRECT3DSURFACE9 for dxva2

2015-06-02 Thread James Almer
On 02/06/15 4:27 AM, Martin Storsjö wrote:
> On Mon, 1 Jun 2015, James Almer wrote:
> 
>> On 01/06/15 7:54 AM, Martin Storsjö wrote:
>>> This fixes dxva2 detection (i.e. correctly realizes that it isn't
>>> available) for WinRT, where dxva2api.h does exist, but these definitions
>>> are omitted (when targeting the API subsets).
>>>
>>> Ideally we should rather check for e.g. DXVA2_ConfigPictureDecode,
>>> but configure might fail to find that definition due to _WIN32_WINNT
>>> not being set to the right value during configure. (libavcodec/dxva2.h
>>> manually overrides the _WIN32_WINNT define.)
>>
>> Something like
>>
>> enabled dxva2api_h && check_type "dxva2api.h" DXVA2_ConfigPictureDecode 
>> -D_WIN32_WINNT=0x0600 || disable dxva2api_h
> 
> Thanks - I somehow missed that check_type can take other parameters to use 
> while compiling.
> 
>> Should work then. You can put it above the d3d11_cobj check (Which IMO 
>> should be removed alongside the d3d11va_lib
>> check until actual d3d11 support is added to avconv, for that matter).
>>
>> I see this patch was committed already, so up to you if you prefer the above 
>> solution or not.
> 
> This does sound better indeed (and I agree about removing the extra d3d11 
> things for avconv support which isn't there yet).
> 
> Although I think it's a bit more straightforward to just add this as an 
> unconditional check_type call without intermixing it with enabling/disabling 
> dxva2api_h though.

Yeah, i realized after sending that email that you can probably just replace 
the check_type for LPDIRECT3DSURFACE9
with this one, and of course also the relevant dependency on dxva2_deps.

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

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


[libav-devel] [PATCH] configure: don't enable tls protocols if network is disabled

2015-06-02 Thread James Almer
This was a regression introduced with d8ffb2055f0e0fcb5d025bab72eb19c2a886c125.

Signed-off-by: James Almer 
---
 configure | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 30d6f18..2458adb 100755
--- a/configure
+++ b/configure
@@ -2215,9 +2215,10 @@ sctp_protocol_select="network"
 srtp_protocol_select="rtp_protocol"
 tcp_protocol_select="network"
 tls_gnutls_protocol_deps="gnutls"
+tls_gnutls_protocol_select="tcp_protocol"
 tls_openssl_protocol_deps="openssl !tls_gnutls_protocol"
+tls_openssl_protocol_select="tcp_protocol"
 tls_protocol_deps_any="tls_gnutls_protocol tls_openssl_protocol"
-tls_protocol_select="tcp_protocol"
 udp_protocol_select="network"
 unix_protocol_deps="sys_un_h"
 unix_protocol_select="network"
-- 
2.4.2

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


Re: [libav-devel] [PATCH] libvpx: Support all pixel formats available in encoding and decoding

2015-06-03 Thread James Almer
On 03/06/15 11:29 AM, Luca Barbato wrote:
> On 31/05/15 17:01, Luca Barbato wrote:
>> On 27/05/15 22:25, James Almer wrote:
>>> Yes, that plus a considerable amount of ifdeffery in the code. It
>>> will be ugly, but i also think it's worth keeping compatibility with
>>> at least 1.3.0
>>>
>>
>> 1.3.0 explodes on 422p that at least in theory should support. (I'm
>> testing all the possible encodings right now).
>>
> 
> 1.3.0 seems that had been released when not ready, do we really want to
> support it?
> 
> lu

It works with 420p content (vp8 and vp9). Support for 422p, 440p, 444p and high 
bit-depth
was officially added with 1.4.0.
1.3.0 should reject the latter stuff, but for some reason it doesn't and it 
encodes garbage.

With some ifdeffery and static init magic both the decoder and encoder can be 
limited to
420p for vpx 1.3.0. But then again, I guess vpx 1.3.0 is old enough by now that 
support for
it can be safely dropped.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] Introduce a TextureDSP module

2015-06-05 Thread James Almer
On 02/06/15 8:09 AM, Vittorio Giovara wrote:
> +/* Alpha compression function */
> +static void compress_alpha(uint8_t *dst, ptrdiff_t stride, const uint8_t 
> *block)
> +{
> +int i, j;
> +int dist, bias, dist4, dist2, bits, mask;
> +int mn, mx;
> +
> +/* Find min/max color */
> +mn = mx = block[3];
> +for (j = 0; j < 4; j++) {
> +for (i = 0; i < 4; i++) {
> +int val = block[3 + i * 4 + j * stride];
> +if (val < mn)
> +mn = val;
> +else if (val > mx)
> +mx = val;
> +}
> +}
> +
> +AV_ZERO64(dst);

Documentation for AV_ZERO* says "Parameters for AV_COPY*, AV_SWAP*,
AV_ZERO* must be naturally aligned. They may be implemented using MMX,
so emms_c() must be called before using any float code afterwards".

Make sure fate passes on x86_32 (targeting anything above i686, which
is when AV_ZERO64 is implemented with MMX movq) as you're using float
code all around.
If it doesn't, then maybe you could bench to see if using AV_WN64 is
faster than AV_ZERO64 + emms_c().
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] mpjpegdec: don't try to alloc an AVIOContext when probe is guaranteed to fail

2015-06-08 Thread James Almer
The first check is done without the AVIOContext, so alloc it only if said check 
succeeds

Signed-off-by: James Almer 
---
 libavformat/mpjpegdec.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c
index 72891e7..e2a2ece 100644
--- a/libavformat/mpjpegdec.c
+++ b/libavformat/mpjpegdec.c
@@ -83,13 +83,13 @@ static int mpjpeg_read_probe(AVProbeData *p)
 char line[128] = { 0 };
 int ret = 0;
 
+if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-')
+return 0;
+
 pb = avio_alloc_context(p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL);
 if (!pb)
 return AVERROR(ENOMEM);
 
-if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-')
-goto end;
-
 while (!pb->eof_reached) {
 ret = get_line(pb, line, sizeof(line));
 if (ret < 0)
@@ -101,7 +101,7 @@ static int mpjpeg_read_probe(AVProbeData *p)
 break;
 }
 }
-end:
+
 av_free(pb);
 
 return ret;
-- 
2.4.2

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


Re: [libav-devel] [PATCH 1/2] libvpx: Support all pixel formats available in encoding and decoding

2015-06-11 Thread James Almer
On 11/06/15 11:56 AM, Luca Barbato wrote:
> @@ -321,8 +321,12 @@ static av_cold int vpx_init(AVCodecContext *avctx,
>  /* 0-3: For non-zero values the encoder increasingly optimizes for 
> reduced
> complexity playback on low powered devices at the expense of encode
> quality. */
> -   if (avctx->profile != FF_PROFILE_UNKNOWN)
> -   enccfg.g_profile = avctx->profile;
> +if (avctx->profile != FF_PROFILE_UNKNOWN)
> +enccfg.g_profile = avctx->profile;
> +else if (avctx->pix_fmt == AV_PIX_FMT_YUV440P)

As i said before, profile 0 is 8bit yuv420p.

> +avctx->profile = enccfg.g_profile = FF_PROFILE_VP9_0;
> +else
> +avctx->profile = enccfg.g_profile = FF_PROFILE_VP9_1;
> 
>  enccfg.g_error_resilient = ctx->error_resilient;
> 


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


Re: [libav-devel] [PATCH 2/2] vpx: Support version 1.3.0

2015-06-11 Thread James Almer
On 11/06/15 11:56 AM, Luca Barbato wrote:
> ---
> 
> I tied the supported formats to the ABI version.
> 
>  configure  | 12 ++--
>  libavcodec/libvpx.c|  8 ++--
>  libavcodec/libvpxenc.c |  6 +-
>  3 files changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/configure b/configure
> index a416dc2..8cb53d2 100755
> --- a/configure
> +++ b/configure
> @@ -4312,19 +4312,19 @@ enabled libvo_amrwbenc&& require libvo_amrwbenc 
> vo-amrwbenc/enc_if.h E_IF_in
>  enabled libvorbis && require libvorbis vorbis/vorbisenc.h 
> vorbis_info_init -lvorbisenc -lvorbis -logg
>  enabled libvpx&& {
>  enabled libvpx_vp8_decoder && {
> -require "vpx >= 1.4.0" vpx/vpx_decoder.h vpx_codec_dec_init_ver 
> -lvpx ||
> -die "ERROR: libvpx encoder version must be >=1.4.0";
> +require_pkg_config "vpx >= 1.3.0" vpx/vpx_decoder.h 
> vpx_codec_dec_init_ver ||
> +die "ERROR: libvpx encoder version must be >= 1.3.0";
>  }
>  enabled libvpx_vp8_encoder && {
> -require "vpx >= 1.4.0" vpx/vpx_encoder.h vpx_codec_enc_init_ver 
> -lvpx ||
> -die "ERROR: libvpx encoder version must be >=1.4.0";
> +require_pkg_config "vpx >= 1.3.0" vpx/vpx_encoder.h 
> vpx_codec_enc_init_ver ||
> +die "ERROR: libvpx encoder version must be >= 1.3.0";
>  }
>  enabled libvpx_vp9_decoder && {
> -require "vpx >= 1.4.0" vpx/vpx_decoder.h vpx_codec_dec_init_ver 
> -lvpx ||
> +require_pkg_config "vpx >= 1.3.0" vpx/vpx_decoder.h 
> vpx_codec_dec_init_ver ||
>  disable libvpx_vp9_decoder;
>  }
>  enabled libvpx_vp9_encoder && {
> -require "vpx >= 1.4.0" vpx/vpx_encoder.h vpx_codec_enc_init_ver 
> -lvpx ||
> +require_pkg_config "vpx >= 1.3.0" vpx/vpx_encoder.h 
> vpx_codec_enc_init_ver ||
>  disable libvpx_vp9_encoder;

Using require_pkg_config() makes configure abort if the check fails, so the 
disable() calls are dead code.
That's why use_pkg_config() and check_pkg_config exist.
Also, checking for the decoding/encoding header and the init function is 
apparently not enough. You need
to check for the decoding/encoding interfaces vpx_codec_vp[89]_[cd]x because 
libvpx can be built without
one or more of the four components.

enabled libvpx&& require_pkg_config "vpx >= 1.3.0" vpx/vpx_codec.h 
vpx_codec_version && {
enabled libvpx_vp8_decoder && { check_pkg_config vpx "vpx/vpx_decoder.h 
vpx/vp8dx.h" vpx_codec_vp8_dx ||
disable libvpx_vp8_decoder; }
enabled libvpx_vp8_encoder && { check_pkg_config vpx "vpx/vpx_encoder.h 
vpx/vp8cx.h" vpx_codec_vp8_cx ||
disable libvpx_vp8_encoder; }
enabled libvpx_vp9_decoder && { check_pkg_config vpx "vpx/vpx_decoder.h 
vpx/vp8dx.h" vpx_codec_vp9_dx ||
disable libvpx_vp9_decoder; }
enabled libvpx_vp9_encoder && { check_pkg_config vpx "vpx/vpx_encoder.h 
vpx/vp8cx.h" vpx_codec_vp9_cx ||
disable libvpx_vp9_encoder; } }

Updated from the version i posted in a previous email (Which was wrong as it 
only checked for the header
and init function).
This will first check for a recent libvpx, then for each component.

>  }
>  }
> diff --git a/libavcodec/libvpx.c b/libavcodec/libvpx.c
> index 603ed13..230bc49 100644
> --- a/libavcodec/libvpx.c
> +++ b/libavcodec/libvpx.c
> @@ -39,11 +39,13 @@ enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t 
> img)
>  case VPX_IMG_FMT_I420:  return AV_PIX_FMT_YUV420P;
>  case VPX_IMG_FMT_I422:  return AV_PIX_FMT_YUV422P;
>  case VPX_IMG_FMT_I444:  return AV_PIX_FMT_YUV444P;
> -case VPX_IMG_FMT_I440:  return AV_PIX_FMT_YUV440P;
>  case VPX_IMG_FMT_444A:  return AV_PIX_FMT_YUVA444P;
> +#ifdef VPX_IMG_FMT_HIGHBITDEPTH
> +case VPX_IMG_FMT_I440:  return AV_PIX_FMT_YUV440P;

The correct guard for VPX_IMG_FMT_I440 is VPX_IMAGE_ABI_VERSION >=3.
libvpx git snapshots post 1.3.0 and pre 1.4.0 may fail because they may define 
VPX_IMG_FMT_HIGHBITDEPTH
but not VPX_IMG_FMT_I440.

>  case VPX_IMG_FMT_I42016:return AV_PIX_FMT_YUV420P16BE;
>  case VPX_IMG_FMT_I42216:return AV_PIX_FMT_YUV422P16BE;
>  case VPX_IMG_FMT_I44416:return AV_PIX_FMT_YUV444P16BE;
> +#endif
>  default:return AV_PIX_FMT_NONE;
>  }
>  }
> @@ -65,11 +67,13 @@ vpx_img_fmt_t ff_vpx_pixfmt_to_imgfmt(enum AVPixelFormat 
> pix)
>  case AV_PIX_FMT_YUV420P:  return VPX_IMG_FMT_I420;
>  case AV_PIX_FMT_YUV422P:  return VPX_IMG_FMT_I422;
>  case AV_PIX_FMT_YUV444P:  return VPX_IMG_FMT_I444;
> -case AV_PIX_FMT_YUV440P:  return VPX_IMG_FMT_I440;
>  case AV_PIX_FMT_YUVA444P: return VPX_IMG_FMT_444A;
> +#ifdef VPX_IMG_FMT_HIGHBITDEPTH
> +case AV_PIX_FMT_YUV440P:  return VPX_IMG_FMT_I440;
>  case AV_PIX_FMT_YUV420P16BE:  retur

Re: [libav-devel] [PATCH 09/11] hevc_parser: parse and export some stream parameters

2015-07-12 Thread James Almer
On 09/07/15 3:23 PM, Anton Khirnov wrote:
> Particularly those that will be needed by the QSV decoder.
> More can be added later as necessary.
> ---
>  configure|   1 +
>  libavcodec/Makefile  |   2 +-
>  libavcodec/hevc_parser.c | 128 
> +--
>  3 files changed, 125 insertions(+), 6 deletions(-)
> 
> diff --git a/configure b/configure
> index 45d1cf9..7154187 100755
> --- a/configure
> +++ b/configure
> @@ -2059,6 +2059,7 @@ wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
>  
>  # parsers
>  h264_parser_select="h264_decoder"
> +hevc_parser_select="golomb"

./configure --enable-gpl --disable-everything --disable-programs 
--enable-avconv --enable-parser=hevc

LD  avconv
libavcodec/libavcodec.a(hevc_parser.o): In function `parse_nal_units':
/home/jamrial/libav/libavcodec/hevc_parser.c:95: undefined reference to 
`ff_hevc_decode_nal_pps'
/home/jamrial/libav/libavcodec/hevc_parser.c:94: undefined reference to 
`ff_hevc_decode_nal_sps'
/home/jamrial/libav/libavcodec/hevc_parser.c:93: undefined reference to 
`ff_hevc_decode_nal_vps'
collect2: error: ld returned 1 exit status
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread James Almer
On 14/07/15 7:36 AM, Luca Barbato wrote:
> ---
> 
> Properly rebased version
> 
>  libavcodec/hevc_ps.c | 258 
> ++-
>  1 file changed, 131 insertions(+), 127 deletions(-)
> 
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index a5a2ace..2112265 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -1039,14 +1039,139 @@ static void hevc_pps_free(void *opaque, uint8_t 
> *data)
>  av_freep(&pps);
>  }
> 
> +static int setup_pps(AVCodecContext *avctx, GetBitContext *gb,

If this is done only for readability's sake and not because this function will 
be
used somewhere else, then making sure the compiler always inlines this function 
may
be a good idea.

> + HEVCPPS *pps, HEVCSPS *sps)
> +{
> +int log2_diff;
> +int pic_area_in_ctbs, pic_area_in_min_tbs;
> +int i, j, x, y, ctb_addr_rs, tile_id;
> +
> +// Inferred parameters
> +pps->col_bd   = av_malloc_array(pps->num_tile_columns + 1, 
> sizeof(*pps->col_bd));
> +pps->row_bd   = av_malloc_array(pps->num_tile_rows + 1,
> sizeof(*pps->row_bd));
> +pps->col_idxX = av_malloc_array(sps->ctb_width,
> sizeof(*pps->col_idxX));
> +if (!pps->col_bd || !pps->row_bd || !pps->col_idxX)
> +return AVERROR(ENOMEM);
> +
> +if (pps->uniform_spacing_flag) {
> +if (!pps->column_width) {
> +pps->column_width = av_malloc_array(pps->num_tile_columns, 
> sizeof(*pps->column_width));
> +pps->row_height   = av_malloc_array(pps->num_tile_rows,
> sizeof(*pps->row_height));
> +}
> +if (!pps->column_width || !pps->row_height)
> +return AVERROR(ENOMEM);
> +
> +for (i = 0; i < pps->num_tile_columns; i++) {
> +pps->column_width[i] = ((i + 1) * sps->ctb_width) / 
> pps->num_tile_columns -
> +   (i * sps->ctb_width) / 
> pps->num_tile_columns;
> +}
> +
> +for (i = 0; i < pps->num_tile_rows; i++) {
> +pps->row_height[i] = ((i + 1) * sps->ctb_height) / 
> pps->num_tile_rows -
> + (i * sps->ctb_height) / pps->num_tile_rows;
> +}
> +}
> +
> +pps->col_bd[0] = 0;
> +for (i = 0; i < pps->num_tile_columns; i++)
> +pps->col_bd[i + 1] = pps->col_bd[i] + pps->column_width[i];
> +
> +pps->row_bd[0] = 0;
> +for (i = 0; i < pps->num_tile_rows; i++)
> +pps->row_bd[i + 1] = pps->row_bd[i] + pps->row_height[i];
> +
> +for (i = 0, j = 0; i < sps->ctb_width; i++) {
> +if (i > pps->col_bd[j])
> +j++;
> +pps->col_idxX[i] = j;
> +}
> +
> +/**
> + * 6.5
> + */
> +pic_area_in_ctbs = sps->ctb_width* sps->ctb_height;
> +pic_area_in_min_tbs  = sps->min_tb_width * sps->min_tb_height;
> +
> +pps->ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs,
> sizeof(*pps->ctb_addr_rs_to_ts));
> +pps->ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs,
> sizeof(*pps->ctb_addr_ts_to_rs));
> +pps->tile_id   = av_malloc_array(pic_area_in_ctbs,
> sizeof(*pps->tile_id));
> +pps->min_tb_addr_zs= av_malloc_array(pic_area_in_min_tbs, 
> sizeof(*pps->min_tb_addr_zs));
> +if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||
> +!pps->tile_id || !pps->min_tb_addr_zs) {
> +return AVERROR(ENOMEM);
> +}
> +
> +for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
> +int tb_x   = ctb_addr_rs % sps->ctb_width;
> +int tb_y   = ctb_addr_rs / sps->ctb_width;
> +int tile_x = 0;
> +int tile_y = 0;
> +int val= 0;
> +
> +for (i = 0; i < pps->num_tile_columns; i++) {
> +if (tb_x < pps->col_bd[i + 1]) {
> +tile_x = i;
> +break;
> +}
> +}
> +
> +for (i = 0; i < pps->num_tile_rows; i++) {
> +if (tb_y < pps->row_bd[i + 1]) {
> +tile_y = i;
> +break;
> +}
> +}
> +
> +for (i = 0; i < tile_x; i++)
> +val += pps->row_height[tile_y] * pps->column_width[i];
> +for (i = 0; i < tile_y; i++)
> +val += sps->ctb_width * pps->row_height[i];
> +
> +val += (tb_y - pps->row_bd[tile_y]) * pps->column_width[tile_x] +
> +   tb_x - pps->col_bd[tile_x];
> +
> +pps->ctb_addr_rs_to_ts[ctb_addr_rs] = val;
> +pps->ctb_addr_ts_to_rs[val] = ctb_addr_rs;
> +}
> +
> +for (j = 0, tile_id = 0; j < pps->num_tile_rows; j++)
> +for (i = 0; i < pps->num_tile_columns; i++, tile_id++)
> +for (y = pps->row_bd[j]; y < pps->row_bd[j + 1]; y++)
> +for (x = pps->col_bd[i]; x < pps->col_bd[i + 1]; x++)
> +pps->tile_id[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + 
> x]] = tile_id;
> +
> +pps->tile_pos_rs = av_malloc_array(tile_id, sizeof(*pps->tile_pos

Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread James Almer
On 15/07/15 1:46 PM, Luca Barbato wrote:
> On 15/07/15 18:26, James Almer wrote:
>> If this is done only for readability's sake and not because this function 
>> will be
>> used somewhere else, then making sure the compiler always inlines this 
>> function may
>> be a good idea.
> 
> Good idea, the idea itself is fine?
> 
> lu

The split? It won't hurt, so sure.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread James Almer
On 15/07/15 2:06 PM, Anton Khirnov wrote:
> Quoting James Almer (2015-07-15 18:26:28)
>> On 14/07/15 7:36 AM, Luca Barbato wrote:
>>> ---
>>>
>>> Properly rebased version
>>>
>>>  libavcodec/hevc_ps.c | 258 
>>> ++-
>>>  1 file changed, 131 insertions(+), 127 deletions(-)
>>>
>>> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
>>> index a5a2ace..2112265 100644
>>> --- a/libavcodec/hevc_ps.c
>>> +++ b/libavcodec/hevc_ps.c
>>> @@ -1039,14 +1039,139 @@ static void hevc_pps_free(void *opaque, uint8_t 
>>> *data)
>>>  av_freep(&pps);
>>>  }
>>>
>>> +static int setup_pps(AVCodecContext *avctx, GetBitContext *gb,
>>
>> If this is done only for readability's sake and not because this function 
>> will be
>> used somewhere else, then making sure the compiler always inlines this 
>> function may
>> be a good idea.
>>
> 
> Why should that be important in this specific case?

Function call overhead. ff_hevc_decode_nal_pps() is not an init function, it may
or may not be called for every decoded frame.

The split in question doesn't seem to be anything but cosmetics, so might as 
well
make sure it doesn't affect performance, even if marginally, for no real gain.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 8/9] avconv: split creating and (re-)configuring complex filtergraphs

2015-07-20 Thread James Almer
On 16/07/15 3:56 PM, Anton Khirnov wrote:
> The current code is less than straightforward due to the fact that
> output streams can be created based on filtergraph definitions. This
> change should make the code simpler and more readable. It will also be
> useful in the future commits.

This commit introduced some memleaks.

See fate-filter-channelmap-one-int and fate-filter-channelmap-one-str in
https://fate.libav.org/x86_32-linux-gcc-valgrind/20150721024306
https://fate.libav.org/x86_64-linux-gcc-valgrind/20150721033643
https://fate.libav.org/ppc64-linux-gcc-valgrind/20150720195628
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/7] blowfish: add av_blowfish_alloc()

2015-07-27 Thread James Almer
Signed-off-by: James Almer 
---
 doc/APIchanges   |  3 +++
 libavutil/blowfish.c | 15 +++
 libavutil/blowfish.h | 10 ++
 libavutil/version.h  |  5 -
 4 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 4ee7f41..4db1a3c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - lavu 54.16.0
+  xxx -  Add av_blowfish_alloc().
+
 2015-xx-xx - lavc 56.35.0 - avcodec.h
   x - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*.
   x - Rename CODEC_CAP_* defines to AV_CODEC_CAP_*.
diff --git a/libavutil/blowfish.c b/libavutil/blowfish.c
index 8437dd6..97a10a7 100644
--- a/libavutil/blowfish.c
+++ b/libavutil/blowfish.c
@@ -24,8 +24,18 @@
 #include "avutil.h"
 #include "common.h"
 #include "intreadwrite.h"
+#include "mem.h"
 #include "blowfish.h"
 
+#if !FF_API_CRYPTO_CONTEXT
+#define AV_BF_ROUNDS 16
+
+typedef struct AVBlowfish {
+uint32_t p[AV_BF_ROUNDS + 2];
+uint32_t s[4][256];
+} AVBlowfish;
+#endif
+
 static const uint32_t orig_p[AV_BF_ROUNDS + 2] = {
 0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
@@ -312,6 +322,11 @@ static void F(AVBlowfish *ctx, uint32_t *xl, uint32_t *xr, 
int i)
 *xr = Xl;
 }
 
+struct AVBlowfish *av_blowfish_alloc(void)
+{
+return av_mallocz(sizeof(struct AVBlowfish));
+}
+
 av_cold void av_blowfish_init(AVBlowfish *ctx, const uint8_t *key, int key_len)
 {
 uint32_t data, data_l, data_r;
diff --git a/libavutil/blowfish.h b/libavutil/blowfish.h
index 8c29536..ef0e88f 100644
--- a/libavutil/blowfish.h
+++ b/libavutil/blowfish.h
@@ -22,6 +22,7 @@
 #define AVUTIL_BLOWFISH_H
 
 #include 
+#include "version.h"
 
 /**
  * @defgroup lavu_blowfish Blowfish
@@ -29,12 +30,21 @@
  * @{
  */
 
+#if FF_API_CRYPTO_CONTEXT
 #define AV_BF_ROUNDS 16
 
 typedef struct AVBlowfish {
 uint32_t p[AV_BF_ROUNDS + 2];
 uint32_t s[4][256];
 } AVBlowfish;
+#else
+struct AVBlowfish;
+#endif
+
+/**
+ * Allocate an AVBlowfish context.
+ */
+struct AVBlowfish *av_blowfish_alloc(void);
 
 /**
  * Initialize an AVBlowfish context.
diff --git a/libavutil/version.h b/libavutil/version.h
index 4c3b7f4..ae8924f 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 54
-#define LIBAVUTIL_VERSION_MINOR 15
+#define LIBAVUTIL_VERSION_MINOR 16
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -114,6 +114,9 @@
 #ifndef FF_API_DLOG
 #define FF_API_DLOG (LIBAVUTIL_VERSION_MAJOR < 55)
 #endif
+#ifndef FF_API_CRYPTO_CONTEXT
+#define FF_API_CRYPTO_CONTEXT   (LIBAVUTIL_VERSION_MAJOR < 55)
+#endif
 
 
 /**
-- 
2.4.5

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


[libav-devel] [PATCH 0/7] blowfish/dec/rc4/xtea updates

2015-07-27 Thread James Almer
This set aims at making the API of these four modules more consistent with
the rest of libavutil crypto stuff by adding alloc functions as well as
making the contexts opaque starting with the next lavu major version.

The last three patches are untested as i don't have access to an rtmpe
stream or encrypted asf/oma files. They are nonetheless not needed for the
time being and can be postponed until someone can properly test them if
that's preferred.

James Almer (7):
  blowfish: add av_blowfish_alloc()
  rc4: add av_rc4_alloc()
  xtea: add av_xtea_alloc()
  des: add av_des_alloc()
  rtmp: use the new blowfish/rc4/xtea alloc functions
  asfdec: use the new rc4/des alloc functions
  omadec: use the new des alloc function

 doc/APIchanges  |  6 +
 libavformat/asfcrypt.c  | 35 +-
 libavformat/asfcrypt.h  |  2 +-
 libavformat/asfdec.c| 12 ++---
 libavformat/omadec.c| 54 
 libavformat/rtmpcrypt.c | 66 +++--
 libavformat/rtmpcrypt.h |  5 ++--
 libavformat/rtmpproto.c | 15 ++-
 libavutil/blowfish.c| 15 +++
 libavutil/blowfish.h| 10 
 libavutil/des.c | 13 ++
 libavutil/des.h | 20 +++
 libavutil/rc4.c | 13 ++
 libavutil/rc4.h | 21 
 libavutil/version.h |  5 +++-
 libavutil/xtea.c| 12 +
 libavutil/xtea.h| 10 
 17 files changed, 249 insertions(+), 65 deletions(-)

-- 
2.4.5

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


[libav-devel] [PATCH 2/7] rc4: add av_rc4_alloc()

2015-07-27 Thread James Almer
Signed-off-by: James Almer 
---
 doc/APIchanges  |  1 +
 libavutil/rc4.c | 13 +
 libavutil/rc4.h | 21 +
 3 files changed, 35 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index 4db1a3c..3d40ec7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,7 @@ API changes, most recent first:
 
 2015-xx-xx - lavu 54.16.0
   xxx -  Add av_blowfish_alloc().
+  xxx -  Add av_rc4_alloc().
 
 2015-xx-xx - lavc 56.35.0 - avcodec.h
   x - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*.
diff --git a/libavutil/rc4.c b/libavutil/rc4.c
index 3bf710f..129c8f1 100644
--- a/libavutil/rc4.c
+++ b/libavutil/rc4.c
@@ -22,9 +22,22 @@
  */
 #include "avutil.h"
 #include "common.h"
+#include "mem.h"
 #include "rc4.h"
 
+#if FF_API_CRYPTO_CONTEXT
 typedef struct AVRC4 AVRC4;
+#else
+typedef struct AVRC4 {
+uint8_t state[256];
+int x, y;
+} AVRC4;
+#endif
+
+struct AVRC4 *av_rc4_alloc(void)
+{
+return av_mallocz(sizeof(struct AVRC4));
+}
 
 int av_rc4_init(AVRC4 *r, const uint8_t *key, int key_bits, int decrypt) {
 int i, j;
diff --git a/libavutil/rc4.h b/libavutil/rc4.h
index ec3b47c..c6168a6 100644
--- a/libavutil/rc4.h
+++ b/libavutil/rc4.h
@@ -22,17 +22,34 @@
 #define AVUTIL_RC4_H
 
 #include 
+#include "version.h"
 
+/**
+ * @defgroup lavu_rc4 RC4
+ * @ingroup lavu_crypto
+ * @{
+ */
+
+#if FF_API_CRYPTO_CONTEXT
 struct AVRC4 {
 uint8_t state[256];
 int x, y;
 };
+#else
+struct AVRC4;
+#endif
+
+/**
+ * Allocate an AVRC4 context.
+ */
+struct AVRC4 *av_rc4_alloc(void);
 
 /**
  * @brief Initializes an AVRC4 context.
  *
  * @param key_bits must be a multiple of 8
  * @param decrypt 0 for encryption, 1 for decryption, currently has no effect
+ * @return zero on success, negative value otherwise
  */
 int av_rc4_init(struct AVRC4 *d, const uint8_t *key, int key_bits, int 
decrypt);
 
@@ -47,4 +64,8 @@ int av_rc4_init(struct AVRC4 *d, const uint8_t *key, int 
key_bits, int decrypt);
  */
 void av_rc4_crypt(struct AVRC4 *d, uint8_t *dst, const uint8_t *src, int 
count, uint8_t *iv, int decrypt);
 
+/**
+ * @}
+ */
+
 #endif /* AVUTIL_RC4_H */
-- 
2.4.5

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


[libav-devel] [PATCH 6/7] asfdec: use the new rc4/des alloc functions

2015-07-27 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/asfcrypt.c | 35 ---
 libavformat/asfcrypt.h |  2 +-
 libavformat/asfdec.c   | 12 
 3 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/libavformat/asfcrypt.c b/libavformat/asfcrypt.c
index c261475..8292eae 100644
--- a/libavformat/asfcrypt.c
+++ b/libavformat/asfcrypt.c
@@ -144,35 +144,42 @@ static uint64_t multiswap_dec(const uint32_t keys[12],
 return ((uint64_t)b << 32) | a;
 }
 
-void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
+int ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
 {
-struct AVDES des;
-struct AVRC4 rc4;
+struct AVDES *des;
+struct AVRC4 *rc4;
 int num_qwords  = len >> 3;
 uint8_t *qwords = data;
 uint64_t rc4buff[8] = { 0 };
 uint64_t packetkey;
 uint32_t ms_keys[12];
 uint64_t ms_state;
-int i;
+int i, ret = 0;
 if (len < 16) {
 for (i = 0; i < len; i++)
 data[i] ^= key[i];
-return;
+return ret;
 }
 
-av_rc4_init(&rc4, key, 12 * 8, 1);
-av_rc4_crypt(&rc4, (uint8_t *)rc4buff, NULL, sizeof(rc4buff), NULL, 1);
+if (!(rc4 = av_rc4_alloc()))
+return AVERROR(ENOMEM);
+av_rc4_init(rc4, key, 12 * 8, 1);
+av_rc4_crypt(rc4, (uint8_t *)rc4buff, NULL, sizeof(rc4buff), NULL, 1);
 multiswap_init((uint8_t *)rc4buff, ms_keys);
 
 packetkey  = AV_RN64(&qwords[num_qwords * 8 - 8]);
 packetkey ^= rc4buff[7];
-av_des_init(&des, key + 12, 64, 1);
-av_des_crypt(&des, (uint8_t *)&packetkey, (uint8_t *)&packetkey, 1, NULL, 
1);
+
+if (!(des = av_des_alloc())) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+av_des_init(des, key + 12, 64, 1);
+av_des_crypt(des, (uint8_t *)&packetkey, (uint8_t *)&packetkey, 1, NULL, 
1);
 packetkey ^= rc4buff[6];
 
-av_rc4_init(&rc4, (uint8_t *)&packetkey, 64, 1);
-av_rc4_crypt(&rc4, data, data, len, NULL, 1);
+av_rc4_init(rc4, (uint8_t *)&packetkey, 64, 1);
+av_rc4_crypt(rc4, data, data, len, NULL, 1);
 
 ms_state = 0;
 for (i = 0; i < num_qwords - 1; i++, qwords += 8)
@@ -182,4 +189,10 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, 
int len)
 packetkey = av_le2ne64(packetkey);
 packetkey = multiswap_dec(ms_keys, ms_state, packetkey);
 AV_WL64(qwords, packetkey);
+
+fail:
+av_freep(&rc4);
+av_freep(&des);
+
+return ret;
 }
diff --git a/libavformat/asfcrypt.h b/libavformat/asfcrypt.h
index 53388b4..d4f311c 100644
--- a/libavformat/asfcrypt.h
+++ b/libavformat/asfcrypt.h
@@ -24,6 +24,6 @@
 
 #include 
 
-void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len);
+int ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len);
 
 #endif /* AVFORMAT_ASFCRYPT_H */
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 37d91e0..058bfa2 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1167,8 +1167,10 @@ static int asf_read_multiple_payload(AVFormatContext *s, 
AVPacket *pkt,
 }
 if ((ret = avio_read(pb, p, pay_len)) < 0)
 return ret;
-if (s->key && s->keylen == 20)
-ff_asfcrypt_dec(s->key, p, ret);
+if (s->key && s->keylen == 20) {
+if ((ret = ff_asfcrypt_dec(s->key, p, ret)) < 0)
+return ret;
+}
 avio_skip(pb, skip);
 asf_pkt->size_left -= pay_len;
 asf->nb_mult_left--;
@@ -1220,8 +1222,10 @@ static int asf_read_single_payload(AVFormatContext *s, 
AVPacket *pkt,
 asf_pkt->size_left = 0;
 if ((ret = avio_read(pb, p, size)) < 0)
 return ret;
-if (s->key && s->keylen == 20)
-ff_asfcrypt_dec(s->key, p, ret);
+if (s->key && s->keylen == 20) {
+if ((ret = ff_asfcrypt_dec(s->key, p, ret)) < 0)
+return ret;
+}
 if (asf->packet_size_internal)
 avio_skip(pb, asf->packet_size - asf->packet_size_internal);
 avio_skip(pb, asf->pad_len); // skip padding
-- 
2.4.5

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


[libav-devel] [PATCH 3/7] xtea: add av_xtea_alloc()

2015-07-27 Thread James Almer
Signed-off-by: James Almer 
---
 doc/APIchanges   |  1 +
 libavutil/xtea.c | 12 
 libavutil/xtea.h | 10 ++
 3 files changed, 23 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index 3d40ec7..be5d4cf 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -16,6 +16,7 @@ API changes, most recent first:
 2015-xx-xx - lavu 54.16.0
   xxx -  Add av_blowfish_alloc().
   xxx -  Add av_rc4_alloc().
+  xxx -  Add av_xtea_alloc().
 
 2015-xx-xx - lavc 56.35.0 - avcodec.h
   x - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*.
diff --git a/libavutil/xtea.c b/libavutil/xtea.c
index 53c0bfe..c0d8b17 100644
--- a/libavutil/xtea.c
+++ b/libavutil/xtea.c
@@ -31,8 +31,20 @@
 #include "avutil.h"
 #include "common.h"
 #include "intreadwrite.h"
+#include "mem.h"
 #include "xtea.h"
 
+#if !FF_API_CRYPTO_CONTEXT
+typedef struct AVXTEA {
+uint32_t key[16];
+} AVXTEA;
+#endif
+
+struct AVXTEA *av_xtea_alloc(void)
+{
+return av_mallocz(sizeof(struct AVXTEA));
+}
+
 void av_xtea_init(AVXTEA *ctx, const uint8_t key[16])
 {
 int i;
diff --git a/libavutil/xtea.h b/libavutil/xtea.h
index 0fc3810..54ba523 100644
--- a/libavutil/xtea.h
+++ b/libavutil/xtea.h
@@ -22,6 +22,7 @@
 #define AVUTIL_XTEA_H
 
 #include 
+#include "version.h"
 
 /**
  * @file
@@ -31,9 +32,18 @@
  * @{
  */
 
+#if FF_API_CRYPTO_CONTEXT
 typedef struct AVXTEA {
 uint32_t key[16];
 } AVXTEA;
+#else
+struct AVXTEA;
+#endif
+
+/**
+ * Allocate an AVXTEA context.
+ */
+struct AVXTEA *av_xtea_alloc(void);
 
 /**
  * Initialize an AVXTEA context.
-- 
2.4.5

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


[libav-devel] [PATCH 7/7] omadec: use the new des alloc function

2015-07-27 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/omadec.c | 54 
 1 file changed, 38 insertions(+), 16 deletions(-)

diff --git a/libavformat/omadec.c b/libavformat/omadec.c
index 28276d9..e57140d 100644
--- a/libavformat/omadec.c
+++ b/libavformat/omadec.c
@@ -74,7 +74,7 @@ typedef struct OMAContext {
 uint8_t sm_val[8];
 uint8_t e_val[8];
 uint8_t iv[8];
-struct AVDES av_des;
+struct AVDES *av_des;
 } OMAContext;
 
 static void hex_log(AVFormatContext *s, int level,
@@ -125,7 +125,7 @@ static int rprobe(AVFormatContext *s, uint8_t *enc_header, 
unsigned size,
 {
 OMAContext *oc = s->priv_data;
 unsigned int pos;
-struct AVDES av_des;
+struct AVDES *av_des;
 
 if (!enc_header || !r_val ||
 size < OMA_ENC_HEADER_SIZE + oc->k_size + oc->e_size + oc->i_size ||
@@ -133,20 +133,24 @@ static int rprobe(AVFormatContext *s, uint8_t 
*enc_header, unsigned size,
 return -1;
 
 /* m_val */
-av_des_init(&av_des, r_val, 192, 1);
-av_des_crypt(&av_des, oc->m_val, &enc_header[48], 1, NULL, 1);
+if (!(av_des = av_des_alloc()))
+return AVERROR(ENOMEM);
+av_des_init(av_des, r_val, 192, 1);
+av_des_crypt(av_des, oc->m_val, &enc_header[48], 1, NULL, 1);
 
 /* s_val */
-av_des_init(&av_des, oc->m_val, 64, 0);
-av_des_crypt(&av_des, oc->s_val, NULL, 1, NULL, 0);
+av_des_init(av_des, oc->m_val, 64, 0);
+av_des_crypt(av_des, oc->s_val, NULL, 1, NULL, 0);
 
 /* sm_val */
 pos = OMA_ENC_HEADER_SIZE + oc->k_size + oc->e_size;
-av_des_init(&av_des, oc->s_val, 64, 0);
-av_des_mac(&av_des, oc->sm_val, &enc_header[pos], (oc->i_size >> 3));
+av_des_init(av_des, oc->s_val, 64, 0);
+av_des_mac(av_des, oc->sm_val, &enc_header[pos], (oc->i_size >> 3));
 
 pos += oc->i_size;
 
+av_freep(&av_des);
+
 return memcmp(&enc_header[pos], oc->sm_val, 8) ? -1 : 0;
 }
 
@@ -156,7 +160,7 @@ static int nprobe(AVFormatContext *s, uint8_t *enc_header, 
unsigned size,
 OMAContext *oc = s->priv_data;
 uint64_t pos;
 uint32_t taglen, datalen;
-struct AVDES av_des;
+struct AVDES *av_des;
 
 if (!enc_header || !n_val ||
 size < OMA_ENC_HEADER_SIZE + oc->k_size + 4)
@@ -184,15 +188,21 @@ static int nprobe(AVFormatContext *s, uint8_t 
*enc_header, unsigned size,
 if (datalen << 4 > size - pos)
 return -1;
 
-av_des_init(&av_des, n_val, 192, 1);
+if (!(av_des = av_des_alloc()))
+return AVERROR(ENOMEM);
+av_des_init(av_des, n_val, 192, 1);
 while (datalen-- > 0) {
-av_des_crypt(&av_des, oc->r_val, &enc_header[pos], 2, NULL, 1);
+av_des_crypt(av_des, oc->r_val, &enc_header[pos], 2, NULL, 1);
 kset(s, oc->r_val, NULL, 16);
-if (!rprobe(s, enc_header, size, oc->r_val))
+if (!rprobe(s, enc_header, size, oc->r_val)) {
+av_freep(&av_des);
 return 0;
+}
 pos += 16;
 }
 
+av_freep(&av_des);
+
 return -1;
 }
 
@@ -278,13 +288,15 @@ static int decrypt_init(AVFormatContext *s, 
ID3v2ExtraMeta *em, uint8_t *header)
 }
 
 /* e_val */
-av_des_init(&oc->av_des, oc->m_val, 64, 0);
-av_des_crypt(&oc->av_des, oc->e_val,
+if (!(oc->av_des = av_des_alloc()))
+return AVERROR(ENOMEM);
+av_des_init(oc->av_des, oc->m_val, 64, 0);
+av_des_crypt(oc->av_des, oc->e_val,
  &gdata[OMA_ENC_HEADER_SIZE + 40], 1, NULL, 0);
 hex_log(s, AV_LOG_DEBUG, "EK", oc->e_val, 8);
 
 /* init e_val */
-av_des_init(&oc->av_des, oc->e_val, 64, 1);
+av_des_init(oc->av_des, oc->e_val, 64, 1);
 
 return 0;
 }
@@ -446,7 +458,7 @@ static int oma_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 /* previous unencrypted block saved in IV for
  * the next packet (CBC mode) */
 if (ret == packet_size)
-av_des_crypt(&oc->av_des, pkt->data, pkt->data,
+av_des_crypt(oc->av_des, pkt->data, pkt->data,
  (packet_size >> 3), oc->iv, 1);
 else
 memset(oc->iv, 0, 8);
@@ -502,6 +514,15 @@ wipe:
 return err;
 }
 
+static int oma_read_close(AVFormatContext *s)
+{
+OMAContext *oc = s->priv_data;
+
+av_freep(&oc->av_des);
+
+return 0;
+}
+
 AVInputFormat ff_oma_demuxer = {
 .name   = "oma",
 .long_name  = NULL_IF_CONFIG_SMALL("Sony OpenMG audio"),
@@ -510,6 +531,7 @@ AVInputFormat ff_oma_demuxer = {
 .read_header= oma_read_header,
 .read_packet= oma_read_packet,
 .read_seek  = oma_read_seek,
+.read_close = oma_read_close,
 .flags  = AVFMT_GENERIC_INDEX,
 .extensions = "oma,omg,aa3",
 .codec_tag  = (const AVCodecTag* const []){ff_oma_codec_tags, 0},
-- 
2.4.5

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


  1   2   3   4   >