FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/matroska.c
Date: 2022-12-05 20:26:17
Exec Total Coverage
Lines: 10 43 23.3%
Functions: 1 1 100.0%
Branches: 3 18 16.7%

Line Branch Exec Source
1 /*
2 * Matroska common data
3 * Copyright (c) 2003-2004 The FFmpeg project
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "libavutil/stereo3d.h"
23
24 #include "matroska.h"
25
26 /* If you add a tag here that is not in ff_codec_bmp_tags[]
27 or ff_codec_wav_tags[], add it also to additional_audio_tags[]
28 or additional_video_tags[] in matroskaenc.c */
29 const CodecTags ff_mkv_codec_tags[]={
30 {"A_AAC" , AV_CODEC_ID_AAC},
31 {"A_AC3" , AV_CODEC_ID_AC3},
32 {"A_ALAC" , AV_CODEC_ID_ALAC},
33 {"A_DTS" , AV_CODEC_ID_DTS},
34 {"A_EAC3" , AV_CODEC_ID_EAC3},
35 {"A_FLAC" , AV_CODEC_ID_FLAC},
36 {"A_MLP" , AV_CODEC_ID_MLP},
37 {"A_MPEG/L2" , AV_CODEC_ID_MP2},
38 {"A_MPEG/L1" , AV_CODEC_ID_MP1},
39 {"A_MPEG/L3" , AV_CODEC_ID_MP3},
40 {"A_OPUS" , AV_CODEC_ID_OPUS},
41 {"A_OPUS/EXPERIMENTAL",AV_CODEC_ID_OPUS},
42 {"A_PCM/FLOAT/IEEE" , AV_CODEC_ID_PCM_F32LE},
43 {"A_PCM/FLOAT/IEEE" , AV_CODEC_ID_PCM_F64LE},
44 {"A_PCM/INT/BIG" , AV_CODEC_ID_PCM_S16BE},
45 {"A_PCM/INT/BIG" , AV_CODEC_ID_PCM_S24BE},
46 {"A_PCM/INT/BIG" , AV_CODEC_ID_PCM_S32BE},
47 {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_S16LE},
48 {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_S24LE},
49 {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_S32LE},
50 {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_U8},
51 {"A_QUICKTIME/QDMC" , AV_CODEC_ID_QDMC},
52 {"A_QUICKTIME/QDM2" , AV_CODEC_ID_QDM2},
53 {"A_REAL/14_4" , AV_CODEC_ID_RA_144},
54 {"A_REAL/28_8" , AV_CODEC_ID_RA_288},
55 {"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3},
56 {"A_REAL/COOK" , AV_CODEC_ID_COOK},
57 {"A_REAL/SIPR" , AV_CODEC_ID_SIPR},
58 {"A_TRUEHD" , AV_CODEC_ID_TRUEHD},
59 {"A_TTA1" , AV_CODEC_ID_TTA},
60 {"A_VORBIS" , AV_CODEC_ID_VORBIS},
61 {"A_WAVPACK4" , AV_CODEC_ID_WAVPACK},
62
63 {"D_WEBVTT/SUBTITLES" , AV_CODEC_ID_WEBVTT},
64 {"D_WEBVTT/CAPTIONS" , AV_CODEC_ID_WEBVTT},
65 {"D_WEBVTT/DESCRIPTIONS", AV_CODEC_ID_WEBVTT},
66 {"D_WEBVTT/METADATA" , AV_CODEC_ID_WEBVTT},
67
68 {"S_TEXT/UTF8" , AV_CODEC_ID_SUBRIP},
69 {"S_TEXT/UTF8" , AV_CODEC_ID_TEXT},
70 {"S_TEXT/ASCII" , AV_CODEC_ID_TEXT},
71 {"S_TEXT/ASS" , AV_CODEC_ID_ASS},
72 {"S_TEXT/SSA" , AV_CODEC_ID_ASS},
73 {"S_ASS" , AV_CODEC_ID_ASS},
74 {"S_SSA" , AV_CODEC_ID_ASS},
75 {"S_VOBSUB" , AV_CODEC_ID_DVD_SUBTITLE},
76 {"S_DVBSUB" , AV_CODEC_ID_DVB_SUBTITLE},
77 {"S_HDMV/PGS" , AV_CODEC_ID_HDMV_PGS_SUBTITLE},
78 {"S_HDMV/TEXTST" , AV_CODEC_ID_HDMV_TEXT_SUBTITLE},
79
80 {"V_AV1" , AV_CODEC_ID_AV1},
81 {"V_AVS2" , AV_CODEC_ID_AVS2},
82 {"V_AVS3" , AV_CODEC_ID_AVS3},
83 {"V_DIRAC" , AV_CODEC_ID_DIRAC},
84 {"V_FFV1" , AV_CODEC_ID_FFV1},
85 {"V_MJPEG" , AV_CODEC_ID_MJPEG},
86 {"V_MPEG1" , AV_CODEC_ID_MPEG1VIDEO},
87 {"V_MPEG2" , AV_CODEC_ID_MPEG2VIDEO},
88 {"V_MPEG4/ISO/ASP" , AV_CODEC_ID_MPEG4},
89 {"V_MPEG4/ISO/AP" , AV_CODEC_ID_MPEG4},
90 {"V_MPEG4/ISO/SP" , AV_CODEC_ID_MPEG4},
91 {"V_MPEG4/ISO/AVC" , AV_CODEC_ID_H264},
92 {"V_MPEGH/ISO/HEVC" , AV_CODEC_ID_HEVC},
93 {"V_MPEG4/MS/V3" , AV_CODEC_ID_MSMPEG4V3},
94 {"V_PRORES" , AV_CODEC_ID_PRORES},
95 {"V_REAL/RV10" , AV_CODEC_ID_RV10},
96 {"V_REAL/RV20" , AV_CODEC_ID_RV20},
97 {"V_REAL/RV30" , AV_CODEC_ID_RV30},
98 {"V_REAL/RV40" , AV_CODEC_ID_RV40},
99 {"V_SNOW" , AV_CODEC_ID_SNOW},
100 {"V_THEORA" , AV_CODEC_ID_THEORA},
101 {"V_UNCOMPRESSED" , AV_CODEC_ID_RAWVIDEO},
102 {"V_VP8" , AV_CODEC_ID_VP8},
103 {"V_VP9" , AV_CODEC_ID_VP9},
104
105 {"" , AV_CODEC_ID_NONE}
106 };
107
108 const CodecTags ff_webm_codec_tags[] = {
109 {"V_VP8" , AV_CODEC_ID_VP8},
110 {"V_VP9" , AV_CODEC_ID_VP9},
111 {"V_AV1" , AV_CODEC_ID_AV1},
112
113 {"A_VORBIS" , AV_CODEC_ID_VORBIS},
114 {"A_OPUS" , AV_CODEC_ID_OPUS},
115
116 {"D_WEBVTT/SUBTITLES" , AV_CODEC_ID_WEBVTT},
117 {"D_WEBVTT/CAPTIONS" , AV_CODEC_ID_WEBVTT},
118 {"D_WEBVTT/DESCRIPTIONS", AV_CODEC_ID_WEBVTT},
119 {"D_WEBVTT/METADATA" , AV_CODEC_ID_WEBVTT},
120
121 {"" , AV_CODEC_ID_NONE}
122 };
123
124 const AVMetadataConv ff_mkv_metadata_conv[] = {
125 { "LEAD_PERFORMER", "performer" },
126 { "PART_NUMBER" , "track" },
127 { 0 }
128 };
129
130 const char * const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREOMODE_TYPE_NB] = {
131 "mono",
132 "left_right",
133 "bottom_top",
134 "top_bottom",
135 "checkerboard_rl",
136 "checkerboard_lr",
137 "row_interleaved_rl",
138 "row_interleaved_lr",
139 "col_interleaved_rl",
140 "col_interleaved_lr",
141 "anaglyph_cyan_red",
142 "right_left",
143 "anaglyph_green_magenta",
144 "block_lr",
145 "block_rl",
146 };
147
148 const char * const ff_matroska_video_stereo_plane[MATROSKA_VIDEO_STEREO_PLANE_COUNT] = {
149 "left",
150 "right",
151 "background",
152 };
153
154 227 int ff_mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode)
155 {
156 AVStereo3D *stereo;
157 int ret;
158
159 227 stereo = av_stereo3d_alloc();
160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 if (!stereo)
161 return AVERROR(ENOMEM);
162
163 // note: the missing breaks are intentional
164
1/14
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
227 switch (stereo_mode) {
165 227 case MATROSKA_VIDEO_STEREOMODE_TYPE_MONO:
166 227 stereo->type = AV_STEREO3D_2D;
167 227 break;
168 case MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT:
169 stereo->flags |= AV_STEREO3D_FLAG_INVERT;
170 case MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT:
171 stereo->type = AV_STEREO3D_SIDEBYSIDE;
172 break;
173 case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTTOM_TOP:
174 stereo->flags |= AV_STEREO3D_FLAG_INVERT;
175 case MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM:
176 stereo->type = AV_STEREO3D_TOPBOTTOM;
177 break;
178 case MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_RL:
179 stereo->flags |= AV_STEREO3D_FLAG_INVERT;
180 case MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR:
181 stereo->type = AV_STEREO3D_CHECKERBOARD;
182 break;
183 case MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_RL:
184 stereo->flags |= AV_STEREO3D_FLAG_INVERT;
185 case MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR:
186 stereo->type = AV_STEREO3D_LINES;
187 break;
188 case MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_RL:
189 stereo->flags |= AV_STEREO3D_FLAG_INVERT;
190 case MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR:
191 stereo->type = AV_STEREO3D_COLUMNS;
192 break;
193 case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL:
194 stereo->flags |= AV_STEREO3D_FLAG_INVERT;
195 case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR:
196 stereo->type = AV_STEREO3D_FRAMESEQUENCE;
197 break;
198 }
199
200 227 ret = av_stream_add_side_data(st, AV_PKT_DATA_STEREO3D, (uint8_t *)stereo,
201 sizeof(*stereo));
202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 if (ret < 0) {
203 av_freep(&stereo);
204 return ret;
205 }
206
207 227 return 0;
208 }
209