VLC 4.0.0-dev
Loading...
Searching...
No Matches
vlc_es.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vlc_es.h: Elementary stream formats descriptions
3 *****************************************************************************
4 * Copyright (C) 1999-2012 VLC authors and VideoLAN
5 *
6 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
22
23#ifndef VLC_ES_H
24#define VLC_ES_H 1
25
26#include <vlc_common.h>
27#include <vlc_fourcc.h>
28#include <vlc_viewpoint.h>
29
30/**
31 * \file
32 * This file defines the elementary streams format types
33 */
34
35/**
36 * video palette data
37 * \see video_format_t
38 * \see subs_format_t
39 */
40#define VIDEO_PALETTE_COLORS_MAX 256
41#define VIDEO_PALETTE_CLUT_COUNT 16
43struct video_palette_t
45 int i_entries; /**< number of in-use palette entries */
46 uint8_t palette[VIDEO_PALETTE_COLORS_MAX][4]; /**< 4-byte RGBA/YUVA palette */
47};
48
49/**
50 * audio replay gain description
51 */
52#define AUDIO_REPLAY_GAIN_MAX (2)
53#define AUDIO_REPLAY_GAIN_TRACK (0)
54#define AUDIO_REPLAY_GAIN_ALBUM (1)
55typedef struct
57 /* true if we have the peak value */
58 bool pb_peak[AUDIO_REPLAY_GAIN_MAX];
59 /* peak value where 1.0 means full sample value */
60 float pf_peak[AUDIO_REPLAY_GAIN_MAX];
62 /* true if we have the gain value */
63 bool pb_gain[AUDIO_REPLAY_GAIN_MAX];
64 /* gain value in dB */
65 float pf_gain[AUDIO_REPLAY_GAIN_MAX];
67
68
69/**
70 * Audio channel type
71 */
72typedef enum audio_channel_type_t
78/**
79 * audio format description
80 */
81struct audio_format_t
83 vlc_fourcc_t i_format; /**< audio format fourcc */
84 unsigned int i_rate; /**< audio sample-rate */
86 /* Describes the channels configuration of the samples (ie. number of
87 * channels which are available in the buffer, and positions). */
88 uint16_t i_physical_channels;
90 /* Describes the chan mode, either set from the input
91 * (demux/codec/packetizer) or overridden by the user, used by audio
92 * filters. */
93 uint16_t i_chan_mode;
95 /* Channel type */
98 /* Optional - for A/52, SPDIF and DTS types : */
99 /* Bytes used by one compressed frame, depends on bitrate. */
100 unsigned int i_bytes_per_frame;
102 /* Number of sampleframes contained in one compressed frame. */
103 unsigned int i_frame_length;
104 /* Please note that it may be completely arbitrary - buffers are not
105 * obliged to contain a integral number of so-called "frames". It's
106 * just here for the division :
107 * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length
108 */
109
110 /* FIXME ? (used by the codecs) */
111 unsigned i_bitspersample;
112 unsigned i_blockalign;
113 uint8_t i_channels; /* must be <=32 */
115
116/* Values available for audio channels */
117#define AOUT_CHAN_CENTER 0x1
118#define AOUT_CHAN_LEFT 0x2
119#define AOUT_CHAN_RIGHT 0x4
120#define AOUT_CHAN_REARCENTER 0x10
121#define AOUT_CHAN_REARLEFT 0x20
122#define AOUT_CHAN_REARRIGHT 0x40
123#define AOUT_CHAN_MIDDLELEFT 0x100
124#define AOUT_CHAN_MIDDLERIGHT 0x200
125#define AOUT_CHAN_LFE 0x1000
127#define AOUT_CHANS_FRONT (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)
128#define AOUT_CHANS_MIDDLE (AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT)
129#define AOUT_CHANS_REAR (AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT)
130#define AOUT_CHANS_CENTER (AOUT_CHAN_CENTER | AOUT_CHAN_REARCENTER)
132#define AOUT_CHANS_STEREO AOUT_CHANS_2_0
133#define AOUT_CHANS_2_0 (AOUT_CHANS_FRONT)
134#define AOUT_CHANS_2_1 (AOUT_CHANS_FRONT | AOUT_CHAN_LFE)
135#define AOUT_CHANS_3_0 (AOUT_CHANS_FRONT | AOUT_CHAN_CENTER)
136#define AOUT_CHANS_3_1 (AOUT_CHANS_3_0 | AOUT_CHAN_LFE)
137#define AOUT_CHANS_4_0 (AOUT_CHANS_FRONT | AOUT_CHANS_REAR)
138#define AOUT_CHANS_4_1 (AOUT_CHANS_4_0 | AOUT_CHAN_LFE)
139#define AOUT_CHANS_5_0 (AOUT_CHANS_4_0 | AOUT_CHAN_CENTER)
140#define AOUT_CHANS_5_1 (AOUT_CHANS_5_0 | AOUT_CHAN_LFE)
141#define AOUT_CHANS_6_0 (AOUT_CHANS_4_0 | AOUT_CHANS_MIDDLE)
142#define AOUT_CHANS_7_0 (AOUT_CHANS_6_0 | AOUT_CHAN_CENTER)
143#define AOUT_CHANS_7_1 (AOUT_CHANS_5_1 | AOUT_CHANS_MIDDLE)
144#define AOUT_CHANS_8_1 (AOUT_CHANS_7_1 | AOUT_CHAN_REARCENTER)
146#define AOUT_CHANS_4_0_MIDDLE (AOUT_CHANS_FRONT | AOUT_CHANS_MIDDLE)
147#define AOUT_CHANS_4_CENTER_REAR (AOUT_CHANS_FRONT | AOUT_CHANS_CENTER)
148#define AOUT_CHANS_5_0_MIDDLE (AOUT_CHANS_4_0_MIDDLE | AOUT_CHAN_CENTER)
149#define AOUT_CHANS_6_1_MIDDLE (AOUT_CHANS_5_0_MIDDLE | AOUT_CHAN_REARCENTER | AOUT_CHAN_LFE)
151/* Maximum number of mapped channels (or the maximum of bits set in
152 * i_physical_channels) */
153#define AOUT_CHAN_MAX 9
154/* Maximum number of unmapped channels */
155#define INPUT_CHAN_MAX 64
157static const uint16_t vlc_chan_maps[] =
171/* Values available for i_chan_mode only */
172#define AOUT_CHANMODE_DUALMONO 0x1
173#define AOUT_CHANMODE_DOLBYSTEREO 0x2
174#define AOUT_CHANMODE_BINAURAL 0x4
176/**
177 * Picture orientation.
178 */
179typedef enum video_orientation_t
181 ORIENT_TOP_LEFT = 0, /**< Top line represents top, left column left. */
182 ORIENT_TOP_RIGHT, /**< Flipped horizontally */
183 ORIENT_BOTTOM_LEFT, /**< Flipped vertically */
184 ORIENT_BOTTOM_RIGHT, /**< Rotated 180 degrees */
185 ORIENT_LEFT_TOP, /**< Transposed */
186 ORIENT_LEFT_BOTTOM, /**< Rotated 90 degrees anti-clockwise */
187 ORIENT_RIGHT_TOP, /**< Rotated 90 degrees clockwise */
188 ORIENT_RIGHT_BOTTOM, /**< Anti-transposed */
189#define ORIENT_MAX ((size_t)ORIENT_RIGHT_BOTTOM)
200/** Convert EXIF orientation to enum video_orientation_t */
201#define ORIENT_FROM_EXIF(exif) ((0x57642310U >> (4 * ((exif) - 1))) & 7)
202/** Convert enum video_orientation_t to EXIF */
203#define ORIENT_TO_EXIF(orient) ((0x76853421U >> (4 * (orient))) & 15)
204/** If the orientation is natural or mirrored */
205#define ORIENT_IS_MIRROR(orient) vlc_parity(orient)
206/** If the orientation swaps dimensions */
207#define ORIENT_IS_SWAP(orient) (((orient) & 4) != 0)
208/** Applies horizontal flip to an orientation */
209#define ORIENT_HFLIP(orient) ((orient) ^ 1)
210/** Applies vertical flip to an orientation */
211#define ORIENT_VFLIP(orient) ((orient) ^ 2)
212/** Applies 180 degree rotation to an orientation */
213#define ORIENT_ROTATE_180(orient) ((orient) ^ 3)
215VLC_API void
217
218typedef enum video_transform_t
230typedef enum video_multiview_mode_t
232 /* No stereoscopy: 2D picture. */
233 MULTIVIEW_2D = 0,
235 /* Side-by-side with left eye first. */
238 /* Top-bottom with left eye first. */
241 /* Row sequential with left eye first. */
244 /* Column sequential with left eye first. */
247 /* Frame sequential with left eye first. */
250 /* Checkerboard pattern with left eye first. */
253#define MULTIVIEW_STEREO_MAX MULTIVIEW_STEREO_CHECKERBOARD
256/**
257 * Video projection mode.
258 */
259typedef enum video_projection_mode_t
267/**
268 * Video color primaries (a.k.a. chromacities)
269 */
270typedef enum video_color_primaries_t
279#define COLOR_PRIMARIES_SRGB COLOR_PRIMARIES_BT709
280#define COLOR_PRIMARIES_SMTPE_170 COLOR_PRIMARIES_BT601_525
281#define COLOR_PRIMARIES_SMTPE_240 COLOR_PRIMARIES_BT601_525 /* Only differs from 1e10-4 in white Y */
282#define COLOR_PRIMARIES_SMTPE_RP145 COLOR_PRIMARIES_BT601_525
283#define COLOR_PRIMARIES_EBU_3213 COLOR_PRIMARIES_BT601_625
284#define COLOR_PRIMARIES_BT470_BG COLOR_PRIMARIES_BT601_625
285#define COLOR_PRIMARIES_BT470_M COLOR_PRIMARIES_FCC1953
286#define COLOR_PRIMARIES_MAX COLOR_PRIMARIES_FCC1953
289/**
290 * Video transfer functions
291 */
292typedef enum video_transfer_func_t
296 TRANSFER_FUNC_SRGB /**< Gamma 2.2 */,
303#define TRANSFER_FUNC_BT2020 TRANSFER_FUNC_BT709
304#define TRANSFER_FUNC_SMPTE_170 TRANSFER_FUNC_BT709
305#define TRANSFER_FUNC_SMPTE_274 TRANSFER_FUNC_BT709
306#define TRANSFER_FUNC_SMPTE_293 TRANSFER_FUNC_BT709
307#define TRANSFER_FUNC_SMPTE_296 TRANSFER_FUNC_BT709
308#define TRANSFER_FUNC_ARIB_B67 TRANSFER_FUNC_HLG
309#define TRANSFER_FUNC_MAX TRANSFER_FUNC_HLG
312/**
313 * Video color space (i.e. YCbCr matrices)
314 */
315typedef enum video_color_space_t
321#define COLOR_SPACE_SRGB COLOR_SPACE_BT709
322#define COLOR_SPACE_SMPTE_170 COLOR_SPACE_BT601
323#define COLOR_SPACE_SMPTE_240 COLOR_SPACE_SMPTE_170
324#define COLOR_SPACE_MAX COLOR_SPACE_BT2020
327/**
328 * Video chroma location
329 */
330typedef enum video_chroma_location_t
333 CHROMA_LOCATION_LEFT, /**< Most common in MPEG-2 Video, H.264/265 */
334 CHROMA_LOCATION_CENTER, /**< Most common in MPEG-1 Video, JPEG */
339#define CHROMA_LOCATION_MAX CHROMA_LOCATION_BOTTOM_CENTER
342typedef enum video_color_range_t
347#define COLOR_RANGE_STUDIO COLOR_RANGE_LIMITED
348#define COLOR_RANGE_MAX COLOR_RANGE_LIMITED
351/**
352 * video format description
353 */
354struct video_format_t
356 vlc_fourcc_t i_chroma; /**< picture chroma */
358 unsigned int i_width; /**< picture width */
359 unsigned int i_height; /**< picture height */
360 unsigned int i_x_offset; /**< start offset of visible area */
361 unsigned int i_y_offset; /**< start offset of visible area */
362 unsigned int i_visible_width; /**< width of visible area */
363 unsigned int i_visible_height; /**< height of visible area */
365 unsigned int i_sar_num; /**< sample/pixel aspect ratio */
366 unsigned int i_sar_den;
368 unsigned int i_frame_rate; /**< frame rate numerator */
369 unsigned int i_frame_rate_base; /**< frame rate denominator */
371 video_palette_t *p_palette; /**< video palette from demuxer */
372 video_orientation_t orientation; /**< picture orientation */
373 video_color_primaries_t primaries; /**< color primaries */
374 video_transfer_func_t transfer; /**< transfer function */
375 video_color_space_t space; /**< YCbCr color space */
376 video_color_range_t color_range; /**< 0-255 instead of 16-235 */
377 video_chroma_location_t chroma_location; /**< YCbCr chroma location */
379 video_multiview_mode_t multiview_mode; /** Multiview mode, 2D, 3D */
380 bool b_multiview_right_eye_first; /** Multiview left or right eye first*/
382 video_projection_mode_t projection_mode; /**< projection mode */
384 struct {
385 /* similar to SMPTE ST 2086 mastering display color volume */
386 uint16_t primaries[3*2]; /* G,B,R / x,y */
387 uint16_t white_point[2]; /* x,y */
391 struct {
392 /* similar to CTA-861.3 content light level */
393 uint16_t MaxCLL; /* max content light level */
394 uint16_t MaxFALL; /* max frame average light level */
396 struct {
397 uint8_t version_major;
399 unsigned profile : 7;
400 unsigned level : 6;
401 unsigned rpu_present : 1;
402 unsigned el_present : 1;
403 unsigned bl_present : 1;
405 uint32_t i_cubemap_padding; /**< padding in pixels of the cube map faces */
407
408/**
409 * Initialize a video_format_t structure with chroma 'i_chroma'
410 * \param p_src pointer to video_format_t structure
411 * \param i_chroma chroma value to use
412 */
413static inline void video_format_Init( video_format_t *p_src, vlc_fourcc_t i_chroma )
415 memset( p_src, 0, sizeof( video_format_t ) );
416 p_src->i_chroma = i_chroma;
417 vlc_viewpoint_init( &p_src->pose );
418}
419
420/**
421 * Copy video_format_t including the palette
422 * \param p_dst video_format_t to copy to
423 * \param p_src video_format_t to copy from
424 */
425static inline int video_format_Copy( video_format_t *p_dst, const video_format_t *p_src )
427 memcpy( p_dst, p_src, sizeof( *p_dst ) );
428 if( p_src->p_palette )
429 {
430 p_dst->p_palette = (video_palette_t *) malloc( sizeof( video_palette_t ) );
431 if( !p_dst->p_palette )
432 return VLC_ENOMEM;
433 memcpy( p_dst->p_palette, p_src->p_palette, sizeof( *p_dst->p_palette ) );
434 }
435 return VLC_SUCCESS;
436}
437
438static inline void video_format_AdjustColorSpace( video_format_t *p_fmt )
440 if ( p_fmt->primaries == COLOR_PRIMARIES_UNDEF )
441 {
442 if ( p_fmt->i_visible_height > 576 ) // HD
444 else if ( p_fmt->i_visible_height > 525 ) // PAL
446 else
448 }
449
450 if ( p_fmt->transfer == TRANSFER_FUNC_UNDEF )
451 {
452 if ( p_fmt->i_visible_height > 576 ) // HD
454 else
456 }
457
458 if ( p_fmt->space == COLOR_SPACE_UNDEF )
459 {
460 if ( p_fmt->i_visible_height > 576 ) // HD
461 p_fmt->space = COLOR_SPACE_BT709;
462 else
463 p_fmt->space = COLOR_SPACE_BT601;
464 }
465
466 if ( p_fmt->color_range == COLOR_RANGE_UNDEF )
467 {
468 if ( vlc_fourcc_IsYUV(p_fmt->i_chroma) )
470 else
472 }
473}
474
475/**
476 * Cleanup and free palette of this video_format_t
477 * \param p_src video_format_t structure to clean
478 */
479static inline void video_format_Clean( video_format_t *p_src )
481 free( p_src->p_palette );
482 memset( p_src, 0, sizeof( video_format_t ) );
483}
484
485/**
486 * It will fill up a video_format_t using the given arguments.
487 * Note that the video_format_t must already be initialized.
488 */
490 int i_width, int i_height, int i_visible_width, int i_visible_height,
491 int i_sar_num, int i_sar_den );
492
493/**
494 * It will copy the crop properties from a video_format_t to another.
495 */
497
498static inline void video_format_CopyCropAr(video_format_t *dst,
499 const video_format_t *src)
500{
501 video_format_CopyCrop(dst, src);
502 dst->i_sar_num = src->i_sar_num;
503 dst->i_sar_den = src->i_sar_den;
504}
505
506/**
507 * It will compute the crop/ar properties when scaling.
508 */
510
511/**
512 * This function "normalizes" the formats orientation, by switching the a/r according to the orientation,
513 * producing a format whose orientation is ORIENT_NORMAL. It makes a shallow copy (palette is not alloc'ed).
514 */
516 const video_format_t *in);
517
518/**
519 * This function applies the transform operation to fmt.
520 */
522
523/**
524 * This function applies the transforms necessary to fmt so that the resulting fmt
525 * has the dst_orientation.
526 */
529/**
530 * Returns the operation required to transform src into dst.
531 */
533
534/**
535 * This function will check if the first video format is similar
536 * to the second one.
537 */
539
540/** Checks whether the video formats have the same chroma and mask */
542
543/**
544 * It prints details about the given video_format_t
545 */
546VLC_API void video_format_Print( vlc_object_t *, const char *, const video_format_t * );
547
548
551 switch ( transform ) {
552 case TRANSFORM_R90:
553 return TRANSFORM_R270;
554 case TRANSFORM_R270:
555 return TRANSFORM_R90;
556 default:
557 return transform;
558 }
559}
560
561
562/**
563 * subtitles format description
564 */
565struct subs_format_t
567 /* the character encoding of the text of the subtitle.
568 * all gettext recognized shorts can be used */
569 char *psz_encoding;
571
572 int i_x_origin; /**< x coordinate of the subtitle. 0 = left */
573 int i_y_origin; /**< y coordinate of the subtitle. 0 = top */
575 struct
576 {
577 /* the width of the original movie the spu was extracted from */
578 unsigned i_original_frame_width;
579 /* the height of the original movie the spu was extracted from */
582 /* */
583 uint32_t palette[VIDEO_PALETTE_CLUT_COUNT]; /* CLUT Palette AYVU */
587 struct
588 {
589 int i_id;
591 struct
592 {
593 uint8_t i_magazine; /* magazine value (3 bits), > 8 for any */
594 uint8_t i_page; /* BCD packet address value (4+4 bits) */
596 struct
597 {
598 uint8_t i_channel;
599 /* Reorder depth of transport video, -1 for no reordering */
600 int i_reorder_depth;
601 } cc;
603
604/**
605 * ES language definition
606 */
607typedef struct extra_languages_t
613/** ES Categories */
616 UNKNOWN_ES = 0x00,
622#define ES_CATEGORY_COUNT (DATA_ES + 1)
624/**
625 * ES format definition
626 */
627#define ES_PRIORITY_NOT_SELECTABLE -2
628#define ES_PRIORITY_NOT_DEFAULTABLE -1
629#define ES_PRIORITY_SELECTABLE_MIN 0
630#define ES_PRIORITY_MIN ES_PRIORITY_NOT_SELECTABLE
633 enum es_format_category_e i_cat; /**< ES category */
634 vlc_fourcc_t i_codec; /**< FOURCC value as used in vlc */
635 vlc_fourcc_t i_original_fourcc; /**< original FOURCC from the container */
637 int i_id; /**< es identifier, where means
638 -1: let the core mark the right id
639 >=0: valid id */
640 int i_group; /**< group identifier, where means:
641 -1 : standalone
642 >= 0 then a "group" (program) is created
643 for each value */
644 int i_priority; /**< priority, where means:
645 -2 : mean not selectable by the users
646 -1 : mean not selected by default even
647 when no other stream
648 >=0: priority */
649
650 char *psz_language; /**< human-readable language name */
651 char *psz_description; /**< human-readable description of language */
652 unsigned i_extra_languages; /**< length in bytes of extra language data pointer */
653 extra_languages_t *p_extra_languages; /**< extra language data needed by some decoders */
655 union {
656 struct {
657 audio_format_t audio; /**< description of audio format */
658 audio_replay_gain_t audio_replay_gain; /**< audio replay gain information */
659 };
660 video_format_t video; /**< description of video format */
661 subs_format_t subs; /**< description of subtitle format */
662 };
663
664 unsigned int i_bitrate; /**< bitrate of this ES */
665 int i_profile; /**< codec specific information (like real audio flavor, mpeg audio layer, h264 profile ...) */
666 int i_level; /**< codec specific information: indicates maximum restrictions on the stream (resolution, bitrate, codec features ...) */
668 bool b_packetized; /**< whether the data is packetized (ie. not truncated) */
669 int i_extra; /**< length in bytes of extra data pointer */
670 void *p_extra; /**< extra data needed by some decoders or muxers */
672};
673
674/**
675 * This function will initialize a es_format_t structure.
676 */
678
679/**
680 * This function will initialize a es_format_t structure from a video_format_t.
681 */
683
684/**
685 * This functions will copy a es_format_t.
686 */
687VLC_API int es_format_Copy( es_format_t *p_dst, const es_format_t *p_src );
689/**
690 * This function will clean up a es_format_t and release all associated
691 * resources.
692 * You can call it multiple times on the same structure.
693 */
695
696/**
697 * This function will check if the first ES format is similar
698 * to the second one.
699 *
700 * All descriptive fields are ignored.
701 */
702VLC_API bool es_format_IsSimilar( const es_format_t *, const es_format_t * );
703
704/**
705 * Log differences between 2 ES format.
706 * The difference checks the same fields as \ref es_format_IsSimilar
707 */
709 const char *name_a, const es_format_t *a,
710 const char *name_b, const es_format_t *b);
711/**
712 * Log differences between 2 video format.
713 * The difference checks the same fields as \ref video_format_IsSimilar
714 */
716 const char *name_a, const video_format_t *a,
717 const char *name_b, const video_format_t *b);
718
719/**
720 * Changes ES format to another category
721 * Format must have been properly initialized
722 */
723static inline void es_format_Change( es_format_t *fmt, int i_cat, vlc_fourcc_t i_codec )
725 es_format_Clean( fmt );
726 es_format_Init( fmt, i_cat, i_codec );
727}
728
729/**
730 * Increase the ES track id reference count.
731 *
732 * Any held ES tracks must be released with vlc_es_id_Release().
733 *
734 * @param es pointer to the ES id
735 * @return the same ES pointer, for convenience
736 */
739
740/**
741 * Decrease the ES track id reference count.
742 *
743 * @param id pointer to the ES track id
744 */
745VLC_API void
747
748/**
749 * Get the ES track input id
750 *
751 * @param id pointer to the ES track id
752 * @return the ES track input id (always valid)
753 */
754VLC_API int
756
757/**
758 * Return whether the ES track identifier is stable
759 *
760 * An string identifier is stable when it is certified to be the same across
761 * different playback instances for the same ES track.
762 *
763 * @param id pointer to the ES track id
764 * @return true if stable
765 */
766VLC_API bool
768
769/**
770 * Get the unique string identifier
771 *
772 * This id could be used to identify a track across different playback
773 * instances. For example, it can be used to store a track selection
774 * preference in a database.
775 *
776 * @warning Check with vlc_es_id_IsStrIdStable() if the ES track is stable
777 * before saving it for a future usage.
778 *
779 * @param id pointer to the ES track id
780 * @return the ES track string identifier, can't be NULL, valid until id is
781 * released
782 */
783VLC_API const char *
785
786/**
787 * Get the ES category
788 *
789 * @param id pointer to the ES track id
790 * @return the es track category (always valid)
791 */
794
795/**
796 * Get the native endianness mask for a RGB fourcc
797 *
798 * @note the alpha mask is 0 when the chroma doesn't contain an alpha component.
799 *
800 * @return VLC_SUCCESS if the mask values were filled
801 */
802static inline int vlc_RGBChromaToMask( vlc_fourcc_t fcc, uint32_t *rmask,
803 uint32_t *gmask, uint32_t *bmask,
804 uint32_t *amask )
805{
806 switch(fcc)
807 {
808 case VLC_CODEC_BGRA:
809 *bmask = 0xff000000;
810 *gmask = 0x00ff0000;
811 *rmask = 0x0000ff00;
812 *amask = 0x000000ff;
813 break;
814 case VLC_CODEC_BGRX:
815 *bmask = 0xff000000;
816 *gmask = 0x00ff0000;
817 *rmask = 0x0000ff00;
818 *amask = 0;
819 break;
820 case VLC_CODEC_RGBA:
821 *rmask = 0xff000000;
822 *gmask = 0x00ff0000;
823 *bmask = 0x0000ff00;
824 *amask = 0x000000ff;
825 break;
826 case VLC_CODEC_RGBX:
827 *rmask = 0xff000000;
828 *gmask = 0x00ff0000;
829 *bmask = 0x0000ff00;
830 *amask = 0;
831 break;
832 case VLC_CODEC_ABGR:
833 *amask = 0xff000000;
834 *bmask = 0x00ff0000;
835 *gmask = 0x0000ff00;
836 *rmask = 0x000000ff;
837 break;
838 case VLC_CODEC_XBGR:
839 *amask = 0;
840 *bmask = 0x00ff0000;
841 *gmask = 0x0000ff00;
842 *rmask = 0x000000ff;
843 break;
844 case VLC_CODEC_ARGB:
845 *amask = 0xff000000;
846 *rmask = 0x00ff0000;
847 *gmask = 0x0000ff00;
848 *bmask = 0x000000ff;
849 break;
850 case VLC_CODEC_XRGB:
851 *amask = 0;
852 *rmask = 0x00ff0000;
853 *gmask = 0x0000ff00;
854 *bmask = 0x000000ff;
855 break;
856 default:
857 return VLC_EINVAL;
858 }
859 return VLC_SUCCESS;
860}
861
862#endif
bool vlc_fourcc_IsYUV(vlc_fourcc_t fcc)
It returns true if the given fourcc is YUV and false otherwise.
Definition fourcc.c:660
#define VLC_API
Definition fourcc_gen.c:31
uint32_t vlc_fourcc_t
Definition fourcc_gen.c:33
#define VLC_EINVAL
Bad variable value.
Definition vlc_common.h:488
#define VLC_ENOMEM
Not enough memory.
Definition vlc_common.h:482
#define VLC_SUCCESS
No error.
Definition vlc_common.h:478
vlc_fourcc_t i_codec
Definition image.c:568
static void transform(MD5_CONTEXT *ctx, const unsigned char *data)
Definition md5.c:84
audio format description
Definition vlc_es.h:83
unsigned int i_rate
audio sample-rate
Definition vlc_es.h:85
uint8_t i_channels
Definition vlc_es.h:114
unsigned i_blockalign
Definition vlc_es.h:113
unsigned int i_frame_length
Definition vlc_es.h:104
unsigned int i_bytes_per_frame
Definition vlc_es.h:101
audio_channel_type_t channel_type
Definition vlc_es.h:97
unsigned i_bitspersample
Definition vlc_es.h:112
uint16_t i_chan_mode
Definition vlc_es.h:94
uint16_t i_physical_channels
Definition vlc_es.h:89
vlc_fourcc_t i_format
audio format fourcc
Definition vlc_es.h:84
Definition vlc_es.h:57
Definition vlc_es.h:633
char * psz_description
human-readable description of language
Definition vlc_es.h:652
int i_level
codec specific information: indicates maximum restrictions on the stream (resolution,...
Definition vlc_es.h:667
int i_id
es identifier, where means -1: let the core mark the right id >=0: valid id
Definition vlc_es.h:638
int i_profile
codec specific information (like real audio flavor, mpeg audio layer, h264 profile ....
Definition vlc_es.h:666
audio_format_t audio
description of audio format
Definition vlc_es.h:658
int i_group
group identifier, where means: -1 : standalone >= 0 then a "group" (program) is created for each valu...
Definition vlc_es.h:641
enum es_format_category_e i_cat
ES category.
Definition vlc_es.h:634
video_format_t video
description of video format
Definition vlc_es.h:661
int i_priority
priority, where means: -2 : mean not selectable by the users -1 : mean not selected by default even w...
Definition vlc_es.h:645
int i_extra
length in bytes of extra data pointer
Definition vlc_es.h:670
bool b_packetized
whether the data is packetized (ie.
Definition vlc_es.h:669
audio_replay_gain_t audio_replay_gain
audio replay gain information
Definition vlc_es.h:659
extra_languages_t * p_extra_languages
extra language data needed by some decoders
Definition vlc_es.h:654
void * p_extra
extra data needed by some decoders or muxers
Definition vlc_es.h:671
subs_format_t subs
description of subtitle format
Definition vlc_es.h:662
unsigned int i_bitrate
bitrate of this ES
Definition vlc_es.h:665
vlc_fourcc_t i_codec
FOURCC value as used in vlc.
Definition vlc_es.h:635
char * psz_language
human-readable language name
Definition vlc_es.h:651
vlc_fourcc_t i_original_fourcc
original FOURCC from the container
Definition vlc_es.h:636
unsigned i_extra_languages
length in bytes of extra language data pointer
Definition vlc_es.h:653
ES language definition.
Definition vlc_es.h:609
char * psz_description
Definition vlc_es.h:611
char * psz_language
Definition vlc_es.h:610
subtitles format description
Definition vlc_es.h:567
int i_x_origin
x coordinate of the subtitle.
Definition vlc_es.h:573
struct subs_format_t::@212 dvb
struct subs_format_t::@213 teletext
int i_reorder_depth
Definition vlc_es.h:601
char * psz_encoding
Definition vlc_es.h:570
bool b_palette
Definition vlc_es.h:585
uint8_t i_magazine
Definition vlc_es.h:594
int i_y_origin
y coordinate of the subtitle.
Definition vlc_es.h:574
int i_id
Definition vlc_es.h:590
struct subs_format_t::@214 cc
uint32_t palette[16]
Definition vlc_es.h:584
uint8_t i_page
Definition vlc_es.h:595
uint8_t i_channel
Definition vlc_es.h:599
unsigned i_original_frame_width
Definition vlc_es.h:579
struct subs_format_t::@211 spu
unsigned i_original_frame_height
Definition vlc_es.h:581
video format description
Definition vlc_es.h:356
video_color_range_t color_range
0-255 instead of 16-235
Definition vlc_es.h:377
video_projection_mode_t projection_mode
Multiview left or right eye first.
Definition vlc_es.h:383
unsigned int i_height
picture height
Definition vlc_es.h:360
unsigned int i_y_offset
start offset of visible area
Definition vlc_es.h:362
unsigned int i_visible_width
width of visible area
Definition vlc_es.h:363
struct video_format_t::@208 mastering
unsigned int i_sar_den
Definition vlc_es.h:367
uint16_t MaxCLL
Definition vlc_es.h:394
unsigned int i_frame_rate
frame rate numerator
Definition vlc_es.h:369
unsigned el_present
Definition vlc_es.h:403
video_orientation_t orientation
picture orientation
Definition vlc_es.h:373
struct video_format_t::@210 dovi
uint32_t max_luminance
Definition vlc_es.h:389
video_palette_t * p_palette
video palette from demuxer
Definition vlc_es.h:372
struct video_format_t::@209 lighting
bool b_multiview_right_eye_first
Multiview mode, 2D, 3D.
Definition vlc_es.h:381
video_color_space_t space
YCbCr color space.
Definition vlc_es.h:376
unsigned rpu_present
Definition vlc_es.h:402
vlc_viewpoint_t pose
Definition vlc_es.h:384
uint8_t version_minor
Definition vlc_es.h:399
unsigned level
Definition vlc_es.h:401
unsigned int i_x_offset
start offset of visible area
Definition vlc_es.h:361
uint8_t version_major
Definition vlc_es.h:398
unsigned bl_present
Definition vlc_es.h:404
video_multiview_mode_t multiview_mode
Definition vlc_es.h:380
unsigned profile
Definition vlc_es.h:400
unsigned int i_width
picture width
Definition vlc_es.h:359
unsigned int i_visible_height
height of visible area
Definition vlc_es.h:364
uint32_t i_cubemap_padding
padding in pixels of the cube map faces
Definition vlc_es.h:406
uint16_t MaxFALL
Definition vlc_es.h:395
uint16_t white_point[2]
Definition vlc_es.h:388
unsigned int i_sar_num
sample/pixel aspect ratio
Definition vlc_es.h:366
unsigned int i_frame_rate_base
frame rate denominator
Definition vlc_es.h:370
video_chroma_location_t chroma_location
YCbCr chroma location.
Definition vlc_es.h:378
uint32_t min_luminance
Definition vlc_es.h:390
vlc_fourcc_t i_chroma
picture chroma
Definition vlc_es.h:357
video_color_primaries_t primaries
color primaries
Definition vlc_es.h:374
video_transfer_func_t transfer
transfer function
Definition vlc_es.h:375
Definition vlc_es.h:45
int i_entries
number of in-use palette entries
Definition vlc_es.h:46
uint8_t palette[256][4]
4-byte RGBA/YUVA palette
Definition vlc_es.h:47
Opaque structure representing an ES (Elementary Stream) track.
Definition es_out.c:104
Definition messages.c:85
VLC object common members.
Definition vlc_objects.h:53
Viewpoints.
Definition vlc_viewpoint.h:41
This file is a collection of common definitions and types.
static video_transform_t transform_Inverse(video_transform_t transform)
Definition vlc_es.h:550
video_projection_mode_t
Video projection mode.
Definition vlc_es.h:261
@ PROJECTION_MODE_EQUIRECTANGULAR
Definition vlc_es.h:263
@ PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD
Definition vlc_es.h:265
@ PROJECTION_MODE_RECTANGULAR
Definition vlc_es.h:262
video_chroma_location_t
Video chroma location.
Definition vlc_es.h:332
@ CHROMA_LOCATION_CENTER
Most common in MPEG-1 Video, JPEG.
Definition vlc_es.h:335
@ CHROMA_LOCATION_TOP_LEFT
Definition vlc_es.h:336
@ CHROMA_LOCATION_LEFT
Most common in MPEG-2 Video, H.264/265.
Definition vlc_es.h:334
@ CHROMA_LOCATION_UNDEF
Definition vlc_es.h:333
@ CHROMA_LOCATION_TOP_CENTER
Definition vlc_es.h:337
@ CHROMA_LOCATION_BOTTOM_CENTER
Definition vlc_es.h:339
@ CHROMA_LOCATION_BOTTOM_LEFT
Definition vlc_es.h:338
#define AOUT_CHANS_7_0
Definition vlc_es.h:143
video_color_space_t
Video color space (i.e.
Definition vlc_es.h:317
@ COLOR_SPACE_BT2020
Definition vlc_es.h:321
@ COLOR_SPACE_BT601
Definition vlc_es.h:319
@ COLOR_SPACE_BT709
Definition vlc_es.h:320
@ COLOR_SPACE_UNDEF
Definition vlc_es.h:318
#define AOUT_CHANS_5_0
Definition vlc_es.h:140
bool video_format_IsSimilar(const video_format_t *, const video_format_t *)
This function will check if the first video format is similar to the second one.
Definition es_format.c:218
es_format_category_e
ES Categories.
Definition vlc_es.h:616
@ SPU_ES
Definition vlc_es.h:620
@ UNKNOWN_ES
Definition vlc_es.h:617
@ DATA_ES
Definition vlc_es.h:621
@ AUDIO_ES
Definition vlc_es.h:619
@ VIDEO_ES
Definition vlc_es.h:618
#define AOUT_CHANS_3_0
Definition vlc_es.h:136
void es_format_Init(es_format_t *, int i_cat, vlc_fourcc_t i_codec)
This function will initialize a es_format_t structure.
Definition es_format.c:301
void video_format_ScaleCropAr(video_format_t *, const video_format_t *)
It will compute the crop/ar properties when scaling.
Definition es_format.c:61
video_orientation_t
Picture orientation.
Definition vlc_es.h:181
@ ORIENT_NORMAL
Definition vlc_es.h:192
@ ORIENT_LEFT_TOP
Transposed.
Definition vlc_es.h:186
@ ORIENT_RIGHT_TOP
Rotated 90 degrees clockwise.
Definition vlc_es.h:188
@ ORIENT_VFLIPPED
Definition vlc_es.h:196
@ ORIENT_ROTATED_180
Definition vlc_es.h:197
@ ORIENT_ANTI_TRANSPOSED
Definition vlc_es.h:194
@ ORIENT_RIGHT_BOTTOM
Anti-transposed.
Definition vlc_es.h:189
@ ORIENT_ROTATED_270
Definition vlc_es.h:198
@ ORIENT_TRANSPOSED
Definition vlc_es.h:193
@ ORIENT_BOTTOM_RIGHT
Rotated 180 degrees.
Definition vlc_es.h:185
@ ORIENT_TOP_RIGHT
Flipped horizontally.
Definition vlc_es.h:183
@ ORIENT_HFLIPPED
Definition vlc_es.h:195
@ ORIENT_ROTATED_90
Definition vlc_es.h:199
@ ORIENT_LEFT_BOTTOM
Rotated 90 degrees anti-clockwise.
Definition vlc_es.h:187
@ ORIENT_BOTTOM_LEFT
Flipped vertically.
Definition vlc_es.h:184
@ ORIENT_TOP_LEFT
Top line represents top, left column left.
Definition vlc_es.h:182
#define AOUT_CHANS_8_1
Definition vlc_es.h:145
vlc_es_id_t * vlc_es_id_Hold(vlc_es_id_t *es)
Increase the ES track id reference count.
Definition es_out.c:4657
void video_format_ApplyRotation(video_format_t *out, const video_format_t *in)
This function "normalizes" the formats orientation, by switching the a/r according to the orientation...
void video_format_Print(vlc_object_t *, const char *, const video_format_t *)
It prints details about the given video_format_t.
Definition es_format.c:283
const char * vlc_es_id_GetStrId(vlc_es_id_t *id)
Get the unique string identifier.
Definition es_out.c:4682
bool es_format_IsSimilar(const es_format_t *, const es_format_t *)
This function will check if the first ES format is similar to the second one.
Definition es_format.c:424
static void video_format_Init(video_format_t *p_src, vlc_fourcc_t i_chroma)
Initialize a video_format_t structure with chroma 'i_chroma'.
Definition vlc_es.h:414
audio_channel_type_t
Audio channel type.
Definition vlc_es.h:74
@ AUDIO_CHANNEL_TYPE_AMBISONICS
Definition vlc_es.h:76
@ AUDIO_CHANNEL_TYPE_BITMAP
Definition vlc_es.h:75
void video_format_CopyCrop(video_format_t *, const video_format_t *)
It will copy the crop properties from a video_format_t to another.
Definition es_format.c:53
video_multiview_mode_t
Definition vlc_es.h:232
@ MULTIVIEW_STEREO_TB
Definition vlc_es.h:240
@ MULTIVIEW_STEREO_ROW
Definition vlc_es.h:243
@ MULTIVIEW_STEREO_CHECKERBOARD
Definition vlc_es.h:252
@ MULTIVIEW_STEREO_SBS
Definition vlc_es.h:237
@ MULTIVIEW_2D
Definition vlc_es.h:234
@ MULTIVIEW_STEREO_COL
Definition vlc_es.h:246
@ MULTIVIEW_STEREO_FRAME
Definition vlc_es.h:249
video_color_range_t
Definition vlc_es.h:344
@ COLOR_RANGE_FULL
Definition vlc_es.h:346
@ COLOR_RANGE_LIMITED
Definition vlc_es.h:347
@ COLOR_RANGE_UNDEF
Definition vlc_es.h:345
void video_format_LogDifferences(struct vlc_logger *log, const char *name_a, const video_format_t *a, const char *name_b, const video_format_t *b)
Log differences between 2 video format.
Definition es_format.c:242
video_color_primaries_t
Video color primaries (a.k.a.
Definition vlc_es.h:272
@ COLOR_PRIMARIES_BT601_625
Definition vlc_es.h:275
@ COLOR_PRIMARIES_BT601_525
Definition vlc_es.h:274
@ COLOR_PRIMARIES_FCC1953
Definition vlc_es.h:279
@ COLOR_PRIMARIES_BT2020
Definition vlc_es.h:277
@ COLOR_PRIMARIES_DCI_P3
Definition vlc_es.h:278
@ COLOR_PRIMARIES_UNDEF
Definition vlc_es.h:273
@ COLOR_PRIMARIES_BT709
Definition vlc_es.h:276
enum es_format_category_e vlc_es_id_GetCat(vlc_es_id_t *id)
Get the ES category.
Definition es_out.c:4688
video_transfer_func_t
Video transfer functions.
Definition vlc_es.h:294
@ TRANSFER_FUNC_BT709
Definition vlc_es.h:300
@ TRANSFER_FUNC_LINEAR
Definition vlc_es.h:296
@ TRANSFER_FUNC_BT470_M
Definition vlc_es.h:299
@ TRANSFER_FUNC_SRGB
Gamma 2.2.
Definition vlc_es.h:297
@ TRANSFER_FUNC_UNDEF
Definition vlc_es.h:295
@ TRANSFER_FUNC_HLG
Definition vlc_es.h:303
@ TRANSFER_FUNC_SMPTE_240
Definition vlc_es.h:302
@ TRANSFER_FUNC_BT470_BG
Definition vlc_es.h:298
@ TRANSFER_FUNC_SMPTE_ST2084
Definition vlc_es.h:301
static void video_format_AdjustColorSpace(video_format_t *p_fmt)
Definition vlc_es.h:439
static int video_format_Copy(video_format_t *p_dst, const video_format_t *p_src)
Copy video_format_t including the palette.
Definition vlc_es.h:426
void video_format_TransformBy(video_format_t *fmt, video_transform_t transform)
This function applies the transform operation to fmt.
Definition es_format.c:140
#define AOUT_CHANS_5_1
Definition vlc_es.h:141
static const uint16_t vlc_chan_maps[]
Definition vlc_es.h:158
void video_format_Setup(video_format_t *, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_visible_width, int i_visible_height, int i_sar_num, int i_sar_den)
It will fill up a video_format_t using the given arguments.
Definition es_format.c:36
int es_format_Copy(es_format_t *p_dst, const es_format_t *p_src)
This functions will copy a es_format_t.
#define AOUT_CHANS_7_1
Definition vlc_es.h:144
void es_format_InitFromVideo(es_format_t *, const video_format_t *)
This function will initialize a es_format_t structure from a video_format_t.
Definition es_format.c:322
bool video_format_IsSameChroma(const video_format_t *, const video_format_t *)
Checks whether the video formats have the same chroma and mask.
Definition es_format.c:209
void es_format_Clean(es_format_t *fmt)
This function will clean up a es_format_t and release all associated resources.
Definition es_format.c:401
#define VIDEO_PALETTE_COLORS_MAX
video palette data
Definition vlc_es.h:41
bool vlc_es_id_IsStrIdStable(vlc_es_id_t *id)
Return whether the ES track identifier is stable.
Definition es_out.c:4676
static void es_format_Change(es_format_t *fmt, int i_cat, vlc_fourcc_t i_codec)
Changes ES format to another category Format must have been properly initialized.
Definition vlc_es.h:724
void es_format_LogDifferences(struct vlc_logger *, const char *name_a, const es_format_t *a, const char *name_b, const es_format_t *b)
Log differences between 2 ES format.
Definition es_format.c:471
#define AOUT_CHANS_4_0
Definition vlc_es.h:138
void video_format_TransformTo(video_format_t *fmt, video_orientation_t dst_orientation)
This function applies the transforms necessary to fmt so that the resulting fmt has the dst_orientati...
video_transform_t video_format_GetTransform(video_orientation_t src, video_orientation_t dst)
Returns the operation required to transform src into dst.
Definition es_format.c:124
void vlc_viewpoint_from_orientation(vlc_viewpoint_t *vp, video_orientation_t orient)
Definition viewpoint.c:74
void vlc_es_id_Release(vlc_es_id_t *id)
Decrease the ES track id reference count.
Definition es_out.c:4664
static void video_format_Clean(video_format_t *p_src)
Cleanup and free palette of this video_format_t.
Definition vlc_es.h:480
#define VIDEO_PALETTE_CLUT_COUNT
Definition vlc_es.h:42
static void video_format_CopyCropAr(video_format_t *dst, const video_format_t *src)
Definition vlc_es.h:499
static int vlc_RGBChromaToMask(vlc_fourcc_t fcc, uint32_t *rmask, uint32_t *gmask, uint32_t *bmask, uint32_t *amask)
Get the native endianness mask for a RGB fourcc.
Definition vlc_es.h:803
#define AOUT_CHANS_2_0
Definition vlc_es.h:134
#define AUDIO_REPLAY_GAIN_MAX
audio replay gain description
Definition vlc_es.h:53
video_transform_t
Definition vlc_es.h:220
@ TRANSFORM_HFLIP
Definition vlc_es.h:222
@ TRANSFORM_R180
Definition vlc_es.h:224
@ TRANSFORM_TRANSPOSE
Definition vlc_es.h:227
@ TRANSFORM_ANTI_TRANSPOSE
Definition vlc_es.h:228
@ TRANSFORM_R90
Definition vlc_es.h:226
@ TRANSFORM_VFLIP
Definition vlc_es.h:223
@ TRANSFORM_IDENTITY
Definition vlc_es.h:221
@ TRANSFORM_R270
Definition vlc_es.h:225
int vlc_es_id_GetInputId(vlc_es_id_t *id)
Get the ES track input id.
Definition es_out.c:4670
#define AOUT_CHAN_CENTER
Definition vlc_es.h:118
#define VLC_CODEC_RGBA
Definition vlc_fourcc.h:408
#define VLC_CODEC_XBGR
Definition vlc_fourcc.h:350
#define VLC_CODEC_ABGR
Definition vlc_fourcc.h:414
#define VLC_CODEC_BGRA
Definition vlc_fourcc.h:412
#define VLC_CODEC_ARGB
Definition vlc_fourcc.h:410
#define VLC_CODEC_RGBX
Definition vlc_fourcc.h:346
#define VLC_CODEC_XRGB
Definition vlc_fourcc.h:344
#define VLC_CODEC_BGRX
Definition vlc_fourcc.h:348
Video and audio viewpoint struct and helpers.
static void vlc_viewpoint_init(vlc_viewpoint_t *p_vp)
Definition vlc_viewpoint.h:48