From patchwork Sun Apr 29 21:56:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 8697 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp2898013jad; Sun, 29 Apr 2018 14:57:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZozPtS6BRq170vHJ5p++Vcz6Mjx9H8yzrEGL5qqO7w5NDafsoytrk4JtRvANjJgbILUXgTA X-Received: by 10.28.235.14 with SMTP id j14mr5548282wmh.87.1525039059462; Sun, 29 Apr 2018 14:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525039059; cv=none; d=google.com; s=arc-20160816; b=zyt0PqwAgnV5e1kIb+WMgqZ+1Ah3JKFxcH57gyKZL9cDg8y5x2p/Ts0u7fCFOvmAED l2v0iJSqwrQrRcTZuD507IVPriqhiYCv82neAAu83Yx7u50LdnZgK0efCxJso1Gp34xG 9uygt58cphc8QdG0QCrW5P3mEEbAU+jO3Hd2R49AhxTzI/1tx6CTCWlYihSvmsPoWDQE cr3gRLuQSWg728yOdlIPGpkLkevEGM+7XnWzNyfcpPqj5r6zVoSYBisfZlpphEn4aXtk GVgSkOkZbFpxkGISOGOgRYFFZdEix8uieVirIE105UKiYxYXZucNijXx0bc/QWdEgqDq GQkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=2dQyn5BCqDhDSFLvEGpgBfs36IXLMyUUuiH71T7KmfA=; b=sLe8+567pcIYVBPVm4mdDnuAC0unZMHK6x4u8DtC6YuqKa5VcQ2PP8XS15xnPfIXLZ g10AZWQUThl2uyfeQRnAUUvRoJ6X7r2AiEOp2ul9e9UXDaSwnKt0ww/QiZ0PuH4rqwhp IY+g6smpMtD60euIdg4SCEEkZplBD9YfRtIMt1jQ1455o37goDKBdIGGGZAfVzMdCeQk kZqiy/a2MFVWu6o/eUKdInGwWYksa6CJohj2y9Gjl2OWRstqsiCbMxnDk/p5eeEWmS5n Q0KQIpGQ6fy6Z2o9qykO/5jIMcIjIFpjLwCesnk3ssVMRXa3VbFxK0Ga6amzAxkzNgm6 XoUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l22-v6si5029611wre.77.2018.04.29.14.57.38; Sun, 29 Apr 2018 14:57:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DE42668A380; Mon, 30 Apr 2018 00:57:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe04-3.mx.upcmail.net (vie01a-dmta-pe04-3.mx.upcmail.net [62.179.121.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CF1E9689F18 for ; Mon, 30 Apr 2018 00:56:58 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fCuK1-0008B3-Ao for ffmpeg-devel@ffmpeg.org; Sun, 29 Apr 2018 23:57:29 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id gMxU1x00P0S5wYM01MxVJj; Sun, 29 Apr 2018 23:57:29 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 29 Apr 2018 23:56:16 +0200 Message-Id: <20180429215616.17303-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180429215616.17303-1-michael@niedermayer.cc> References: <20180429215616.17303-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/mpeg4video: Detect reference studio streams as studio streams X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Michael Niedermayer --- libavcodec/mpeg4video.h | 2 ++ libavcodec/mpeg4videodec.c | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index f974792887..dd0a59038d 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -41,6 +41,8 @@ #define NBIT_VO_TYPE 5 #define ARTS_VO_TYPE 10 #define ACE_VO_TYPE 12 +#define SIMPLE_STUDIO_VO_TYPE 14 +#define CORE_STUDIO_VO_TYPE 15 #define ADV_SIMPLE_VO_TYPE 17 #define VOT_VIDEO_ID 1 diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index ada5cdc6fa..d2b5e90331 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -46,6 +46,8 @@ #define MB_TYPE_B_VLC_BITS 4 #define STUDIO_INTRA_BITS 9 +static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb); + static VLC dc_lum, dc_chrom; static VLC sprite_trajectory; static VLC mb_type_b_vlc; @@ -2049,6 +2051,18 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) /* vol header */ skip_bits(gb, 1); /* random access */ s->vo_type = get_bits(gb, 8); + + if (s->vo_type == CORE_STUDIO_VO_TYPE || + s->vo_type == SIMPLE_STUDIO_VO_TYPE) { + if (s->avctx->profile != FF_PROFILE_UNKNOWN && s->avctx->profile != FF_PROFILE_MPEG4_SIMPLE_STUDIO) + return AVERROR_INVALIDDATA; + s->studio_profile = 1; + s->avctx->profile = FF_PROFILE_MPEG4_SIMPLE_STUDIO; + return decode_studio_vol_header(ctx, gb); + } else if (s->studio_profile) { + return AVERROR_PATCHWELCOME; + } + if (get_bits1(gb) != 0) { /* is_ol_id */ vo_ver_id = get_bits(gb, 4); /* vo_ver_id */ skip_bits(gb, 3); /* vo_priority */ @@ -3001,8 +3015,6 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) int width, height; int bits_per_raw_sample; - skip_bits1(gb); /* random_accessible_vol */ - skip_bits(gb, 8); /* video_object_type_indication */ skip_bits(gb, 4); /* video_object_layer_verid */ ctx->shape = get_bits(gb, 2); /* video_object_layer_shape */ skip_bits(gb, 4); /* video_object_layer_shape_extension */ @@ -3179,13 +3191,8 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb) continue; } vol++; - if (s->studio_profile) { - if ((ret = decode_studio_vol_header(ctx, gb)) < 0) - return ret; - } else { - if ((ret = decode_vol_header(ctx, gb)) < 0) - return ret; - } + if ((ret = decode_vol_header(ctx, gb)) < 0) + return ret; } else if (startcode == USER_DATA_STARTCODE) { decode_user_data(ctx, gb); } else if (startcode == GOP_STARTCODE) {