]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'e328178da90f44690e0076f4dbfd16da9175f441'
authorClément Bœsch <u@pkh.me>
Wed, 15 Mar 2017 22:22:50 +0000 (23:22 +0100)
committerClément Bœsch <u@pkh.me>
Wed, 15 Mar 2017 22:22:50 +0000 (23:22 +0100)
* commit 'e328178da90f44690e0076f4dbfd16da9175f441':
  qsvdec: only access hwaccel_context is the pixel format is QSV

Merged-by: Clément Bœsch <u@pkh.me>
1  2 
libavcodec/qsvdec.c

diff --combined libavcodec/qsvdec.c
index 06056a30618ee865e527104b66a33d21ea0286a2,e19eba5b52ffdb145d3e8de82afa2a523c245380..dc9db2fafbd8c3d8fe931679c229dc3fb286cba8
@@@ -4,20 -4,20 +4,20 @@@
   * copyright (c) 2013 Luca Barbato
   * copyright (c) 2015 Anton Khirnov <anton@khirnov.net>
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
 - * Libav is free software; you can redistribute it and/or
 + * FFmpeg is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   *
 - * Libav is distributed in the hope that it will be useful,
 + * FFmpeg is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
 - * License along with Libav; if not, write to the Free Software
 + * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
@@@ -106,7 -106,7 +106,7 @@@ static int qsv_decode_init(AVCodecConte
              return AVERROR(ENOMEM);
      }
  
-     if (avctx->hwaccel_context) {
+     if (avctx->pix_fmt == AV_PIX_FMT_QSV && avctx->hwaccel_context) {
          AVQSVContext *user_ctx = avctx->hwaccel_context;
          session           = user_ctx->session;
          iopattern         = user_ctx->iopattern;
          return ret;
  
      param.mfx.CodecId      = ret;
 -    param.mfx.CodecProfile = avctx->profile;
 -    param.mfx.CodecLevel   = avctx->level;
 +    param.mfx.CodecProfile = ff_qsv_profile_to_mfx(avctx->codec_id, avctx->profile);
 +    param.mfx.CodecLevel   = avctx->level == FF_LEVEL_UNKNOWN ? MFX_LEVEL_UNKNOWN : avctx->level;
  
      param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
      param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
      param.mfx.FrameInfo.Height         = frame_height;
      param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
  
 +    switch (avctx->field_order) {
 +    case AV_FIELD_PROGRESSIVE:
 +        param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
 +        break;
 +    case AV_FIELD_TT:
 +        param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
 +        break;
 +    case AV_FIELD_BB:
 +        param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_BFF;
 +        break;
 +    default:
 +        param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_UNKNOWN;
 +        break;
 +    }
 +
      param.IOPattern   = q->iopattern;
      param.AsyncDepth  = q->async_depth;
      param.ExtParam    = q->ext_buffers;
@@@ -298,15 -283,13 +298,15 @@@ static int qsv_decode(AVCodecContext *a
  
      do {
          ret = get_surface(avctx, q, &insurf);
 -        if (ret < 0)
 +        if (ret < 0) {
 +            av_freep(&sync);
              return ret;
 +        }
  
          ret = MFXVideoDECODE_DecodeFrameAsync(q->session, avpkt->size ? &bs : NULL,
                                                insurf, &outsurf, sync);
          if (ret == MFX_WRN_DEVICE_BUSY)
 -            av_usleep(1);
 +            av_usleep(500);
  
      } while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_ERR_MORE_SURFACE);
  
@@@ -439,6 -422,16 +439,6 @@@ int ff_qsv_process_data(AVCodecContext 
          if (!q->avctx_internal)
              return AVERROR(ENOMEM);
  
 -        if (avctx->extradata) {
 -            q->avctx_internal->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
 -            if (!q->avctx_internal->extradata)
 -                return AVERROR(ENOMEM);
 -
 -            memcpy(q->avctx_internal->extradata, avctx->extradata,
 -                   avctx->extradata_size);
 -            q->avctx_internal->extradata_size = avctx->extradata_size;
 -        }
 -
          q->parser = av_parser_init(avctx->codec_id);
          if (!q->parser)
              return AVERROR(ENOMEM);
          avctx->height       = q->parser->height;
          avctx->coded_width  = q->parser->coded_width;
          avctx->coded_height = q->parser->coded_height;
 +        avctx->field_order  = q->parser->field_order;
          avctx->level        = q->avctx_internal->level;
          avctx->profile      = q->avctx_internal->profile;