Commit d9071d73 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: mp4: update from vp8/9/10 spec

(cherry picked from commit 2e6a72d2)
parent 99a234fd
......@@ -5,6 +5,7 @@ Demux:
* Fix wrong colors in some AVI files
* Fix IFO files playback
* Fix a crash with missing/invalid MPEG SDT
* Update VP8/9/10 ISOBMFF bindings
Audio output:
* Fix mmdevice default audio device handling
......
......@@ -208,6 +208,7 @@ libmp4_plugin_la_SOURCES = demux/mp4/mp4.c demux/mp4/mp4.h \
demux/mp4/languages.h \
demux/asf/asfpacket.c demux/asf/asfpacket.h \
demux/mp4/avci.h \
demux/mp4/color_specs.h \
demux/mp4/essetup.c demux/mp4/meta.c \
meta_engine/ID3Genres.h
libmp4_plugin_la_LIBADD = $(LIBM)
......
......@@ -28,6 +28,7 @@
#include "avci.h"
#include "../xiph.h"
#include "../../packetizer/dts_header.h"
#include "color_config.h"
#include <vlc_demux.h>
#include <vlc_aout.h>
......@@ -670,24 +671,37 @@ int SetupVideoES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
p_track->fmt.i_codec = VLC_CODEC_VP8;
p_track->fmt.i_profile = p_data->i_profile;
p_track->fmt.i_level = p_data->i_level;
const uint8_t colorspacesmapping[] =
{
COLOR_SPACE_UNDEF,
COLOR_SPACE_BT601,
COLOR_SPACE_BT709,
COLOR_SPACE_SMPTE_170,
COLOR_SPACE_SMPTE_240,
COLOR_SPACE_BT2020,
COLOR_SPACE_BT2020,
COLOR_SPACE_SRGB,
};
if( p_data->i_color_space < ARRAY_SIZE(colorspacesmapping) )
p_track->fmt.video.space = colorspacesmapping[p_data->i_color_space];
if( p_data->i_xfer_function == 0 )
p_track->fmt.video.transfer = TRANSFER_FUNC_BT709;
else if ( p_data->i_xfer_function == 1 )
p_track->fmt.video.transfer = TRANSFER_FUNC_SMPTE_ST2084;
if( p_data->i_version == 0 ) /* old deprecated */
{
const uint8_t colorspacesmapping[] =
{
COLOR_SPACE_UNDEF,
COLOR_SPACE_BT601,
COLOR_SPACE_BT709,
COLOR_SPACE_SMPTE_170,
COLOR_SPACE_SMPTE_240,
COLOR_SPACE_BT2020,
COLOR_SPACE_BT2020,
COLOR_SPACE_SRGB,
};
if( p_data->i_color_primaries < ARRAY_SIZE(colorspacesmapping) )
p_track->fmt.video.space = colorspacesmapping[p_data->i_color_primaries];
if( p_data->i_xfer_function == 0 )
p_track->fmt.video.transfer = TRANSFER_FUNC_BT709;
else if ( p_data->i_xfer_function == 1 )
p_track->fmt.video.transfer = TRANSFER_FUNC_SMPTE_ST2084;
}
else
{
p_track->fmt.video.primaries =
iso_23001_8_cp_to_vlc_primaries( p_data->i_color_primaries );
p_track->fmt.video.transfer =
iso_23001_8_tc_to_vlc_xfer( p_data->i_xfer_function );
p_track->fmt.video.space =
iso_23001_8_mc_to_vlc_coeffs( p_data->i_matrix_coeffs );
}
p_track->fmt.video.b_color_range_full = p_data->i_fullrange;
p_track->fmt.video.i_bits_per_pixel = p_data->i_bit_depth;
......
......@@ -1949,20 +1949,35 @@ static int MP4_ReadBox_vpcC( stream_t *p_stream, MP4_Box_t *p_box )
if( p_box->i_size < 6 )
MP4_READBOX_EXIT( 0 );
uint8_t i_version;
MP4_GET1BYTE( i_version );
if( i_version != 0 )
MP4_GET1BYTE( p_vpcC->i_version );
if( p_vpcC->i_version > 1 )
MP4_READBOX_EXIT( 0 );
MP4_GET1BYTE( p_vpcC->i_profile );
MP4_GET1BYTE( p_vpcC->i_level );
MP4_GET1BYTE( p_vpcC->i_bit_depth );
p_vpcC->i_color_space = p_vpcC->i_bit_depth & 0x0F;
p_vpcC->i_bit_depth >>= 4;
MP4_GET1BYTE( p_vpcC->i_chroma_subsampling );
p_vpcC->i_xfer_function = ( p_vpcC->i_chroma_subsampling & 0x0F ) >> 1;
p_vpcC->i_fullrange = p_vpcC->i_chroma_subsampling & 0x01;
p_vpcC->i_chroma_subsampling >>= 4;
/* Deprecated one
https://github.com/webmproject/vp9-dash/blob/master/archive/VPCodecISOMediaFileFormatBinding-v0.docx */
if( p_vpcC->i_version == 0 )
{
p_vpcC->i_color_primaries = p_vpcC->i_bit_depth & 0x0F;
p_vpcC->i_bit_depth >>= 4;
MP4_GET1BYTE( p_vpcC->i_chroma_subsampling );
p_vpcC->i_xfer_function = ( p_vpcC->i_chroma_subsampling & 0x0F ) >> 1;
p_vpcC->i_fullrange = p_vpcC->i_chroma_subsampling & 0x01;
p_vpcC->i_chroma_subsampling >>= 4;
}
else
{
p_vpcC->i_chroma_subsampling = ( p_vpcC->i_bit_depth & 0x0F ) >> 1;
p_vpcC->i_fullrange = p_vpcC->i_bit_depth & 0x01;
p_vpcC->i_bit_depth >>= 4;
MP4_GET1BYTE( p_vpcC->i_color_primaries );
MP4_GET1BYTE( p_vpcC->i_xfer_function );
MP4_GET1BYTE( p_vpcC->i_matrix_coeffs );
}
MP4_GET2BYTES( p_vpcC->i_codec_init_datasize );
if( p_vpcC->i_codec_init_datasize > i_read )
p_vpcC->i_codec_init_datasize = i_read;
......
......@@ -1270,12 +1270,14 @@ typedef struct
typedef struct
{
uint8_t i_version;
uint8_t i_profile;
uint8_t i_level;
uint8_t i_bit_depth;
uint8_t i_color_space;
uint8_t i_chroma_subsampling;
uint8_t i_color_primaries;
uint8_t i_xfer_function;
uint8_t i_matrix_coeffs;
uint8_t i_fullrange;
uint16_t i_codec_init_datasize;
uint8_t *p_codec_init_data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment