1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * nut 3cabdff1aSopenharmony_ci * Copyright (c) 2004-2007 Michael Niedermayer 4cabdff1aSopenharmony_ci * 5cabdff1aSopenharmony_ci * This file is part of FFmpeg. 6cabdff1aSopenharmony_ci * 7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 11cabdff1aSopenharmony_ci * 12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15cabdff1aSopenharmony_ci * Lesser General Public License for more details. 16cabdff1aSopenharmony_ci * 17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20cabdff1aSopenharmony_ci */ 21cabdff1aSopenharmony_ci 22cabdff1aSopenharmony_ci#include "libavutil/mathematics.h" 23cabdff1aSopenharmony_ci#include "libavutil/tree.h" 24cabdff1aSopenharmony_ci#include "nut.h" 25cabdff1aSopenharmony_ci#include "riff.h" 26cabdff1aSopenharmony_ci#include "internal.h" 27cabdff1aSopenharmony_ci 28cabdff1aSopenharmony_ciconst AVCodecTag ff_nut_subtitle_tags[] = { 29cabdff1aSopenharmony_ci { AV_CODEC_ID_TEXT, MKTAG('U', 'T', 'F', '8') }, 30cabdff1aSopenharmony_ci { AV_CODEC_ID_ASS, MKTAG('S', 'S', 'A', 0 ) }, 31cabdff1aSopenharmony_ci { AV_CODEC_ID_ASS, MKTAG('A', 'S', 'S', 0 ) }, 32cabdff1aSopenharmony_ci { AV_CODEC_ID_DVD_SUBTITLE, MKTAG('D', 'V', 'D', 'S') }, 33cabdff1aSopenharmony_ci { AV_CODEC_ID_DVB_SUBTITLE, MKTAG('D', 'V', 'B', 'S') }, 34cabdff1aSopenharmony_ci { AV_CODEC_ID_DVB_TELETEXT, MKTAG('D', 'V', 'B', 'T') }, 35cabdff1aSopenharmony_ci { AV_CODEC_ID_NONE, 0 } 36cabdff1aSopenharmony_ci}; 37cabdff1aSopenharmony_ci 38cabdff1aSopenharmony_ciconst AVCodecTag ff_nut_data_tags[] = { 39cabdff1aSopenharmony_ci { AV_CODEC_ID_TEXT, MKTAG('U', 'T', 'F', '8') }, 40cabdff1aSopenharmony_ci { AV_CODEC_ID_NONE, 0 } 41cabdff1aSopenharmony_ci}; 42cabdff1aSopenharmony_ci 43cabdff1aSopenharmony_ciconst AVCodecTag ff_nut_video_tags[] = { 44cabdff1aSopenharmony_ci { AV_CODEC_ID_GIF, MKTAG('G', 'I', 'F', 0 ) }, 45cabdff1aSopenharmony_ci { AV_CODEC_ID_XFACE, MKTAG('X', 'F', 'A', 'C') }, 46cabdff1aSopenharmony_ci { AV_CODEC_ID_VP9, MKTAG('V', 'P', '9', '0') }, 47cabdff1aSopenharmony_ci { AV_CODEC_ID_HEVC, MKTAG('H', 'E', 'V', 'C') }, 48cabdff1aSopenharmony_ci { AV_CODEC_ID_CPIA, MKTAG('C', 'P', 'i', 'A') }, 49cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 15 ) }, 50cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 15 ) }, 51cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 16 ) }, 52cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 16 ) }, 53cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(15 , 'B', 'G', 'R') }, 54cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(15 , 'R', 'G', 'B') }, 55cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16 , 'B', 'G', 'R') }, 56cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16 , 'R', 'G', 'B') }, 57cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 12 ) }, 58cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 12 ) }, 59cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(12 , 'B', 'G', 'R') }, 60cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(12 , 'R', 'G', 'B') }, 61cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 'A') }, 62cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 0 ) }, 63cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 'A') }, 64cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 0 ) }, 65cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('A', 'B', 'G', 'R') }, 66cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG( 0 , 'B', 'G', 'R') }, 67cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('A', 'R', 'G', 'B') }, 68cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG( 0 , 'R', 'G', 'B') }, 69cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 24 ) }, 70cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 24 ) }, 71cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('4', '1', '1', 'P') }, 72cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('4', '2', '2', 'P') }, 73cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('4', '2', '2', 'P') }, 74cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('4', '4', '0', 'P') }, 75cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('4', '4', '0', 'P') }, 76cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('4', '4', '4', 'P') }, 77cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('4', '4', '4', 'P') }, 78cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', '1', 'W', '0') }, 79cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', '0', 'W', '1') }, 80cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 8 ) }, 81cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 8 ) }, 82cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 4 ) }, 83cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 4 ) }, 84cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', '4', 'B', 'Y') }, 85cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', '4', 'B', 'Y') }, 86cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 48 ) }, 87cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 48 ) }, 88cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(48 , 'B', 'G', 'R') }, 89cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(48 , 'R', 'G', 'B') }, 90cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('R', 'B', 'A', 64 ) }, 91cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'R', 'A', 64 ) }, 92cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(64 , 'R', 'B', 'A') }, 93cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(64 , 'B', 'R', 'A') }, 94cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 11 , 9 ) }, 95cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG( 9 , 11 , '3', 'Y') }, 96cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 10 , 9 ) }, 97cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG( 9 , 10 , '3', 'Y') }, 98cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 0 , 9 ) }, 99cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG( 9 , 0 , '3', 'Y') }, 100cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 11 , 10 ) }, 101cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(10 , 11 , '3', 'Y') }, 102cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 10 , 10 ) }, 103cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(10 , 10 , '3', 'Y') }, 104cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 0 , 10 ) }, 105cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(10 , 0 , '3', 'Y') }, 106cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 11 , 12 ) }, 107cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(12 , 11 , '3', 'Y') }, 108cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 10 , 12 ) }, 109cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(12 , 10 , '3', 'Y') }, 110cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 0 , 12 ) }, 111cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(12 , 0 , '3', 'Y') }, 112cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 11 , 14 ) }, 113cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(14 , 11 , '3', 'Y') }, 114cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 10 , 14 ) }, 115cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(14 , 10 , '3', 'Y') }, 116cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 0 , 14 ) }, 117cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(14 , 0 , '3', 'Y') }, 118cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '1', 0 , 16 ) }, 119cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16 , 0 , '1', 'Y') }, 120cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 11 , 16 ) }, 121cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16 , 11 , '3', 'Y') }, 122cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 10 , 16 ) }, 123cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16 , 10 , '3', 'Y') }, 124cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 0 , 16 ) }, 125cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16 , 0 , '3', 'Y') }, 126cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 11 , 8 ) }, 127cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 10 , 8 ) }, 128cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 0 , 8 ) }, 129cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '2', 0 , 8 ) }, 130cabdff1aSopenharmony_ci 131cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '1', 0, 9) }, 132cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(9, 0, '1', 'Y') }, 133cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 11, 9) }, 134cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(9, 11, '4', 'Y') }, 135cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 10, 9) }, 136cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(9, 10, '4', 'Y') }, 137cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 0, 9) }, 138cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(9, 0, '4', 'Y') }, 139cabdff1aSopenharmony_ci 140cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '1', 0, 10) }, 141cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(10, 0, '1', 'Y') }, 142cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 11, 10) }, 143cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(10, 11, '4', 'Y') }, 144cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 10, 10) }, 145cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(10, 10, '4', 'Y') }, 146cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 0, 10) }, 147cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(10, 0, '4', 'Y') }, 148cabdff1aSopenharmony_ci 149cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 0, 12) }, 150cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(12, 0, '4', 'Y') }, 151cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 10, 12) }, 152cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(12, 10, '4', 'Y') }, 153cabdff1aSopenharmony_ci 154cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '1', 0, 12) }, 155cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(12, 0, '1', 'Y') }, 156cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '1', 0, 16) }, 157cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16, 0, '1', 'Y') }, 158cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 11, 16) }, 159cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16, 11, '4', 'Y') }, 160cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 10, 16) }, 161cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16, 10, '4', 'Y') }, 162cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 0, 16) }, 163cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16, 0, '4', 'Y') }, 164cabdff1aSopenharmony_ci 165cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '1', 0, 14) }, 166cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(14, 0, '1', 'Y') }, 167cabdff1aSopenharmony_ci 168cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('G', '3', 0, 8) }, 169cabdff1aSopenharmony_ci 170cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('G', '3', 0, 9) }, 171cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG( 9, 0, '3', 'G') }, 172cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('G', '3', 0, 10) }, 173cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(10, 0, '3', 'G') }, 174cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('G', '3', 0, 12) }, 175cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(12, 0, '3', 'G') }, 176cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('G', '3', 0, 14) }, 177cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(14, 0, '3', 'G') }, 178cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('G', '3', 0, 16) }, 179cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16, 0, '3', 'G') }, 180cabdff1aSopenharmony_ci 181cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('G', '4', 0, 8) }, 182cabdff1aSopenharmony_ci 183cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('G', '4', 00 , 10 ) }, 184cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(10 , 00 , '4', 'G') }, 185cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('G', '4', 00 , 12 ) }, 186cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(12 , 00 , '4', 'G') }, 187cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('G', '4', 00 , 16 ) }, 188cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16 , 00 , '4', 'G') }, 189cabdff1aSopenharmony_ci 190cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('X', 'Y', 'Z' , 36 ) }, 191cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(36 , 'Z' , 'Y', 'X') }, 192cabdff1aSopenharmony_ci 193cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG('P', 'A', 'L', 8 ) }, 194cabdff1aSopenharmony_ci 195cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(0xBA, 'B', 'G', 8 ) }, 196cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(0xBA, 'B', 'G', 16 ) }, 197cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16 , 'G', 'B', 0xBA) }, 198cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(0xBA, 'R', 'G', 8 ) }, 199cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(0xBA, 'R', 'G', 16 ) }, 200cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16 , 'G', 'R', 0xBA) }, 201cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(0xBA, 'G', 'B', 8 ) }, 202cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(0xBA, 'G', 'B', 16 ) }, 203cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16, 'B', 'G', 0xBA) }, 204cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(0xBA, 'G', 'R', 8 ) }, 205cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(0xBA, 'G', 'R', 16 ) }, 206cabdff1aSopenharmony_ci { AV_CODEC_ID_RAWVIDEO, MKTAG(16, 'R', 'G', 0xBA) }, 207cabdff1aSopenharmony_ci 208cabdff1aSopenharmony_ci { AV_CODEC_ID_NONE, 0 } 209cabdff1aSopenharmony_ci}; 210cabdff1aSopenharmony_ci 211cabdff1aSopenharmony_ciconst AVCodecTag ff_nut_audio_extra_tags[] = { 212cabdff1aSopenharmony_ci { AV_CODEC_ID_COMFORT_NOISE, MKTAG('3', '3', '8', '9') }, 213cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_ALAW, MKTAG('A', 'L', 'A', 'W') }, 214cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_MULAW, MKTAG('U', 'L', 'A', 'W') }, 215cabdff1aSopenharmony_ci { AV_CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') }, 216cabdff1aSopenharmony_ci { AV_CODEC_ID_OPUS, MKTAG('O', 'p', 'u', 's') }, 217cabdff1aSopenharmony_ci { AV_CODEC_ID_WAVPACK, MKTAG('w', 'v', 'p', 'k') }, 218cabdff1aSopenharmony_ci { AV_CODEC_ID_NONE, 0 } 219cabdff1aSopenharmony_ci}; 220cabdff1aSopenharmony_ci 221cabdff1aSopenharmony_ciconst AVCodecTag ff_nut_audio_tags[] = { 222cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_F32BE, MKTAG(32 , 'D', 'F', 'P') }, 223cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_F32LE, MKTAG('P', 'F', 'D', 32 ) }, 224cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_F64BE, MKTAG(64 , 'D', 'F', 'P') }, 225cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_F64LE, MKTAG('P', 'F', 'D', 64 ) }, 226cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S16BE, MKTAG(16 , 'D', 'S', 'P') }, 227cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S16LE, MKTAG('P', 'S', 'D', 16 ) }, 228cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S24BE, MKTAG(24 , 'D', 'S', 'P') }, 229cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S24LE, MKTAG('P', 'S', 'D', 24 ) }, 230cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S32BE, MKTAG(32 , 'D', 'S', 'P') }, 231cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S32LE, MKTAG('P', 'S', 'D', 32 ) }, 232cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S64BE, MKTAG(64 , 'D', 'S', 'P') }, 233cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S64LE, MKTAG('P', 'S', 'D', 64 ) }, 234cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S8, MKTAG('P', 'S', 'D', 8 ) }, 235cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_U16BE, MKTAG(16 , 'D', 'U', 'P') }, 236cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_U16LE, MKTAG('P', 'U', 'D', 16 ) }, 237cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_U24BE, MKTAG(24 , 'D', 'U', 'P') }, 238cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_U24LE, MKTAG('P', 'U', 'D', 24 ) }, 239cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_U32BE, MKTAG(32 , 'D', 'U', 'P') }, 240cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_U32LE, MKTAG('P', 'U', 'D', 32 ) }, 241cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_U8, MKTAG('P', 'U', 'D', 8 ) }, 242cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S8_PLANAR, MKTAG('P', 'S', 'P', 8 ) }, 243cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S16BE_PLANAR, MKTAG(16 , 'P', 'S', 'P') }, 244cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S16LE_PLANAR, MKTAG('P', 'S', 'P', 16 ) }, 245cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S24LE_PLANAR, MKTAG('P', 'S', 'P', 24 ) }, 246cabdff1aSopenharmony_ci { AV_CODEC_ID_PCM_S32LE_PLANAR, MKTAG('P', 'S', 'P', 32 ) }, 247cabdff1aSopenharmony_ci { AV_CODEC_ID_NONE, 0 } 248cabdff1aSopenharmony_ci}; 249cabdff1aSopenharmony_ci 250cabdff1aSopenharmony_ciconst AVCodecTag * const ff_nut_codec_tags[] = { 251cabdff1aSopenharmony_ci ff_nut_video_tags, ff_nut_audio_tags, ff_nut_subtitle_tags, 252cabdff1aSopenharmony_ci ff_codec_bmp_tags, ff_codec_wav_tags, ff_nut_audio_extra_tags, ff_nut_data_tags, 0 253cabdff1aSopenharmony_ci}; 254cabdff1aSopenharmony_ci 255cabdff1aSopenharmony_civoid ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val) 256cabdff1aSopenharmony_ci{ 257cabdff1aSopenharmony_ci int i; 258cabdff1aSopenharmony_ci for (i = 0; i < nut->avf->nb_streams; i++) 259cabdff1aSopenharmony_ci nut->stream[i].last_pts = 260cabdff1aSopenharmony_ci av_rescale_rnd(val, 261cabdff1aSopenharmony_ci time_base.num * (int64_t)nut->stream[i].time_base->den, 262cabdff1aSopenharmony_ci time_base.den * (int64_t)nut->stream[i].time_base->num, 263cabdff1aSopenharmony_ci AV_ROUND_DOWN); 264cabdff1aSopenharmony_ci} 265cabdff1aSopenharmony_ci 266cabdff1aSopenharmony_ciint64_t ff_lsb2full(StreamContext *stream, int64_t lsb) 267cabdff1aSopenharmony_ci{ 268cabdff1aSopenharmony_ci int64_t mask = (1ULL << stream->msb_pts_shift) - 1; 269cabdff1aSopenharmony_ci int64_t delta = stream->last_pts - mask / 2; 270cabdff1aSopenharmony_ci return ((lsb - delta) & mask) + delta; 271cabdff1aSopenharmony_ci} 272cabdff1aSopenharmony_ci 273cabdff1aSopenharmony_ciint ff_nut_sp_pos_cmp(const void *a, const void *b) 274cabdff1aSopenharmony_ci{ 275cabdff1aSopenharmony_ci const Syncpoint *va = a, *vb = b; 276cabdff1aSopenharmony_ci return ((va->pos - vb->pos) >> 32) - ((vb->pos - va->pos) >> 32); 277cabdff1aSopenharmony_ci} 278cabdff1aSopenharmony_ci 279cabdff1aSopenharmony_ciint ff_nut_sp_pts_cmp(const void *a, const void *b) 280cabdff1aSopenharmony_ci{ 281cabdff1aSopenharmony_ci const Syncpoint *va = a, *vb = b; 282cabdff1aSopenharmony_ci return ((va->ts - vb->ts) >> 32) - ((vb->ts - va->ts) >> 32); 283cabdff1aSopenharmony_ci} 284cabdff1aSopenharmony_ci 285cabdff1aSopenharmony_ciint ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts) 286cabdff1aSopenharmony_ci{ 287cabdff1aSopenharmony_ci Syncpoint *sp = av_mallocz(sizeof(Syncpoint)); 288cabdff1aSopenharmony_ci struct AVTreeNode *node = av_tree_node_alloc(); 289cabdff1aSopenharmony_ci 290cabdff1aSopenharmony_ci if (!sp || !node) { 291cabdff1aSopenharmony_ci av_freep(&sp); 292cabdff1aSopenharmony_ci av_freep(&node); 293cabdff1aSopenharmony_ci return AVERROR(ENOMEM); 294cabdff1aSopenharmony_ci } 295cabdff1aSopenharmony_ci 296cabdff1aSopenharmony_ci nut->sp_count++; 297cabdff1aSopenharmony_ci 298cabdff1aSopenharmony_ci sp->pos = pos; 299cabdff1aSopenharmony_ci sp->back_ptr = back_ptr; 300cabdff1aSopenharmony_ci sp->ts = ts; 301cabdff1aSopenharmony_ci av_tree_insert(&nut->syncpoints, sp, ff_nut_sp_pos_cmp, &node); 302cabdff1aSopenharmony_ci if (node) { 303cabdff1aSopenharmony_ci av_free(sp); 304cabdff1aSopenharmony_ci av_free(node); 305cabdff1aSopenharmony_ci } 306cabdff1aSopenharmony_ci 307cabdff1aSopenharmony_ci return 0; 308cabdff1aSopenharmony_ci} 309cabdff1aSopenharmony_ci 310cabdff1aSopenharmony_cistatic int enu_free(void *opaque, void *elem) 311cabdff1aSopenharmony_ci{ 312cabdff1aSopenharmony_ci av_free(elem); 313cabdff1aSopenharmony_ci return 0; 314cabdff1aSopenharmony_ci} 315cabdff1aSopenharmony_ci 316cabdff1aSopenharmony_civoid ff_nut_free_sp(NUTContext *nut) 317cabdff1aSopenharmony_ci{ 318cabdff1aSopenharmony_ci if (nut->syncpoints) { 319cabdff1aSopenharmony_ci av_tree_enumerate(nut->syncpoints, NULL, NULL, enu_free); 320cabdff1aSopenharmony_ci av_tree_destroy(nut->syncpoints); 321cabdff1aSopenharmony_ci } 322cabdff1aSopenharmony_ci} 323cabdff1aSopenharmony_ci 324cabdff1aSopenharmony_ciconst Dispositions ff_nut_dispositions[] = { 325cabdff1aSopenharmony_ci { "default", AV_DISPOSITION_DEFAULT }, 326cabdff1aSopenharmony_ci { "dub", AV_DISPOSITION_DUB }, 327cabdff1aSopenharmony_ci { "original", AV_DISPOSITION_ORIGINAL }, 328cabdff1aSopenharmony_ci { "comment", AV_DISPOSITION_COMMENT }, 329cabdff1aSopenharmony_ci { "lyrics", AV_DISPOSITION_LYRICS }, 330cabdff1aSopenharmony_ci { "karaoke", AV_DISPOSITION_KARAOKE }, 331cabdff1aSopenharmony_ci { "", 0 } 332cabdff1aSopenharmony_ci}; 333cabdff1aSopenharmony_ci 334cabdff1aSopenharmony_ciconst AVMetadataConv ff_nut_metadata_conv[] = { 335cabdff1aSopenharmony_ci { "Author", "artist" }, 336cabdff1aSopenharmony_ci { "X-CreationTime", "date" }, 337cabdff1aSopenharmony_ci { "CreationTime", "date" }, 338cabdff1aSopenharmony_ci { "SourceFilename", "filename" }, 339cabdff1aSopenharmony_ci { "X-Language", "language" }, 340cabdff1aSopenharmony_ci { "X-Disposition", "disposition" }, 341cabdff1aSopenharmony_ci { "X-Replaces", "replaces" }, 342cabdff1aSopenharmony_ci { "X-Depends", "depends" }, 343cabdff1aSopenharmony_ci { "X-Uses", "uses" }, 344cabdff1aSopenharmony_ci { "X-UsesFont", "usesfont" }, 345cabdff1aSopenharmony_ci { 0 }, 346cabdff1aSopenharmony_ci}; 347