[libav-devel] [PATCH 3/3] avconv_hw: Free device on initialisation failure

2017-06-16 Thread Mark Thompson
---
 avtools/avconv_hw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/avtools/avconv_hw.c b/avtools/avconv_hw.c
index 94be72330..81af54a19 100644
--- a/avtools/avconv_hw.c
+++ b/avtools/avconv_hw.c
@@ -208,6 +208,7 @@ invalid:
 fail:
 av_log(NULL, AV_LOG_ERROR,
"Device creation failed: %d.\n", err);
+av_buffer_unref(_ref);
 goto done;
 }
 
-- 
2.11.0
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 2/3] vf_hwmap: Properly free locally derived device

2017-06-16 Thread Mark Thompson
---
 libavfilter/vf_hwmap.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c
index 48ebbb6bd..b28cb2145 100644
--- a/libavfilter/vf_hwmap.c
+++ b/libavfilter/vf_hwmap.c
@@ -54,7 +54,7 @@ static int hwmap_config_output(AVFilterLink *outlink)
 AVHWFramesContext *hwfc;
 AVBufferRef *device;
 const AVPixFmtDescriptor *desc;
-int err;
+int err, device_is_derived;
 
 av_log(avctx, AV_LOG_DEBUG, "Configure hwmap %s -> %s.\n",
av_get_pix_fmt_name(inlink->format),
@@ -63,6 +63,7 @@ static int hwmap_config_output(AVFilterLink *outlink)
 av_buffer_unref(>hwframes_ref);
 
 device = avctx->hw_device_ctx;
+device_is_derived = 0;
 
 if (inlink->hw_frames_ctx) {
 hwfc = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
@@ -84,6 +85,7 @@ static int hwmap_config_output(AVFilterLink *outlink)
"device context: %d.\n", err);
 goto fail;
 }
+device_is_derived = 1;
 }
 
 desc = av_pix_fmt_desc_get(outlink->format);
@@ -238,9 +240,13 @@ static int hwmap_config_output(AVFilterLink *outlink)
 outlink->w = inlink->w;
 outlink->h = inlink->h;
 
+if (device_is_derived)
+av_buffer_unref();
 return 0;
 
 fail:
+if (device_is_derived)
+av_buffer_unref();
 av_buffer_unref(>hwframes_ref);
 return err;
 }
-- 
2.11.0
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 1/3] vf_hwmap: Add missing error code

2017-06-16 Thread Mark Thompson
---
(These three from coverity on the other tine.)


 libavfilter/vf_hwmap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c
index 2983528ea..48ebbb6bd 100644
--- a/libavfilter/vf_hwmap.c
+++ b/libavfilter/vf_hwmap.c
@@ -73,6 +73,7 @@ static int hwmap_config_output(AVFilterLink *outlink)
 type = av_hwdevice_find_type_by_name(ctx->derive_device_type);
 if (type == AV_HWDEVICE_TYPE_NONE) {
 av_log(avctx, AV_LOG_ERROR, "Invalid device type.\n");
+err = AVERROR(EINVAL);
 goto fail;
 }
 
-- 
2.11.0

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

Re: [libav-devel] [PATCH 2/4] movenc: generalize codec_tag lookup code

2017-06-16 Thread John Stebbins
On 06/15/2017 11:52 AM, John Stebbins wrote:
> This simplifies the code and adds the capability to support alternative
> tags for the same codec_id
> ---
>  libavformat/movenc.c | 137 
> ++-
>  1 file changed, 70 insertions(+), 67 deletions(-)
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 6c3d36c..eb12431 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -32,6 +32,7 @@
>  #include "isom.h"
>  #include "avc.h"
>  
> +#include "libavcodec/internal.h"
>  #include "libavcodec/bitstream.h"
>  #include "libavcodec/put_bits.h"
>  #include "libavcodec/vc1_common.h"
> @@ -778,50 +779,39 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack 
> *track)
>  return 0;
>  }
>  
> -static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track)
> +static int validate_codec_tag(const AVCodecTag * const tags[], unsigned int 
> tag,
> +  enum AVCodecID id)
>  {
> -int tag = track->par->codec_tag;
> -
> -if (!ff_codec_get_tag(ff_mp4_obj_type, track->par->codec_id))
> -return 0;
> +const AVCodecTag *avctag;
> +int n;
>  
> -if  (track->par->codec_id == AV_CODEC_ID_H264)  tag = 
> MKTAG('a','v','c','1');
> -else if (track->par->codec_id == AV_CODEC_ID_HEVC)  tag = 
> MKTAG('h','e','v','1');
> -else if (track->par->codec_id == AV_CODEC_ID_AC3)   tag = 
> MKTAG('a','c','-','3');
> -else if (track->par->codec_id == AV_CODEC_ID_DIRAC) tag = 
> MKTAG('d','r','a','c');
> -else if (track->par->codec_id == AV_CODEC_ID_MOV_TEXT)  tag = 
> MKTAG('t','x','3','g');
> -else if (track->par->codec_id == AV_CODEC_ID_VC1)   tag = 
> MKTAG('v','c','-','1');
> -else if (track->par->codec_type == AVMEDIA_TYPE_VIDEO)  tag = 
> MKTAG('m','p','4','v');
> -else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO)  tag = 
> MKTAG('m','p','4','a');
> -else if (track->par->codec_id == AV_CODEC_ID_DVD_SUBTITLE)  tag = 
> MKTAG('m','p','4','s');
> -
> -return tag;
> +for (n = 0; tags[n]; n++) {
> +avctag = tags[n];
> +while (avctag->id != AV_CODEC_ID_NONE) {
> +if (avpriv_toupper4(avctag->tag) == avpriv_toupper4(tag) &&
> +avctag->id == id)
> +return 1;
> +avctag++;
> +}
> +}
> +return 0;
>  }
>  
> -static const AVCodecTag codec_ipod_tags[] = {
> -{ AV_CODEC_ID_H264, MKTAG('a','v','c','1') },
> -{ AV_CODEC_ID_MPEG4,MKTAG('m','p','4','v') },
> -{ AV_CODEC_ID_AAC,  MKTAG('m','p','4','a') },
> -{ AV_CODEC_ID_ALAC, MKTAG('a','l','a','c') },
> -{ AV_CODEC_ID_AC3,  MKTAG('a','c','-','3') },
> -{ AV_CODEC_ID_MOV_TEXT, MKTAG('t','x','3','g') },
> -{ AV_CODEC_ID_MOV_TEXT, MKTAG('t','e','x','t') },
> -{ AV_CODEC_ID_NONE, 0 },
> -};
> -
> -static int ipod_get_codec_tag(AVFormatContext *s, MOVTrack *track)
> +static int get_codec_tag(AVFormatContext *s, MOVTrack *track)
>  {
>  int tag = track->par->codec_tag;
>  
> -// keep original tag for subs, ipod supports both formats
> -if (!(track->par->codec_type == AVMEDIA_TYPE_SUBTITLE &&
> -  (tag == MKTAG('t', 'x', '3', 'g') ||
> -   tag == MKTAG('t', 'e', 'x', 't'
> -tag = ff_codec_get_tag(codec_ipod_tags, track->par->codec_id);
> -
> -if (!av_match_ext(s->filename, "m4a") && !av_match_ext(s->filename, 
> "m4v"))
> -av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
> -   "Quicktime/Ipod might not play the file\n");
> +if (!tag || (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
> + s->oformat->codec_tag &&
> + !validate_codec_tag(s->oformat->codec_tag, tag,
> + track->par->codec_id))) {
> +int n = 0;
> +
> +tag = 0;
> +while (!tag && s->oformat->codec_tag[n])
> +tag = ff_codec_get_tag(s->oformat->codec_tag[n++],
> +   track->par->codec_id);
> +}
>  
>  return tag;
>  }
> @@ -926,42 +916,24 @@ static int mov_get_codec_tag(AVFormatContext *s, 
> MOVTrack *track)
>  return tag;
>  }
>  
> -static const AVCodecTag codec_3gp_tags[] = {
> -{ AV_CODEC_ID_H263, MKTAG('s','2','6','3') },
> -{ AV_CODEC_ID_H264, MKTAG('a','v','c','1') },
> -{ AV_CODEC_ID_MPEG4,MKTAG('m','p','4','v') },
> -{ AV_CODEC_ID_AAC,  MKTAG('m','p','4','a') },
> -{ AV_CODEC_ID_AMR_NB,   MKTAG('s','a','m','r') },
> -{ AV_CODEC_ID_AMR_WB,   MKTAG('s','a','w','b') },
> -{ AV_CODEC_ID_MOV_TEXT, MKTAG('t','x','3','g') },
> -{ AV_CODEC_ID_NONE, 0 },
> -};
> -
> -static const AVCodecTag codec_f4v_tags[] = {
> -{ AV_CODEC_ID_MP3,MKTAG('.','m','p','3') },
> -{ AV_CODEC_ID_AAC,MKTAG('m','p','4','a') },
> -{ AV_CODEC_ID_H264,   MKTAG('a','v','c','1') },
> -{ AV_CODEC_ID_VP6A,   MKTAG('V','P','6','A') },
> -

Re: [libav-devel] [PATCH 6/6] avcodec/h264: Fix mix of lossless and lossy MBs decoding

2017-06-16 Thread Luca Barbato
On 6/16/17 12:56 AM, Vittorio Giovara wrote:
> From: Anton Mitrofanov 
> 
> ---
>  libavcodec/h264_cabac.c | 16 
>  libavcodec/h264_cavlc.c | 16 
>  2 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
> index c28f5680de..e6dc5258a4 100644
> --- a/libavcodec/h264_cabac.c
> +++ b/libavcodec/h264_cabac.c
> @@ -2371,14 +2371,6 @@ decode_intra_mb:
>  const uint8_t *scan, *scan8x8;
>  const uint32_t *qmul;
>  
> -if(IS_INTERLACED(mb_type)){
> -scan8x8 = sl->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
> -scan= sl->qscale ? h->field_scan : h->field_scan_q0;
> -}else{
> -scan8x8 = sl->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
> -scan= sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
> -}
> -
>  // decode_cabac_mb_dqp
>  if(get_cabac_noinline( >cabac, >cabac_state[60 + 
> (sl->last_qscale_diff != 0)])){
>  int val = 1;
> @@ -2409,6 +2401,14 @@ decode_intra_mb:
>  }else
>  sl->last_qscale_diff=0;
>  
> +if(IS_INTERLACED(mb_type)){
> +scan8x8 = sl->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
> +scan= sl->qscale ? h->field_scan : h->field_scan_q0;
> +}else{
> +scan8x8 = sl->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
> +scan= sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
> +}
> +
>  decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, 
> mb_type, cbp, 0);
>  if (CHROMA444(h)) {
>  decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, 
> mb_type, cbp, 1);
> diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
> index c11e211bd8..d57062bc56 100644
> --- a/libavcodec/h264_cavlc.c
> +++ b/libavcodec/h264_cavlc.c
> @@ -1093,14 +1093,6 @@ decode_intra_mb:
>  const uint8_t *scan, *scan8x8;
>  const int max_qp = 51 + 6 * (h->ps.sps->bit_depth_luma - 8);
>  
> -if(IS_INTERLACED(mb_type)){
> -scan8x8 = sl->qscale ? h->field_scan8x8_cavlc : 
> h->field_scan8x8_cavlc_q0;
> -scan= sl->qscale ? h->field_scan : h->field_scan_q0;
> -}else{
> -scan8x8 = sl->qscale ? h->zigzag_scan8x8_cavlc : 
> h->zigzag_scan8x8_cavlc_q0;
> -scan= sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
> -}
> -
>  dquant= get_se_golomb(>gb);
>  
>  sl->qscale += dquant;
> @@ -1117,6 +1109,14 @@ decode_intra_mb:
>  sl->chroma_qp[0] = get_chroma_qp(h->ps.pps, 0, sl->qscale);
>  sl->chroma_qp[1] = get_chroma_qp(h->ps.pps, 1, sl->qscale);
>  
> +if(IS_INTERLACED(mb_type)){
> +scan8x8 = sl->qscale ? h->field_scan8x8_cavlc : 
> h->field_scan8x8_cavlc_q0;
> +scan= sl->qscale ? h->field_scan : h->field_scan_q0;
> +}else{
> +scan8x8 = sl->qscale ? h->zigzag_scan8x8_cavlc : 
> h->zigzag_scan8x8_cavlc_q0;
> +scan= sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
> +}
> +
>  if ((ret = decode_luma_residual(h, sl, gb, scan, scan8x8, 
> pixel_shift, mb_type, cbp, 0)) < 0 ) {
>  return -1;
>  }
> 

Beside the style nits, looks probably ok.

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

Re: [libav-devel] [PATCH 1/6] avcodec/h264_slice: Also copy x264_build in ff_h264_update_thread_context()

2017-06-16 Thread Anton Khirnov
Quoting Vittorio Giovara (2017-06-16 00:56:11)
> From: Michael Niedermayer 
> 
> Fixes fate-h264-lossless
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/h264_slice.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> index c9f1dbb86f..0ce4127a1d 100644
> --- a/libavcodec/h264_slice.c
> +++ b/libavcodec/h264_slice.c
> @@ -408,6 +408,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
>  // extradata/NAL handling
>  h->is_avc = h1->is_avc;
>  h->nal_length_size = h1->nal_length_size;
> +h->sei.unregistered.x264_build = h1->sei.unregistered.x264_build;
>  
>  memcpy(>poc,>poc,sizeof(h->poc));
>  
> -- 
> 2.13.1

This (and the following patch) is the wrong way to do it. H264SEI should
store the content of the last parsed SEI, other code should not mess
with it.

The right thing to do is maintain a copy of x264_build in H264Context.

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