Merge commit 'b183abfb5b6366b177cf44f244c66156257a6fd6'
authorClément Bœsch <cboesch@gopro.com>
Wed, 15 Mar 2017 11:23:18 +0000 (12:23 +0100)
committerClément Bœsch <cboesch@gopro.com>
Wed, 15 Mar 2017 11:23:18 +0000 (12:23 +0100)
* commit 'b183abfb5b6366b177cf44f244c66156257a6fd6':
  vpx: Support color range

Decoder chunk not merged as the framework automatically copies avctx
color range to the frame color range. And we already set the avctx field
since cbcc88c039.

Merged-by: Clément Bœsch <cboesch@gopro.com>
1  2 
libavcodec/libvpxenc.c

@@@ -1000,26 -551,17 +1000,36 @@@ static int vpx_encode(AVCodecContext *a
          rawimg->stride[VPX_PLANE_Y] = frame->linesize[0];
          rawimg->stride[VPX_PLANE_U] = frame->linesize[1];
          rawimg->stride[VPX_PLANE_V] = frame->linesize[2];
 +        if (ctx->is_alpha) {
 +            uint8_t *u_plane, *v_plane;
 +            rawimg_alpha = &ctx->rawimg_alpha;
 +            rawimg_alpha->planes[VPX_PLANE_Y] = frame->data[3];
 +            u_plane = av_malloc(frame->linesize[1] * frame->height);
 +            v_plane = av_malloc(frame->linesize[2] * frame->height);
 +            if (!u_plane || !v_plane) {
 +                av_free(u_plane);
 +                av_free(v_plane);
 +                return AVERROR(ENOMEM);
 +            }
 +            memset(u_plane, 0x80, frame->linesize[1] * frame->height);
 +            rawimg_alpha->planes[VPX_PLANE_U] = u_plane;
 +            memset(v_plane, 0x80, frame->linesize[2] * frame->height);
 +            rawimg_alpha->planes[VPX_PLANE_V] = v_plane;
 +            rawimg_alpha->stride[VPX_PLANE_Y] = frame->linesize[0];
 +            rawimg_alpha->stride[VPX_PLANE_U] = frame->linesize[1];
 +            rawimg_alpha->stride[VPX_PLANE_V] = frame->linesize[2];
 +        }
          timestamp                   = frame->pts;
+ #if VPX_IMAGE_ABI_VERSION >= 4
+         switch (frame->color_range) {
+         case AVCOL_RANGE_MPEG:
+             rawimg->range = VPX_CR_STUDIO_RANGE;
+             break;
+         case AVCOL_RANGE_JPEG:
+             rawimg->range = VPX_CR_FULL_RANGE;
+             break;
+         }
+ #endif
          if (frame->pict_type == AV_PICTURE_TYPE_I)
              flags |= VPX_EFLAG_FORCE_KF;
      }