From patchwork Sun Dec 10 15:20:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 6682 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp1783222jah; Sun, 10 Dec 2017 07:20:34 -0800 (PST) X-Google-Smtp-Source: ACJfBosiVxK47TJRFjuodmkO6GJIMkr1B5i8Uyx5+q6UoNQtW6nRO9Lmd+PgjSd+9mRiUppIhPl3 X-Received: by 10.28.131.73 with SMTP id f70mr6867793wmd.153.1512919234190; Sun, 10 Dec 2017 07:20:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512919234; cv=none; d=google.com; s=arc-20160816; b=dya7TP6+A0tgPW3/19WvMcUeFpHpLDdcxOTgab8OBsmYV4Hzir2zPR5Xh76LcOhf5C QqT/3vBg/7iLMAYtpTP+7cCz+1mE4SANBGLSXFaVshPb7DUoFec42imHig4YZ3XwaCUL rKRNG/VffU1oyIhtAgkRyvbWXp7tyq2NfvCZzIS3pkbumr25Ldss/GOpMvdKZJxc6O1G MXd2BLPVoz6cy8wGAFXG7EpOJqJV72M8hkHDUfOWy7s5INwJEJBjnKOnoLo0cp1EOo5b PnaUlrSGZdCMkJnouU0HzoYF9TDlUbCNSoA2uhjiSzkpksf8GmaJvhs+7Mh7PYhK2+W6 gQQg== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=Y104TvoqwjRw6rbeEd8EFBLzBWp6AKcfknpDP4yN0Hc=; b=lL2uxJpMfhYjyrq3MoCxsp7FcfDqHNTvRW7uNGVoH7tBqENjXhnYYic7CSpPaxZ5wD vKKaLxYU0OUmn6AgDkdRcc/IzHXCKyCE9HEiZstY1+oOkhOtRhFMuaFrM82VDFruoCks uwmrlTujXvhknQJdHeQC/mVeRQO/XDTGLMbIfbxGn1ZNRyraXRJHg8ylCwuUTKoVmusO +lBDNoglJYQYkrKqDPEb5iLnlf7BoITqkjCqw6VTnqjvb/W9OmDnaQ7FTODaLt4iBdbj PIWj4X8aD7wn1H3bMuspnVTiGlzrr61oLGEwl4hugeEz87I0Ojrm8yvY4Wp0cQQ3x7C3 tZtg== 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 p95si9188347wrb.504.2017.12.10.07.20.33; Sun, 10 Dec 2017 07:20:34 -0800 (PST) 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 9EC0B68A52B; Sun, 10 Dec 2017 17:20:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe01-2.mx.upcmail.net (vie01a-dmta-pe01-2.mx.upcmail.net [62.179.121.155]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE23A688353 for ; Sun, 10 Dec 2017 17:20:18 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eO3Oz-00007Z-5V for ffmpeg-devel@ffmpeg.org; Sun, 10 Dec 2017 16:20:25 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id kFLE1w02P0S5wYM01FLFJa; Sun, 10 Dec 2017 16:20:16 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 10 Dec 2017 16:20:14 +0100 Message-Id: <20171210152014.30802-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.15.1 Subject: [FFmpeg-devel] [PATCH] avcodec/mpeg4videodec: Add support for parsing and exporting video_range 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 | 3 +++ libavcodec/mpeg4videodec.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index 515b008ae4..0ba502d50b 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -43,6 +43,9 @@ #define ACE_VO_TYPE 12 #define ADV_SIMPLE_VO_TYPE 17 +#define VOT_VIDEO_ID 1 +#define VOT_STILL_TEXTURE_ID 2 + // aspect_ratio_info #define EXTENDED_PAR 15 diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index cdd7077f01..852f73f02c 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -1751,6 +1751,36 @@ static int mpeg4_decode_profile_level(MpegEncContext *s, GetBitContext *gb) s->avctx->level = 0; } + return 0; + +} + +static int mpeg4_decode_visual_object(MpegEncContext *s, GetBitContext *gb) +{ + int visual_object_type; + int is_visual_object_identifier = get_bits1(gb); + + if (is_visual_object_identifier) { + skip_bits(gb, 4+3); + } + visual_object_type = get_bits(gb, 4); + + if (visual_object_type == VOT_VIDEO_ID || + visual_object_type == VOT_STILL_TEXTURE_ID) { + int video_signal_type = get_bits1(gb); + if (video_signal_type) { + int video_format = get_bits(gb, 3); + int video_range = get_bits1(gb); + int color_description = get_bits1(gb); + + s->avctx->color_range = video_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; + + if (color_description) { + skip_bits(gb, 8+8+8); + } + } + } + return 0; } @@ -2684,6 +2714,8 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb) mpeg4_decode_gop_header(s, gb); } else if (startcode == VOS_STARTCODE) { mpeg4_decode_profile_level(s, gb); + } else if (startcode == VISUAL_OBJ_STARTCODE) { + mpeg4_decode_visual_object(s, gb); } else if (startcode == VOP_STARTCODE) { break; }