FFmpeg
Loading...
Searching...
No Matches
flvdec.c
Go to the documentation of this file.
1/*
2 * FLV demuxer
3 * Copyright (c) 2003 The FFmpeg Project
4 *
5 * This demuxer will generate a 1 byte extradata for VP6F content.
6 * It is composed of:
7 * - upper 4 bits: difference between encoded width and visible width
8 * - lower 4 bits: difference between encoded height and visible height
9 *
10 * This file is part of FFmpeg.
11 *
12 * FFmpeg is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * FFmpeg is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with FFmpeg; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
28#include "libavutil/avassert.h"
29#include "libavutil/avstring.h"
31#include "libavutil/dict.h"
32#include "libavutil/mem.h"
33#include "libavutil/opt.h"
34#include "libavutil/internal.h"
35#include "libavutil/intfloat.h"
38#include "avformat.h"
39#include "avio_internal.h"
40#include "demux.h"
41#include "internal.h"
42#include "flv.h"
43
44#define VALIDATE_INDEX_TS_THRESH 2500
45
46#define RESYNC_BUFFER_SIZE (1<<20)
47
48#define MAX_DEPTH 16 ///< arbitrary limit to prevent unbounded recursion
49
50typedef struct FLVMasteringMeta {
51 float r_x;
52 float r_y;
53 float g_x;
54 float g_y;
55 float b_x;
56 float b_y;
57 float white_x;
58 float white_y;
62
71
77
119
120/* AMF date type */
121typedef struct amf_date {
123 int16_t timezone;
124} amf_date;
125
126static int probe(const AVProbeData *p, int live)
127{
128 const uint8_t *d = p->buf;
129 unsigned offset = AV_RB32(d + 5);
130
131 if (d[0] == 'F' &&
132 d[1] == 'L' &&
133 d[2] == 'V' &&
134 d[3] < 5 && d[5] == 0 &&
135 offset + 100 < p->buf_size &&
136 offset > 8) {
137 int is_live = !memcmp(d + offset + 40, "NGINX RTMP", 10);
138
139 if (live == is_live)
140 return AVPROBE_SCORE_MAX;
141 }
142 return 0;
143}
144
145static int flv_probe(const AVProbeData *p)
146{
147 return probe(p, 0);
148}
149
150static int live_flv_probe(const AVProbeData *p)
151{
152 return probe(p, 1);
153}
154
155static int kux_probe(const AVProbeData *p)
156{
157 const uint8_t *d = p->buf;
158
159 if (d[0] == 'K' &&
160 d[1] == 'D' &&
161 d[2] == 'K' &&
162 d[3] == 0 &&
163 d[4] == 0) {
164 return AVPROBE_SCORE_EXTENSION + 1;
165 }
166 return 0;
167}
168
170{
171 FLVContext *flv = s->priv_data;
172 AVStream *stream = NULL;
173 unsigned int i = 0;
174
175 if (flv->last_keyframe_stream_index < 0) {
176 av_log(s, AV_LOG_DEBUG, "keyframe stream hasn't been created\n");
177 return;
178 }
179
180 av_assert0(flv->last_keyframe_stream_index <= s->nb_streams);
181 stream = s->streams[flv->last_keyframe_stream_index];
182
183 if (ffstream(stream)->nb_index_entries == 0) {
184 for (i = 0; i < flv->keyframe_count; i++) {
185 av_log(s, AV_LOG_TRACE, "keyframe filepositions = %"PRId64" times = %"PRId64"\n",
188 flv->keyframe_times[i], 0, 0, AVINDEX_KEYFRAME);
189 }
190 } else
191 av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
192
193 if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
196 flv->keyframe_count = 0;
197 }
198}
199
200static AVStream *create_stream(AVFormatContext *s, int codec_type, int track_idx)
201{
202 FFFormatContext *const si = ffformatcontext(s);
203 FLVContext *flv = s->priv_data;
205 if (!st)
206 return NULL;
208 st->id = track_idx;
209 avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
210 if (track_idx)
211 return st;
212
213 if (s->nb_streams>=3 ||( s->nb_streams==2
214 && s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE
215 && s->streams[1]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE
216 && s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_DATA
217 && s->streams[1]->codecpar->codec_type != AVMEDIA_TYPE_DATA))
218 s->ctx_flags &= ~AVFMTCTX_NOHEADER;
220 st->codecpar->bit_rate = flv->audio_bit_rate;
222 }
224 st->codecpar->bit_rate = flv->video_bit_rate;
226 st->avg_frame_rate = flv->framerate;
227 }
228
229 flv->last_keyframe_stream_index = s->nb_streams - 1;
231 return st;
232}
233
234static int flv_same_audio_codec(AVCodecParameters *apar, int flags, uint32_t codec_fourcc)
235{
236 int bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
237 int flv_codecid = flags & FLV_AUDIO_CODECID_MASK;
238 int codec_id;
239
240 switch (codec_fourcc) {
241 case MKBETAG('m', 'p', '4', 'a'):
242 return apar->codec_id == AV_CODEC_ID_AAC;
243 case MKBETAG('O', 'p', 'u', 's'):
244 return apar->codec_id == AV_CODEC_ID_OPUS;
245 case MKBETAG('.', 'm', 'p', '3'):
246 return apar->codec_id == AV_CODEC_ID_MP3;
247 case MKBETAG('f', 'L', 'a', 'C'):
248 return apar->codec_id == AV_CODEC_ID_FLAC;
249 case MKBETAG('a', 'c', '-', '3'):
250 return apar->codec_id == AV_CODEC_ID_AC3;
251 case MKBETAG('e', 'c', '-', '3'):
252 return apar->codec_id == AV_CODEC_ID_EAC3;
253 case 0:
254 // Not enhanced flv, continue as normal.
255 break;
256 default:
257 // Unknown FOURCC
258 return 0;
259 }
260
261 if (!apar->codec_id && !apar->codec_tag)
262 return 1;
263
264 if (apar->bits_per_coded_sample != bits_per_coded_sample)
265 return 0;
266
267 switch (flv_codecid) {
268 // no distinction between S16 and S8 PCM codec flags
269 case FLV_CODECID_PCM:
270 codec_id = bits_per_coded_sample == 8
272#if HAVE_BIGENDIAN
274#else
276#endif
277 return codec_id == apar->codec_id;
279 codec_id = bits_per_coded_sample == 8
282 return codec_id == apar->codec_id;
283 case FLV_CODECID_AAC:
284 return apar->codec_id == AV_CODEC_ID_AAC;
286 return apar->codec_id == AV_CODEC_ID_ADPCM_SWF;
288 return apar->codec_id == AV_CODEC_ID_SPEEX;
289 case FLV_CODECID_MP3:
290 return apar->codec_id == AV_CODEC_ID_MP3;
294 return apar->codec_id == AV_CODEC_ID_NELLYMOSER;
296 return apar->sample_rate == 8000 &&
299 return apar->sample_rate == 8000 &&
301 default:
302 return apar->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
303 }
304}
305
307 AVCodecParameters *apar, int flv_codecid)
308{
309 FFStream *const astreami = ffstream(astream);
310 AVCodecParameters *par = astream->codecpar;
311 enum AVCodecID old_codec_id = astream->codecpar->codec_id;
312
313 switch (flv_codecid) {
314 // no distinction between S16 and S8 PCM codec flags
315 case FLV_CODECID_PCM:
316 apar->codec_id = apar->bits_per_coded_sample == 8
318#if HAVE_BIGENDIAN
320#else
322#endif
323 break;
325 apar->codec_id = apar->bits_per_coded_sample == 8
328 break;
329 case FLV_CODECID_AAC:
331 break;
334 break;
337 apar->sample_rate = 16000;
338 break;
339 case FLV_CODECID_MP3:
342 break;
344 // in case metadata does not otherwise declare samplerate
345 apar->sample_rate = 8000;
347 break;
349 apar->sample_rate = 16000;
351 break;
354 break;
356 apar->sample_rate = 8000;
358 break;
360 apar->sample_rate = 8000;
362 break;
363 case MKBETAG('m', 'p', '4', 'a'):
365 break;
366 case MKBETAG('O', 'p', 'u', 's'):
368 apar->sample_rate = 48000;
369 break;
370 case MKBETAG('.', 'm', 'p', '3'):
372 break;
373 case MKBETAG('f', 'L', 'a', 'C'):
375 break;
376 case MKBETAG('a', 'c', '-', '3'):
378 break;
379 case MKBETAG('e', 'c', '-', '3'):
381 break;
382 default:
383 avpriv_request_sample(s, "Audio codec (%x)",
384 flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
385 apar->codec_tag = flv_codecid >> FLV_AUDIO_CODECID_OFFSET;
386 }
387
388 if (!astreami->need_context_update && par->codec_id != old_codec_id) {
389 avpriv_request_sample(s, "Changing the codec id midstream");
391 }
392 return 0;
393}
394
395static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid)
396{
397 if (!vpar->codec_id && !vpar->codec_tag)
398 return 1;
399
400 switch (flv_codecid) {
401 case MKBETAG('v', 'v', 'c', '1'):
402 return vpar->codec_id == AV_CODEC_ID_VVC;
404 case MKBETAG('h', 'v', 'c', '1'):
405 return vpar->codec_id == AV_CODEC_ID_HEVC;
406 case MKBETAG('a', 'v', '0', '1'):
407 return vpar->codec_id == AV_CODEC_ID_AV1;
408 case MKBETAG('v', 'p', '0', '9'):
409 return vpar->codec_id == AV_CODEC_ID_VP9;
410 case FLV_CODECID_H263:
411 return vpar->codec_id == AV_CODEC_ID_FLV1;
413 return vpar->codec_id == AV_CODEC_ID_FLASHSV;
415 return vpar->codec_id == AV_CODEC_ID_FLASHSV2;
416 case FLV_CODECID_VP6:
417 return vpar->codec_id == AV_CODEC_ID_VP6F;
418 case FLV_CODECID_VP6A:
419 return vpar->codec_id == AV_CODEC_ID_VP6A;
420 case FLV_CODECID_H264:
421 case MKBETAG('a', 'v', 'c', '1'):
422 return vpar->codec_id == AV_CODEC_ID_H264;
423 default:
424 return vpar->codec_tag == flv_codecid;
425 }
426}
427
429 uint32_t flv_codecid, int read)
430{
431 FFStream *const vstreami = ffstream(vstream);
432 int ret = 0;
433 AVCodecParameters *par = vstream->codecpar;
434 enum AVCodecID old_codec_id = vstream->codecpar->codec_id;
435
436 switch (flv_codecid) {
437 case MKBETAG('v', 'v', 'c', '1'):
440 break;
442 case MKBETAG('h', 'v', 'c', '1'):
445 break;
446 case MKBETAG('a', 'v', '0', '1'):
449 break;
450 case MKBETAG('v', 'p', '0', '9'):
453 break;
454 case FLV_CODECID_H263:
456 break;
459 break; // Really mean it this time
462 break;
465 break;
466 case FLV_CODECID_VP6:
469 case FLV_CODECID_VP6A:
470 if (flv_codecid == FLV_CODECID_VP6A)
472 if (read) {
473 if (par->extradata_size != 1) {
474 ff_alloc_extradata(par, 1);
475 }
476 if (par->extradata)
477 par->extradata[0] = avio_r8(s->pb);
478 else
479 avio_skip(s->pb, 1);
480 }
481 ret = 1; // 1 byte body size adjustment for flv_read_packet()
482 break;
483 case FLV_CODECID_H264:
484 case MKBETAG('a', 'v', 'c', '1'):
487 break;
490 break;
491 default:
492 avpriv_request_sample(s, "Video codec (%x)", flv_codecid);
493 par->codec_tag = flv_codecid;
494 }
495
496 if (!vstreami->need_context_update && par->codec_id != old_codec_id) {
497 avpriv_request_sample(s, "Changing the codec id midstream");
499 }
500
501 return ret;
502}
503
504static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize)
505{
506 int ret;
507 int length = avio_rb16(ioc);
508 if (length >= buffsize) {
509 avio_skip(ioc, length);
510 return AVERROR_INVALIDDATA;
511 }
512
513 ret = avio_read(ioc, buffer, length);
514 if (ret < 0)
515 return ret;
516 if (ret < length)
517 return AVERROR_INVALIDDATA;
518
519 buffer[length] = '\0';
520
521 return length;
522}
523
525{
526 FLVContext *flv = s->priv_data;
527 unsigned int timeslen = 0, fileposlen = 0, i;
528 char str_val[256];
529 int64_t *times = NULL;
530 int64_t *filepositions = NULL;
531 int ret = AVERROR(ENOSYS);
532 int64_t initial_pos = avio_tell(ioc);
533
534 if (flv->keyframe_count > 0) {
535 av_log(s, AV_LOG_DEBUG, "keyframes have been parsed\n");
536 return 0;
537 }
540
541 if (s->flags & AVFMT_FLAG_IGNIDX)
542 return 0;
543
544 while (avio_tell(ioc) < max_pos - 2 &&
545 amf_get_string(ioc, str_val, sizeof(str_val)) > 0) {
546 int64_t **current_array;
547 unsigned int arraylen;
548 int factor;
549
550 // Expect array object in context
551 if (avio_r8(ioc) != AMF_DATA_TYPE_ARRAY)
552 break;
553
554 arraylen = avio_rb32(ioc);
555 if (arraylen>>28 || arraylen > (max_pos - avio_tell(ioc)) / 9)
556 break;
557
558 if (!strcmp(KEYFRAMES_TIMESTAMP_TAG , str_val) && !times) {
559 current_array = &times;
560 timeslen = arraylen;
561 factor = 1000;
562 } else if (!strcmp(KEYFRAMES_BYTEOFFSET_TAG, str_val) &&
563 !filepositions) {
564 current_array = &filepositions;
565 fileposlen = arraylen;
566 factor = 1;
567 } else
568 // unexpected metatag inside keyframes, will not use such
569 // metadata for indexing
570 break;
571
572 if (!(*current_array = av_mallocz(sizeof(**current_array) * arraylen))) {
573 ret = AVERROR(ENOMEM);
574 goto finish;
575 }
576
577 for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) {
578 double d;
579 if (avio_r8(ioc) != AMF_DATA_TYPE_NUMBER)
580 goto invalid;
581 d = av_int2double(avio_rb64(ioc)) * factor;
582 if (isnan(d) || d < INT64_MIN || d > INT64_MAX)
583 goto invalid;
584 if (avio_feof(ioc))
585 goto invalid;
586 current_array[0][i] = d;
587 }
588 if (times && filepositions) {
589 // All done, exiting at a position allowing amf_parse_object
590 // to finish parsing the object
591 ret = 0;
592 break;
593 }
594 }
595
596 if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) {
597 for (i = 0; i < FFMIN(2,fileposlen); i++) {
598 flv->validate_index[i].pos = filepositions[i];
599 flv->validate_index[i].dts = times[i];
600 flv->validate_count = i + 1;
601 }
602 flv->keyframe_times = times;
603 flv->keyframe_filepositions = filepositions;
604 flv->keyframe_count = timeslen;
605 times = NULL;
606 filepositions = NULL;
607 } else {
608invalid:
609 av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
610 }
611
612finish:
613 av_freep(&times);
614 av_freep(&filepositions);
615 avio_seek(ioc, initial_pos, SEEK_SET);
616 return ret;
617}
618
620 AVStream *vstream, const char *key,
621 int64_t max_pos, int depth)
622{
623 AVCodecParameters *apar, *vpar;
624 FLVContext *flv = s->priv_data;
625 AVIOContext *ioc;
626 AMFDataType amf_type;
627 char str_val[1024];
628 double num_val;
629 amf_date date;
630
631 if (depth > MAX_DEPTH)
633
634 num_val = 0;
635 ioc = s->pb;
636 if (avio_feof(ioc))
637 return AVERROR_EOF;
638 amf_type = avio_r8(ioc);
639
640 switch (amf_type) {
642 num_val = av_int2double(avio_rb64(ioc));
643 break;
645 num_val = avio_r8(ioc);
646 break;
648 if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0) {
649 av_log(s, AV_LOG_ERROR, "AMF_DATA_TYPE_STRING parsing failed\n");
650 return -1;
651 }
652 break;
654 if (key &&
656 !strcmp(KEYFRAMES_TAG, key) && depth == 1)
657 if (parse_keyframes_index(s, ioc, max_pos) < 0)
658 av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n");
659 else
661 while (avio_tell(ioc) < max_pos - 2 &&
662 amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
663 if (amf_parse_object(s, astream, vstream, str_val, max_pos,
664 depth + 1) < 0)
665 return -1; // if we couldn't skip, bomb out.
666 if (avio_r8(ioc) != AMF_END_OF_OBJECT) {
667 av_log(s, AV_LOG_ERROR, "Missing AMF_END_OF_OBJECT in AMF_DATA_TYPE_OBJECT\n");
668 return -1;
669 }
670 break;
674 break; // these take up no additional space
676 {
677 unsigned v;
678 avio_skip(ioc, 4); // skip 32-bit max array index
679 while (avio_tell(ioc) < max_pos - 2 &&
680 amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
681 // this is the only case in which we would want a nested
682 // parse to not skip over the object
683 if (amf_parse_object(s, astream, vstream, str_val, max_pos,
684 depth + 1) < 0)
685 return -1;
686 v = avio_r8(ioc);
687 if (v != AMF_END_OF_OBJECT) {
688 av_log(s, AV_LOG_ERROR, "Missing AMF_END_OF_OBJECT in AMF_DATA_TYPE_MIXEDARRAY, found %d\n", v);
689 return -1;
690 }
691 break;
692 }
694 {
695 unsigned int arraylen, i;
696
697 arraylen = avio_rb32(ioc);
698 for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++)
700 depth + 1) < 0)
701 return -1; // if we couldn't skip, bomb out.
702 }
703 break;
705 // timestamp (double) and UTC offset (int16)
707 date.timezone = avio_rb16(ioc);
708 break;
709 default: // unsupported type, we couldn't skip
710 av_log(s, AV_LOG_ERROR, "unsupported amf type %d\n", amf_type);
711 return -1;
712 }
713
714 if (key) {
715 apar = astream ? astream->codecpar : NULL;
716 vpar = vstream ? vstream->codecpar : NULL;
717
718 // stream info doesn't live any deeper than the first object
719 if (depth == 1) {
720 if (amf_type == AMF_DATA_TYPE_NUMBER ||
721 amf_type == AMF_DATA_TYPE_BOOL) {
722 if (!strcmp(key, "duration"))
723 s->duration = num_val * AV_TIME_BASE;
724 else if (!strcmp(key, "videodatarate") &&
725 0 <= (int)(num_val * 1024.0))
726 flv->video_bit_rate = num_val * 1024.0;
727 else if (!strcmp(key, "audiodatarate") &&
728 0 <= (int)(num_val * 1024.0))
729 flv->audio_bit_rate = num_val * 1024.0;
730 else if (!strcmp(key, "framerate")) {
731 flv->framerate = av_d2q(num_val, 1000);
732 if (vstream)
733 vstream->avg_frame_rate = flv->framerate;
734 } else if (flv->trust_metadata) {
735 if (!strcmp(key, "videocodecid") && vpar) {
736 int ret = flv_set_video_codec(s, vstream, num_val, 0);
737 if (ret < 0)
738 return ret;
739 } else if (!strcmp(key, "audiocodecid") && apar) {
740 int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET;
741 int ret = flv_set_audio_codec(s, astream, apar, id);
742 if (ret < 0)
743 return ret;
744 } else if (!strcmp(key, "audiosamplerate") && apar) {
745 apar->sample_rate = num_val;
746 } else if (!strcmp(key, "audiosamplesize") && apar) {
747 apar->bits_per_coded_sample = num_val;
748 } else if (!strcmp(key, "stereo") && apar) {
749 av_channel_layout_default(&apar->ch_layout, num_val + 1);
750 } else if (!strcmp(key, "width") && vpar) {
751 vpar->width = num_val;
752 } else if (!strcmp(key, "height") && vpar) {
753 vpar->height = num_val;
754 } else if (!strcmp(key, "datastream")) {
756 if (!st)
757 return AVERROR(ENOMEM);
759 }
760 }
761 }
762 if (amf_type == AMF_DATA_TYPE_STRING) {
763 if (!strcmp(key, "encoder")) {
764 int version = -1;
765 if (1 == sscanf(str_val, "Open Broadcaster Software v0.%d", &version)) {
766 if (version > 0 && version <= 655)
767 flv->broken_sizes = 1;
768 }
769 } else if (!strcmp(key, "metadatacreator")) {
770 if ( !strcmp (str_val, "MEGA")
771 || !strncmp(str_val, "FlixEngine", 10))
772 flv->broken_sizes = 1;
773 }
774 }
775 }
776
778 FLVMetaVideoColor *meta_video_color = &flv->meta_color_info;
779 if (!strcmp(key, "colorPrimaries")) {
780 meta_video_color->primaries = num_val;
781 } else if (!strcmp(key, "transferCharacteristics")) {
782 meta_video_color->trc = num_val;
783 } else if (!strcmp(key, "matrixCoefficients")) {
784 meta_video_color->matrix_coefficients = num_val;
785 } else if (!strcmp(key, "maxFall")) {
786 meta_video_color->max_fall = num_val;
787 } else if (!strcmp(key, "maxCLL")) {
788 meta_video_color->max_cll = num_val;
789 } else if (!strcmp(key, "redX")) {
790 meta_video_color->mastering_meta.r_x = num_val;
791 } else if (!strcmp(key, "redY")) {
792 meta_video_color->mastering_meta.r_y = num_val;
793 } else if (!strcmp(key, "greenX")) {
794 meta_video_color->mastering_meta.g_x = num_val;
795 } else if (!strcmp(key, "greenY")) {
796 meta_video_color->mastering_meta.g_y = num_val;
797 } else if (!strcmp(key, "blueX")) {
798 meta_video_color->mastering_meta.b_x = num_val;
799 } else if (!strcmp(key, "blueY")) {
800 meta_video_color->mastering_meta.b_y = num_val;
801 } else if (!strcmp(key, "whitePointX")) {
802 meta_video_color->mastering_meta.white_x = num_val;
803 } else if (!strcmp(key, "whitePointY")) {
804 meta_video_color->mastering_meta.white_y = num_val;
805 } else if (!strcmp(key, "maxLuminance")) {
806 meta_video_color->mastering_meta.max_luminance = num_val;
807 } else if (!strcmp(key, "minLuminance")) {
808 meta_video_color->mastering_meta.min_luminance = num_val;
809 }
810 }
811
812 if (amf_type == AMF_DATA_TYPE_OBJECT && s->nb_streams == 1 &&
813 ((!apar && !strcmp(key, "audiocodecid")) ||
814 (!vpar && !strcmp(key, "videocodecid"))))
815 s->ctx_flags &= ~AVFMTCTX_NOHEADER; //If there is either audio/video missing, codecid will be an empty object
816
817 if ((!strcmp(key, "duration") ||
818 !strcmp(key, "filesize") ||
819 !strcmp(key, "width") ||
820 !strcmp(key, "height") ||
821 !strcmp(key, "videodatarate") ||
822 !strcmp(key, "framerate") ||
823 !strcmp(key, "videocodecid") ||
824 !strcmp(key, "audiodatarate") ||
825 !strcmp(key, "audiosamplerate") ||
826 !strcmp(key, "audiosamplesize") ||
827 !strcmp(key, "stereo") ||
828 !strcmp(key, "audiocodecid") ||
829 !strcmp(key, "datastream")) && !flv->dump_full_metadata)
830 return 0;
831
832 s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
833 if (amf_type == AMF_DATA_TYPE_BOOL) {
834 av_strlcpy(str_val, num_val > 0 ? "true" : "false",
835 sizeof(str_val));
836 av_dict_set(&s->metadata, key, str_val, 0);
837 } else if (amf_type == AMF_DATA_TYPE_NUMBER) {
838 snprintf(str_val, sizeof(str_val), "%.f", num_val);
839 av_dict_set(&s->metadata, key, str_val, 0);
840 } else if (amf_type == AMF_DATA_TYPE_STRING) {
841 av_dict_set(&s->metadata, key, str_val, 0);
842 } else if ( amf_type == AMF_DATA_TYPE_DATE
843 && isfinite(date.milliseconds)
844 && date.milliseconds > INT64_MIN/1000
845 && date.milliseconds < INT64_MAX/1000
846 ) {
847 // timezone is ignored, since there is no easy way to offset the UTC
848 // timestamp into the specified timezone
849 ff_dict_set_timestamp(&s->metadata, key, 1000 * (int64_t)date.milliseconds);
850 }
851 }
852
853 return 0;
854}
855
856#define TYPE_ONTEXTDATA 1
857#define TYPE_ONCAPTION 2
858#define TYPE_ONCAPTIONINFO 3
859#define TYPE_UNKNOWN 9
860
862{
863 FLVContext *flv = s->priv_data;
865 AVStream *stream, *astream, *vstream;
866 av_unused AVStream *dstream;
867 AVIOContext *ioc;
868 int i;
869 char buffer[32];
870
871 astream = NULL;
872 vstream = NULL;
873 dstream = NULL;
874 ioc = s->pb;
875
876 // first object needs to be "onMetaData" string
877 type = avio_r8(ioc);
878 if (type != AMF_DATA_TYPE_STRING ||
879 amf_get_string(ioc, buffer, sizeof(buffer)) < 0)
880 return TYPE_UNKNOWN;
881
882 if (!strcmp(buffer, "onTextData"))
883 return TYPE_ONTEXTDATA;
884
885 if (!strcmp(buffer, "onCaption"))
886 return TYPE_ONCAPTION;
887
888 if (!strcmp(buffer, "onCaptionInfo"))
889 return TYPE_ONCAPTIONINFO;
890
891 if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint") && strcmp(buffer, "|RtmpSampleAccess")) {
892 av_log(s, AV_LOG_DEBUG, "Unknown type %s\n", buffer);
893 return TYPE_UNKNOWN;
894 }
895
896 // find the streams now so that amf_parse_object doesn't need to do
897 // the lookup every time it is called.
898 for (i = 0; i < s->nb_streams; i++) {
899 stream = s->streams[i];
900 if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
901 vstream = stream;
903 } else if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
904 astream = stream;
905 if (flv->last_keyframe_stream_index == -1)
907 } else if (stream->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
908 dstream = stream;
909 }
910
911 // parse the second object (we want a mixed array)
912 if (amf_parse_object(s, astream, vstream, buffer, next_pos, 0) < 0)
913 return -1;
914
915 return 0;
916}
917
919{
920 FFFormatContext *const si = ffformatcontext(s);
921 int flags;
922 FLVContext *flv = s->priv_data;
923 int offset;
924 int pre_tag_size = 0;
925
926 /* Actual FLV data at 0xe40000 in KUX file */
927 if(!strcmp(s->iformat->name, "kux"))
928 avio_skip(s->pb, 0xe40000);
929
930 avio_skip(s->pb, 4);
931 flags = avio_r8(s->pb);
932
934
935 s->ctx_flags |= AVFMTCTX_NOHEADER;
936
937 offset = avio_rb32(s->pb);
938 avio_seek(s->pb, offset, SEEK_SET);
939
940 /* Annex E. The FLV File Format
941 * E.3 TheFLVFileBody
942 * Field Type Comment
943 * PreviousTagSize0 UI32 Always 0
944 * */
945 pre_tag_size = avio_rb32(s->pb);
946 if (pre_tag_size) {
947 av_log(s, AV_LOG_WARNING, "Read FLV header error, input file is not a standard flv format, first PreviousTagSize0 always is 0\n");
948 }
949
950 s->start_time = 0;
951 flv->sum_flv_tag_size = 0;
953
954 return 0;
955}
956
958{
959 int i;
960 FLVContext *flv = s->priv_data;
961 for (i = 0; i < FLV_STREAM_TYPE_NB; i++)
962 av_freep(&flv->new_extradata[i]);
963 for (i = 0; i < flv->mt_extradata_cnt; i++)
964 av_freep(&flv->mt_extradata[i]);
965 av_freep(&flv->mt_extradata);
969 return 0;
970}
971
973{
974 int ret;
975 if (!size)
976 return 0;
977
978 if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0)
979 return ret;
981 return 0;
982}
983
984static int flv_queue_extradata(FLVContext *flv, AVIOContext *pb, int stream,
985 int size, int multitrack)
986{
987 if (!size)
988 return 0;
989
990 if (!multitrack) {
991 av_free(flv->new_extradata[stream]);
992 flv->new_extradata[stream] = av_mallocz(size +
994 if (!flv->new_extradata[stream])
995 return AVERROR(ENOMEM);
996 flv->new_extradata_size[stream] = size;
997 avio_read(pb, flv->new_extradata[stream], size);
998 } else {
999 int new_count = stream + 1;
1000
1001 if (flv->mt_extradata_cnt < new_count) {
1002 void *tmp = av_realloc_array(flv->mt_extradata, new_count,
1003 sizeof(*flv->mt_extradata));
1004 if (!tmp)
1005 return AVERROR(ENOMEM);
1006 flv->mt_extradata = tmp;
1007
1008 tmp = av_realloc_array(flv->mt_extradata_sz, new_count,
1009 sizeof(*flv->mt_extradata_sz));
1010 if (!tmp)
1011 return AVERROR(ENOMEM);
1012 flv->mt_extradata_sz = tmp;
1013
1014 // Set newly allocated pointers/sizes to 0
1015 for (int i = flv->mt_extradata_cnt; i < new_count; i++) {
1016 flv->mt_extradata[i] = NULL;
1017 flv->mt_extradata_sz[i] = 0;
1018 }
1019 flv->mt_extradata_cnt = new_count;
1020 }
1021
1022 av_free(flv->mt_extradata[stream]);
1024 if (!flv->mt_extradata[stream])
1025 return AVERROR(ENOMEM);
1026 flv->mt_extradata_sz[stream] = size;
1027 avio_read(pb, flv->mt_extradata[stream], size);
1028 }
1029
1030 return 0;
1031}
1032
1034{
1036 "Found invalid index entries, clearing the index.\n");
1037 for (unsigned i = 0; i < s->nb_streams; i++) {
1038 FFStream *const sti = ffstream(s->streams[i]);
1039 int out = 0;
1040 /* Remove all index entries that point to >= pos */
1041 for (int j = 0; j < sti->nb_index_entries; j++)
1042 if (sti->index_entries[j].pos < pos)
1043 sti->index_entries[out++] = sti->index_entries[j];
1044 sti->nb_index_entries = out;
1045 }
1046}
1047
1048static int amf_skip_tag(AVIOContext *pb, AMFDataType type, int depth)
1049{
1050 int nb = -1, ret, parse_name = 1;
1051
1052 if (depth > MAX_DEPTH)
1053 return AVERROR_PATCHWELCOME;
1054
1055 if (avio_feof(pb))
1056 return AVERROR_EOF;
1057
1058 switch (type) {
1060 avio_skip(pb, 8);
1061 break;
1062 case AMF_DATA_TYPE_BOOL:
1063 avio_skip(pb, 1);
1064 break;
1066 avio_skip(pb, avio_rb16(pb));
1067 break;
1069 parse_name = 0;
1072 nb = avio_rb32(pb);
1073 if (nb < 0)
1074 return AVERROR_INVALIDDATA;
1077 while(!pb->eof_reached && (nb-- > 0 || type != AMF_DATA_TYPE_ARRAY)) {
1078 if (parse_name) {
1079 int size = avio_rb16(pb);
1080 if (!size) {
1081 avio_skip(pb, 1);
1082 break;
1083 }
1084 avio_skip(pb, size);
1085 }
1086 if ((ret = amf_skip_tag(pb, avio_r8(pb), depth + 1)) < 0)
1087 return ret;
1088 }
1089 break;
1090 case AMF_DATA_TYPE_NULL:
1092 break;
1093 default:
1094 return AVERROR_INVALIDDATA;
1095 }
1096 return 0;
1097}
1098
1100 int64_t dts, int64_t next)
1101{
1102 AVIOContext *pb = s->pb;
1103 AVStream *st = NULL;
1104 char buf[20];
1106 int i, length = -1;
1107 int array = 0;
1108
1109 switch (avio_r8(pb)) {
1111 array = 1;
1114 avio_seek(pb, 4, SEEK_CUR);
1117 break;
1118 default:
1119 goto skip;
1120 }
1121
1122 while (array || (ret = amf_get_string(pb, buf, sizeof(buf))) > 0) {
1123 AMFDataType type = avio_r8(pb);
1124 if (type == AMF_DATA_TYPE_STRING && (array || !strcmp(buf, "text"))) {
1125 length = avio_rb16(pb);
1126 ret = av_get_packet(pb, pkt, length);
1127 if (ret < 0)
1128 goto skip;
1129 else
1130 break;
1131 } else {
1132 if ((ret = amf_skip_tag(pb, type, 0)) < 0)
1133 goto skip;
1134 }
1135 }
1136
1137 if (length < 0) {
1139 goto skip;
1140 }
1141
1142 for (i = 0; i < s->nb_streams; i++) {
1143 st = s->streams[i];
1145 break;
1146 }
1147
1148 if (i == s->nb_streams) {
1150 if (!st)
1151 return AVERROR(ENOMEM);
1153 }
1154
1155 pkt->dts = dts;
1156 pkt->pts = dts;
1157 pkt->size = ret;
1158
1159 pkt->stream_index = st->index;
1160 pkt->flags |= AV_PKT_FLAG_KEY;
1161
1162skip:
1163 avio_seek(s->pb, next + 4, SEEK_SET);
1164
1165 return ret;
1166}
1167
1169{
1170 FLVContext *flv = s->priv_data;
1171 int64_t i;
1172 int64_t pos = avio_tell(s->pb);
1173
1174 for (i=0; !avio_feof(s->pb); i++) {
1175 int j = i & (RESYNC_BUFFER_SIZE-1);
1176 int j1 = j + RESYNC_BUFFER_SIZE;
1177 flv->resync_buffer[j ] =
1178 flv->resync_buffer[j1] = avio_r8(s->pb);
1179
1180 if (i >= 8 && pos) {
1181 uint8_t *d = flv->resync_buffer + j1 - 8;
1182 if (d[0] == 'F' &&
1183 d[1] == 'L' &&
1184 d[2] == 'V' &&
1185 d[3] < 5 && d[5] == 0) {
1186 av_log(s, AV_LOG_WARNING, "Concatenated FLV detected, might fail to demux, decode and seek %"PRId64"\n", flv->last_ts);
1187 flv->time_offset = flv->last_ts + 1;
1188 flv->time_pos = avio_tell(s->pb);
1189 }
1190 }
1191
1192 if (i > 22) {
1193 unsigned lsize2 = AV_RB32(flv->resync_buffer + j1 - 4);
1194 if (lsize2 >= 11 && lsize2 + 8LL < FFMIN(i, RESYNC_BUFFER_SIZE)) {
1195 unsigned size2 = AV_RB24(flv->resync_buffer + j1 - lsize2 + 1 - 4);
1196 unsigned lsize1 = AV_RB32(flv->resync_buffer + j1 - lsize2 - 8);
1197 if (lsize1 >= 11 && lsize1 + 8LL + lsize2 < FFMIN(i, RESYNC_BUFFER_SIZE)) {
1198 unsigned size1 = AV_RB24(flv->resync_buffer + j1 - lsize1 + 1 - lsize2 - 8);
1199 if (size1 == lsize1 - 11 && size2 == lsize2 - 11) {
1200 avio_seek(s->pb, pos + i - lsize1 - lsize2 - 8, SEEK_SET);
1201 return 1;
1202 }
1203 }
1204 }
1205 }
1206 }
1207 return AVERROR_EOF;
1208}
1209
1211{
1212 int ret;
1213 FLVContext *flv = s->priv_data;
1215 AVIOContext *ioc;
1216 char buffer[32];
1217 ioc = s->pb;
1218
1219 // first object needs to be "colorInfo" string
1220 type = avio_r8(ioc);
1221 if (type != AMF_DATA_TYPE_STRING) {
1222 av_log(s, AV_LOG_WARNING, "Ignore invalid colorInfo\n");
1223 return 0;
1224 }
1225
1226 ret = amf_get_string(ioc, buffer, sizeof(buffer));
1227 if (ret < 0)
1228 return ret;
1229
1230 if (strcmp(buffer, "colorInfo") != 0) {
1231 av_log(s, AV_LOG_WARNING, "Ignore invalid colorInfo type %s\n", buffer);
1232 return 0;
1233 }
1234
1236 ret = amf_parse_object(s, NULL, NULL, buffer, next_pos, 0); // parse metadata
1237 if (ret < 0) {
1239 return ret;
1240 }
1241
1243
1244 return 0;
1245}
1246
1248{
1249 FLVContext *flv = s->priv_data;
1250 const FLVMetaVideoColor* meta_video_color = &flv->meta_color_info;
1251 const FLVMasteringMeta *mastering_meta = &meta_video_color->mastering_meta;
1252
1253 int has_mastering_primaries, has_mastering_luminance;
1254 // Mastering primaries are CIE 1931 coords, and must be > 0.
1255 has_mastering_primaries =
1256 mastering_meta->r_x > 0 && mastering_meta->r_y > 0 &&
1257 mastering_meta->g_x > 0 && mastering_meta->g_y > 0 &&
1258 mastering_meta->b_x > 0 && mastering_meta->b_y > 0 &&
1259 mastering_meta->white_x > 0 && mastering_meta->white_y > 0;
1260 has_mastering_luminance = mastering_meta->max_luminance > 0 && mastering_meta->min_luminance > 0;
1261
1262 if (meta_video_color->matrix_coefficients != AVCOL_SPC_RESERVED)
1263 st->codecpar->color_space = meta_video_color->matrix_coefficients;
1264 if (meta_video_color->primaries != AVCOL_PRI_RESERVED &&
1265 meta_video_color->primaries != AVCOL_PRI_RESERVED0)
1266 st->codecpar->color_primaries = meta_video_color->primaries;
1267 if (meta_video_color->trc != AVCOL_TRC_RESERVED &&
1268 meta_video_color->trc != AVCOL_TRC_RESERVED0)
1269 st->codecpar->color_trc = meta_video_color->trc;
1270
1271 if (meta_video_color->max_cll && meta_video_color->max_fall) {
1272 size_t size = 0;
1274 if (!metadata)
1275 return AVERROR(ENOMEM);
1279 return AVERROR(ENOMEM);
1280 }
1281 metadata->MaxCLL = meta_video_color->max_cll;
1282 metadata->MaxFALL = meta_video_color->max_fall;
1283 }
1284
1285 if (has_mastering_primaries || has_mastering_luminance) {
1286 size_t size = 0;
1288 AVPacketSideData *sd;
1289
1290 if (!metadata)
1291 return AVERROR(ENOMEM);
1292
1296 metadata, size, 0);
1297 if (!sd) {
1299 return AVERROR(ENOMEM);
1300 }
1301
1302 // hdrCll
1303 if (has_mastering_luminance) {
1304 metadata->max_luminance = av_d2q(mastering_meta->max_luminance, INT_MAX);
1305 metadata->min_luminance = av_d2q(mastering_meta->min_luminance, INT_MAX);
1306 metadata->has_luminance = 1;
1307 }
1308 // hdrMdcv
1309 if (has_mastering_primaries) {
1310 metadata->display_primaries[0][0] = av_d2q(mastering_meta->r_x, INT_MAX);
1311 metadata->display_primaries[0][1] = av_d2q(mastering_meta->r_y, INT_MAX);
1312 metadata->display_primaries[1][0] = av_d2q(mastering_meta->g_x, INT_MAX);
1313 metadata->display_primaries[1][1] = av_d2q(mastering_meta->g_y, INT_MAX);
1314 metadata->display_primaries[2][0] = av_d2q(mastering_meta->b_x, INT_MAX);
1315 metadata->display_primaries[2][1] = av_d2q(mastering_meta->b_y, INT_MAX);
1316 metadata->white_point[0] = av_d2q(mastering_meta->white_x, INT_MAX);
1317 metadata->white_point[1] = av_d2q(mastering_meta->white_y, INT_MAX);
1318 metadata->has_primaries = 1;
1319 }
1320 }
1321 return 0;
1322}
1323
1324static int flv_parse_mod_ex_data(AVFormatContext *s, int *pkt_type, int *size, int64_t *dts)
1325{
1326 int ex_type, ret;
1327 uint8_t *ex_data;
1328
1329 int ex_size = (uint8_t)avio_r8(s->pb) + 1;
1330 *size -= 1;
1331
1332 if (ex_size == 256) {
1333 ex_size = (uint16_t)avio_rb16(s->pb) + 1;
1334 *size -= 2;
1335 }
1336
1337 if (ex_size >= *size) {
1338 av_log(s, AV_LOG_WARNING, "ModEx size larger than remaining data!\n");
1339 return AVERROR(EINVAL);
1340 }
1341
1342 ex_data = av_malloc(ex_size);
1343 if (!ex_data)
1344 return AVERROR(ENOMEM);
1345
1346 ret = ffio_read_size(s->pb, ex_data, ex_size);
1347 if (ret < 0) {
1348 av_free(ex_data);
1349 return ret;
1350 }
1351 *size -= ex_size;
1352
1353 ex_type = (uint8_t)avio_r8(s->pb);
1354 *size -= 1;
1355
1356 *pkt_type = ex_type & 0x0f;
1357 ex_type &= 0xf0;
1358
1359 if (ex_type == PacketModExTypeTimestampOffsetNano) {
1360 uint32_t nano_offset;
1361
1362 if (ex_size != 3) {
1363 av_log(s, AV_LOG_WARNING, "Invalid ModEx size for Type TimestampOffsetNano!\n");
1364 nano_offset = 0;
1365 } else {
1366 nano_offset = (ex_data[0] << 16) | (ex_data[1] << 8) | ex_data[2];
1367 }
1368
1369 // this is not likely to ever add anything, but right now timestamps are with ms precision
1370 *dts += nano_offset / 1000000;
1371 } else {
1372 av_log(s, AV_LOG_INFO, "Unknown ModEx type: %d", ex_type);
1373 }
1374
1375 av_free(ex_data);
1376
1377 return 0;
1378}
1379
1381{
1382 FLVContext *flv = s->priv_data;
1383 int ret = AVERROR_BUG, i, size, flags;
1384 int res = 0;
1385 enum FlvTagType type;
1386 int stream_type = -1;
1387 int64_t next, pos, meta_pos;
1388 int64_t dts, pts = AV_NOPTS_VALUE;
1389 int av_uninit(channels);
1390 int av_uninit(sample_rate);
1391 AVStream *st = NULL;
1392 int last = -1;
1393 int orig_size;
1394 int enhanced_flv = 0;
1395 int multitrack = 0;
1396 int pkt_type = 0;
1397 uint8_t track_idx = 0;
1398 uint32_t codec_id = 0;
1399 int multitrack_type = MultitrackTypeOneTrack;
1400
1401retry:
1402 /* pkt size is repeated at end. skip it */
1403 pos = avio_tell(s->pb);
1404 type = (avio_r8(s->pb) & 0x1F);
1405 orig_size =
1406 size = avio_rb24(s->pb);
1407 flv->sum_flv_tag_size += size + 11LL;
1408 dts = avio_rb24(s->pb);
1409 dts |= (unsigned)avio_r8(s->pb) << 24;
1410 av_log(s, AV_LOG_TRACE, "type:%d, size:%d, last:%d, dts:%"PRId64" pos:%"PRId64"\n", type, size, last, dts, avio_tell(s->pb));
1411 if (avio_feof(s->pb))
1412 return AVERROR_EOF;
1413 avio_skip(s->pb, 3); /* stream id, always 0 */
1414 flags = 0;
1415
1416 if (flv->validate_next < flv->validate_count) {
1417 int64_t validate_pos = flv->validate_index[flv->validate_next].pos;
1418 if (pos == validate_pos) {
1419 if (FFABS(dts - flv->validate_index[flv->validate_next].dts) <=
1421 flv->validate_next++;
1422 } else {
1423 clear_index_entries(s, validate_pos);
1424 flv->validate_count = 0;
1425 }
1426 } else if (pos > validate_pos) {
1427 clear_index_entries(s, validate_pos);
1428 flv->validate_count = 0;
1429 }
1430 }
1431
1432 if (size == 0) {
1433 ret = FFERROR_REDO;
1434 goto leave;
1435 }
1436
1437 next = size + avio_tell(s->pb);
1438
1439 if (type == FLV_TAG_TYPE_AUDIO) {
1440 stream_type = FLV_STREAM_TYPE_AUDIO;
1441 flags = avio_r8(s->pb);
1442 size--;
1443
1445 enhanced_flv = 1;
1446 pkt_type = flags & ~FLV_AUDIO_CODECID_MASK;
1447
1448 while (pkt_type == PacketTypeModEx) {
1449 ret = flv_parse_mod_ex_data(s, &pkt_type, &size, &dts);
1450 if (ret < 0)
1451 goto leave;
1452 }
1453
1454 if (pkt_type == AudioPacketTypeMultitrack) {
1455 uint8_t types = avio_r8(s->pb);
1456 multitrack_type = types & 0xF0;
1457 pkt_type = types & 0xF;
1458
1459 multitrack = 1;
1460 size--;
1461 }
1462
1463 codec_id = avio_rb32(s->pb);
1464 size -= 4;
1465
1466 if (multitrack) {
1467 track_idx = avio_r8(s->pb);
1468 size--;
1469 }
1470 }
1471 } else if (type == FLV_TAG_TYPE_VIDEO) {
1472 stream_type = FLV_STREAM_TYPE_VIDEO;
1473 flags = avio_r8(s->pb);
1475 /*
1476 * Reference Enhancing FLV 2023-03-v1.0.0-B.8
1477 * https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
1478 * */
1479 enhanced_flv = (flags >> 7) & 1;
1480 pkt_type = enhanced_flv ? codec_id : 0;
1481 size--;
1482
1483 while (pkt_type == PacketTypeModEx) {
1484 ret = flv_parse_mod_ex_data(s, &pkt_type, &size, &dts);
1485 if (ret < 0)
1486 goto leave;
1487 }
1488
1489 if (enhanced_flv && pkt_type != PacketTypeMetadata &&
1491 goto skip;
1492
1493 if (pkt_type == PacketTypeMultitrack) {
1494 uint8_t types = avio_r8(s->pb);
1495 multitrack_type = types & 0xF0;
1496 pkt_type = types & 0xF;
1497
1498 multitrack = 1;
1499 size--;
1500 }
1501
1502 if (enhanced_flv) {
1503 codec_id = avio_rb32(s->pb);
1504 size -= 4;
1505 }
1506 if (multitrack) {
1507 track_idx = avio_r8(s->pb);
1508 size--;
1509 }
1510
1511 if (enhanced_flv && (flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_VIDEO_INFO_CMD) {
1512 if (pkt_type == PacketTypeMetadata) {
1513 ret = flv_parse_video_color_info(s, st, next);
1514 if (ret < 0)
1515 goto leave;
1516 }
1517 goto skip;
1519 goto skip;
1520 }
1521 } else if (type == FLV_TAG_TYPE_META) {
1522 stream_type=FLV_STREAM_TYPE_SUBTITLE;
1523 if (size > 13 + 1 + 4) { // Header-type metadata stuff
1524 int type;
1525 meta_pos = avio_tell(s->pb);
1526 type = flv_read_metabody(s, next);
1527 if (type == 0 && dts == 0 || type < 0) {
1528 if (type < 0 && flv->validate_count &&
1529 flv->validate_index[0].pos > next &&
1530 flv->validate_index[0].pos - 4 < next) {
1531 av_log(s, AV_LOG_WARNING, "Adjusting next position due to index mismatch\n");
1532 next = flv->validate_index[0].pos - 4;
1533 }
1534 goto skip;
1535 } else if (type == TYPE_ONTEXTDATA) {
1536 avpriv_request_sample(s, "OnTextData packet");
1537 return flv_data_packet(s, pkt, dts, next);
1538 } else if (type == TYPE_ONCAPTION) {
1539 return flv_data_packet(s, pkt, dts, next);
1540 } else if (type == TYPE_UNKNOWN) {
1541 stream_type = FLV_STREAM_TYPE_DATA;
1542 }
1543 avio_seek(s->pb, meta_pos, SEEK_SET);
1544 }
1545 } else {
1547 "Skipping flv packet: type %d, size %d, flags %d.\n",
1548 type, size, flags);
1549skip:
1550 if (avio_seek(s->pb, next, SEEK_SET) != next) {
1551 // This can happen if flv_read_metabody above read past
1552 // next, on a non-seekable input, and the preceding data has
1553 // been flushed out from the IO buffer.
1554 av_log(s, AV_LOG_ERROR, "Unable to seek to the next packet\n");
1555 return AVERROR_INVALIDDATA;
1556 }
1557 ret = FFERROR_REDO;
1558 goto leave;
1559 }
1560
1561 /* skip empty data packets */
1562 if (!size) {
1563 ret = FFERROR_REDO;
1564 goto leave;
1565 }
1566
1567 for (;;) {
1568 int track_size = size;
1569 if (size < 0) {
1570 ret = FFERROR_REDO;
1571 goto leave;
1572 }
1573
1574 if (multitrack_type != MultitrackTypeOneTrack) {
1575 track_size = avio_rb24(s->pb);
1576 size -= 3;
1577 }
1578
1579 /* now find stream */
1580 for (i = 0; i < s->nb_streams; i++) {
1581 st = s->streams[i];
1582 if (stream_type == FLV_STREAM_TYPE_AUDIO) {
1584 (s->audio_codec_id || flv_same_audio_codec(st->codecpar, flags, codec_id)) &&
1585 st->id == track_idx)
1586 break;
1587 } else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
1589 (s->video_codec_id || flv_same_video_codec(st->codecpar, codec_id)) &&
1590 st->id == track_idx)
1591 break;
1592 } else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) {
1594 break;
1595 } else if (stream_type == FLV_STREAM_TYPE_DATA) {
1597 break;
1598 }
1599 }
1600 if (i == s->nb_streams) {
1602 st = create_stream(s, stream_types[stream_type], track_idx);
1603 if (!st)
1604 return AVERROR(ENOMEM);
1605 }
1606 av_log(s, AV_LOG_TRACE, "%d %X %d \n", stream_type, flags, st->discard);
1607
1608 if (flv->time_pos <= pos) {
1609 dts += flv->time_offset;
1610 }
1611
1612 if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
1614 stream_type == FLV_STREAM_TYPE_AUDIO))
1615 av_add_index_entry(st, pos, dts, track_size, 0, AVINDEX_KEYFRAME);
1616
1617 if ((st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || stream_type == FLV_STREAM_TYPE_AUDIO)) ||
1619 st->discard >= AVDISCARD_ALL) {
1620 avio_seek(s->pb, next, SEEK_SET);
1621 ret = FFERROR_REDO;
1622 goto leave;
1623 }
1624
1625 // if not streamed and no duration from metadata then seek to end to find
1626 // the duration from the timestamps
1627 if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
1628 (!s->duration || s->duration == AV_NOPTS_VALUE) &&
1629 !flv->searched_for_end) {
1630 int final_size;
1631 const int64_t pos = avio_tell(s->pb);
1632 // Read the last 4 bytes of the file, this should be the size of the
1633 // previous FLV tag. Use the timestamp of its payload as duration.
1634 int64_t fsize = avio_size(s->pb);
1635retry_duration:
1636 avio_seek(s->pb, fsize - 4, SEEK_SET);
1637 final_size = avio_rb32(s->pb);
1638 if (final_size > 0 && final_size < fsize) {
1639 // Seek to the start of the last FLV tag at position (fsize - 4 - final_size)
1640 // but skip the byte indicating the type.
1641 avio_seek(s->pb, fsize - 3 - final_size, SEEK_SET);
1642 if (final_size == avio_rb24(s->pb) + 11) {
1643 uint32_t ts = avio_rb24(s->pb);
1644 ts |= (unsigned)avio_r8(s->pb) << 24;
1645 if (ts)
1646 s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
1647 else if (fsize >= 8 && fsize - 8 >= final_size) {
1648 fsize -= final_size+4;
1649 goto retry_duration;
1650 }
1651 }
1652 }
1653
1654 avio_seek(s->pb, pos, SEEK_SET);
1655 flv->searched_for_end = 1;
1656 }
1657
1658 if (stream_type == FLV_STREAM_TYPE_AUDIO && !enhanced_flv) {
1659 int bits_per_coded_sample;
1661 sample_rate = 44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >>
1663 bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
1665 !st->codecpar->sample_rate ||
1669 st->codecpar->sample_rate = sample_rate;
1670 st->codecpar->bits_per_coded_sample = bits_per_coded_sample;
1671 }
1672 if (!st->codecpar->codec_id) {
1673 ret = flv_set_audio_codec(s, st, st->codecpar,
1675 if (ret < 0)
1676 goto leave;
1677 flv->last_sample_rate =
1678 sample_rate = st->codecpar->sample_rate;
1679 flv->last_channels =
1681 } else {
1683 if (!par) {
1684 ret = AVERROR(ENOMEM);
1685 goto leave;
1686 }
1687 par->sample_rate = sample_rate;
1688 par->bits_per_coded_sample = bits_per_coded_sample;
1690 if (ret < 0)
1691 goto leave;
1692 sample_rate = par->sample_rate;
1694 }
1695 } else if (stream_type == FLV_STREAM_TYPE_AUDIO) {
1696 if (!st->codecpar->codec_id) {
1697 ret = flv_set_audio_codec(s, st, st->codecpar,
1699 if (ret < 0)
1700 goto leave;
1701 }
1702
1703 // These are not signalled in the flags anymore
1704 channels = 0;
1705 sample_rate = 0;
1706
1707 if (pkt_type == AudioPacketTypeMultichannelConfig) {
1708 int channel_order = avio_r8(s->pb);
1709 channels = avio_r8(s->pb);
1710 size -= 2;
1711 track_size -= 2;
1712
1714
1715 if (channel_order == AudioChannelOrderCustom) {
1717 if (ret < 0)
1718 return ret;
1719
1720 for (i = 0; i < channels; i++) {
1721 uint8_t id = avio_r8(s->pb);
1722 size--;
1723 track_size--;
1724
1725 if (id < 18)
1726 st->codecpar->ch_layout.u.map[i].id = id;
1727 else if (id >= 18 && id <= 23)
1729 else if (id == 0xFE)
1731 else
1733 }
1734 } else if (channel_order == AudioChannelOrderNative) {
1735 uint64_t mask = avio_rb32(s->pb);
1736 size -= 4;
1737 track_size -= 4;
1738
1739 // The first 18 entries in the mask match ours, but the remaining 6 entries start at AV_CHAN_LOW_FREQUENCY_2
1740 mask = (mask & 0x3FFFF) | ((mask & 0xFC0000) << (AV_CHAN_LOW_FREQUENCY_2 - 18));
1742 if (ret < 0)
1743 return ret;
1744 } else {
1746 }
1747
1748 av_log(s, AV_LOG_DEBUG, "Set channel data from MultiChannel info.\n");
1749
1750 goto next_track;
1751 }
1752 } else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
1753 int sret = flv_set_video_codec(s, st, codec_id, 1);
1754 if (sret < 0)
1755 return sret;
1756 size -= sret;
1757 track_size -= sret;
1758 } else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) {
1760 } else if (stream_type == FLV_STREAM_TYPE_DATA) {
1761 st->codecpar->codec_id = AV_CODEC_ID_NONE; // Opaque AMF data
1762 }
1763
1764 if (st->codecpar->codec_id == AV_CODEC_ID_AAC ||
1773 int type = 0;
1774 if (enhanced_flv) {
1775 type = pkt_type;
1776 } else {
1777 type = avio_r8(s->pb);
1778 size--;
1779 track_size--;
1780 }
1781
1782 if (size < 0 || track_size < 0) {
1784 goto leave;
1785 }
1786
1787 if (enhanced_flv && stream_type == FLV_STREAM_TYPE_VIDEO &&
1789 flv_update_video_color_info(s, st); // update av packet side data
1791 }
1792
1793 if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
1797 (!enhanced_flv || type == PacketTypeCodedFrames))) {
1798 if (size < 3 || track_size < 3) {
1800 goto leave;
1801 }
1802 // sign extension
1803 int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
1804 pts = av_sat_add64(dts, cts);
1805 if (cts < 0) { // dts might be wrong
1806 if (!flv->wrong_dts)
1808 "Negative cts, previous timestamps might be wrong.\n");
1809 flv->wrong_dts = 1;
1810 } else if (FFABS(dts - pts) > 1000*60*15) {
1812 "invalid timestamps %"PRId64" %"PRId64"\n", dts, pts);
1813 dts = pts = AV_NOPTS_VALUE;
1814 }
1815 size -= 3;
1816 track_size -= 3;
1817 }
1818 if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC ||
1824
1825 if (st->codecpar->extradata) {
1826 if ((ret = flv_queue_extradata(flv, s->pb, multitrack ? track_idx : stream_type, track_size, multitrack)) < 0)
1827 return ret;
1828 ret = FFERROR_REDO;
1829 goto leave;
1830 }
1831 if ((ret = flv_get_extradata(s, st, track_size)) < 0)
1832 return ret;
1833
1834 /* Workaround for buggy Omnia A/XE encoder */
1835 t = av_dict_get(s->metadata, "Encoder", NULL, 0);
1836 if (st->codecpar->codec_id == AV_CODEC_ID_AAC && t && !strcmp(t->value, "Omnia A/XE"))
1837 st->codecpar->extradata_size = 2;
1838
1839 ret = FFERROR_REDO;
1840 goto leave;
1841 }
1842 }
1843
1844 /* skip empty or broken data packets */
1845 if (size <= 0 || track_size < 0) {
1846 ret = FFERROR_REDO;
1847 goto leave;
1848 }
1849
1850 /* skip empty data track */
1851 if (!track_size)
1852 goto next_track;
1853
1854 ret = av_get_packet(s->pb, pkt, track_size);
1855 if (ret < 0)
1856 return ret;
1857
1858 track_size -= ret;
1859 size -= ret;
1860
1861 pkt->dts = dts;
1862 pkt->pts = pts == AV_NOPTS_VALUE ? dts : pts;
1863 pkt->stream_index = st->index;
1864 pkt->pos = pos;
1865 if (!multitrack && flv->new_extradata[stream_type]) {
1867 flv->new_extradata[stream_type],
1868 flv->new_extradata_size[stream_type]);
1869 if (ret < 0)
1870 return ret;
1871
1872 flv->new_extradata[stream_type] = NULL;
1873 flv->new_extradata_size[stream_type] = 0;
1874 } else if (multitrack &&
1875 flv->mt_extradata_cnt > track_idx &&
1876 flv->mt_extradata[track_idx]) {
1878 flv->mt_extradata[track_idx],
1879 flv->mt_extradata_sz[track_idx]);
1880 if (ret < 0)
1881 return ret;
1882
1883 flv->mt_extradata[track_idx] = NULL;
1884 flv->mt_extradata_sz[track_idx] = 0;
1885 }
1886 if (stream_type == FLV_STREAM_TYPE_AUDIO && !enhanced_flv &&
1887 (sample_rate != flv->last_sample_rate ||
1888 channels != flv->last_channels)) {
1889 flv->last_sample_rate = sample_rate;
1890 flv->last_channels = channels;
1891 ff_add_param_change(pkt, channels, 0, sample_rate, 0, 0);
1892 }
1893
1894 if (stream_type == FLV_STREAM_TYPE_AUDIO ||
1896 stream_type == FLV_STREAM_TYPE_SUBTITLE ||
1897 stream_type == FLV_STREAM_TYPE_DATA)
1898 pkt->flags |= AV_PKT_FLAG_KEY;
1899
1901 if (ret < 0)
1902 return ret;
1903 res = FFERROR_REDO;
1904
1905next_track:
1906 if (track_size) {
1907 av_log(s, AV_LOG_WARNING, "Track size mismatch: %d!\n", track_size);
1908 if (!avio_feof(s->pb)) {
1909 if (track_size > 0) {
1910 avio_skip(s->pb, track_size);
1911 size -= track_size;
1912 } else {
1913 /* We have somehow read more than the track had to offer, leave and re-sync */
1914 ret = FFERROR_REDO;
1915 goto leave;
1916 }
1917 }
1918 }
1919
1920 if (!size)
1921 break;
1922
1923 if (multitrack_type == MultitrackTypeOneTrack) {
1924 av_log(s, AV_LOG_ERROR, "Attempted to read next track in single-track mode.\n");
1925 ret = FFERROR_REDO;
1926 goto leave;
1927 }
1928
1929 if (multitrack_type == MultitrackTypeManyTracksManyCodecs) {
1930 codec_id = avio_rb32(s->pb);
1931 size -= 4;
1932 }
1933
1934 track_idx = avio_r8(s->pb);
1935 size--;
1936
1937 if (avio_feof(s->pb)) {
1938 av_log(s, AV_LOG_WARNING, "Premature EOF\n");
1939 /* return REDO so that any potentially queued up packages can be drained first */
1940 return FFERROR_REDO;
1941 }
1942 }
1943
1944 ret = 0;
1945leave:
1946 last = avio_rb32(s->pb);
1947 if (!flv->trust_datasize) {
1948 if (last != orig_size + 11 && last != orig_size + 10 &&
1949 !avio_feof(s->pb) &&
1950 (last != orig_size || !last) && last != flv->sum_flv_tag_size &&
1951 !flv->broken_sizes) {
1952 av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %"PRId64"\n", last, orig_size + 11, flv->sum_flv_tag_size);
1953 avio_seek(s->pb, pos + 1, SEEK_SET);
1954 ret = resync(s);
1956 if (ret >= 0) {
1957 goto retry;
1958 }
1959 }
1960 }
1961
1962 if (ret >= 0)
1963 flv->last_ts = pkt->dts;
1964
1965 return ret ? ret : res;
1966}
1967
1968static int flv_read_seek(AVFormatContext *s, int stream_index,
1969 int64_t ts, int flags)
1970{
1971 FLVContext *flv = s->priv_data;
1972 flv->validate_count = 0;
1973 return avio_seek_time(s->pb, stream_index, ts, flags);
1974}
1975
1976#define OFFSET(x) offsetof(FLVContext, x)
1977#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1978static const AVOption options[] = {
1979 { "flv_metadata", "Allocate streams according to the onMetaData array", OFFSET(trust_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
1980 { "flv_full_metadata", "Dump full metadata of the onMetadata", OFFSET(dump_full_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
1981 { "flv_ignore_prevtag", "Ignore the Size of previous tag", OFFSET(trust_datasize), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
1982 { NULL }
1983};
1984
1985static const AVClass flv_kux_class = {
1986 .class_name = "(live) flv/kux demuxer",
1987 .item_name = av_default_item_name,
1988 .option = options,
1989 .version = LIBAVUTIL_VERSION_INT,
1990};
1991
1993 .p.name = "flv",
1994 .p.long_name = NULL_IF_CONFIG_SMALL("FLV (Flash Video)"),
1995 .p.extensions = "flv",
1996 .p.priv_class = &flv_kux_class,
1997 .priv_data_size = sizeof(FLVContext),
2003};
2004
2006 .p.name = "live_flv",
2007 .p.long_name = NULL_IF_CONFIG_SMALL("live RTMP FLV (Flash Video)"),
2008 .p.extensions = "flv",
2009 .p.priv_class = &flv_kux_class,
2010 .p.flags = AVFMT_TS_DISCONT,
2011 .priv_data_size = sizeof(FLVContext),
2017};
2018
2020 .p.name = "kux",
2021 .p.long_name = NULL_IF_CONFIG_SMALL("KUX (YouKu)"),
2022 .p.extensions = "kux",
2023 .p.priv_class = &flv_kux_class,
2024 .priv_data_size = sizeof(FLVContext),
2030};
const FFInputFormat ff_live_flv_demuxer
Definition flvdec.c:2005
const FFInputFormat ff_flv_demuxer
Definition flvdec.c:1992
const FFInputFormat ff_kux_demuxer
Definition flvdec.c:2019
#define VD
Definition amfdec.c:787
static FILE * out
static void finish(void)
channels
Definition aptx.h:31
int32_t
static int64_t fsize(FILE *f)
Definition audiomatch.c:29
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition avformat.c:865
Main libavformat public API header.
#define AVFMT_EVENT_FLAG_METADATA_UPDATED
Definition avformat.h:1796
#define AVINDEX_KEYFRAME
Definition avformat.h:630
#define AVPROBE_SCORE_MAX
maximum score
Definition avformat.h:485
#define AVFMT_FLAG_IGNIDX
Ignore index.
Definition avformat.h:1555
#define AVFMTCTX_NOHEADER
signal that no header is present (streams are added dynamically)
Definition avformat.h:1352
#define AVFMT_TS_DISCONT
Format allows timestamp discontinuities.
Definition avformat.h:502
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition avformat.h:483
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition utils.c:98
@ AVSTREAM_PARSE_HEADERS
Only parse headers, do not repack.
Definition avformat.h:614
@ AVSTREAM_PARSE_FULL
full parsing and repack
Definition avformat.h:613
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition aviobuf.c:236
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition avio.h:41
uint64_t avio_rb64(AVIOContext *s)
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition aviobuf.c:326
unsigned int avio_rb16(AVIOContext *s)
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition aviobuf.c:349
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition avio.h:507
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition aviobuf.c:321
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:620
int64_t avio_seek_time(AVIOContext *h, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp relative to some component stream.
Definition aviobuf.c:1203
unsigned int avio_rb24(AVIOContext *s)
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
Definition aviobuf.c:611
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:674
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static uint32_t BS_FUNC read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
Public libavutil channel layout APIs header.
AVCodecParameters * avcodec_parameters_alloc(void)
Definition codec_par.c:57
void avcodec_parameters_free(AVCodecParameters **ppar)
Definition codec_par.c:67
#define av_sat_add64
Definition common.h:139
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition common.h:74
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt)
Definition demux.c:645
int ff_add_param_change(AVPacket *pkt, int32_t channels, uint64_t channel_layout, int32_t sample_rate, int32_t width, int32_t height)
Add side data to a packet for changing parameters to the given values.
#define FFERROR_REDO
Returned by demuxers to indicate that data was consumed but discarded (ignored streams or junk data).
Definition demux.h:234
int ff_get_extradata(void *logctx, AVCodecParameters *par, AVIOContext *pb, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0 and f...
static AVPacket * pkt
Public dictionary API.
enum AVCodecID id
Definition dts2pts.c:612
const char * key
int ret
Definition ffplay.c:391
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:580
FLV common header.
@ PacketTypeMultitrack
Definition flv.h:132
@ PacketTypeModEx
Definition flv.h:133
@ PacketTypeMetadata
Definition flv.h:130
@ PacketTypeCodedFrames
Definition flv.h:127
FlvTagType
Definition flv.h:65
@ FLV_TAG_TYPE_AUDIO
Definition flv.h:66
@ FLV_TAG_TYPE_META
Definition flv.h:68
@ FLV_TAG_TYPE_VIDEO
Definition flv.h:67
@ FLV_STEREO
Definition flv.h:81
@ FLV_CODECID_SCREEN2
Definition flv.h:116
@ FLV_CODECID_MPEG4
Definition flv.h:119
@ FLV_CODECID_VP6A
Definition flv.h:115
@ FLV_CODECID_X_HEVC
Definition flv.h:122
@ FLV_CODECID_SCREEN
Definition flv.h:113
@ FLV_CODECID_REALH263
Definition flv.h:118
@ FLV_CODECID_H263
Definition flv.h:112
@ FLV_CODECID_VP6
Definition flv.h:114
@ FLV_CODECID_H264
Definition flv.h:117
@ FLV_STREAM_TYPE_AUDIO
Definition flv.h:73
@ FLV_STREAM_TYPE_DATA
Definition flv.h:75
@ FLV_STREAM_TYPE_SUBTITLE
Definition flv.h:74
@ FLV_STREAM_TYPE_NB
Definition flv.h:76
@ FLV_STREAM_TYPE_VIDEO
Definition flv.h:72
#define FLV_VIDEO_FRAMETYPE_MASK
Definition flv.h:51
@ FLV_HEADER_FLAG_HASVIDEO
Definition flv.h:61
@ FLV_HEADER_FLAG_HASAUDIO
Definition flv.h:62
#define FLV_AUDIO_SAMPLERATE_OFFSET
Definition flv.h:33
#define KEYFRAMES_TIMESTAMP_TAG
Definition flv.h:56
AMFDataType
Definition flv.h:167
@ AMF_DATA_TYPE_OBJECT_END
Definition flv.h:176
@ AMF_DATA_TYPE_OBJECT
Definition flv.h:171
@ AMF_DATA_TYPE_BOOL
Definition flv.h:169
@ AMF_DATA_TYPE_NUMBER
Definition flv.h:168
@ AMF_DATA_TYPE_MIXEDARRAY
Definition flv.h:175
@ AMF_DATA_TYPE_UNSUPPORTED
Definition flv.h:180
@ AMF_DATA_TYPE_NULL
Definition flv.h:172
@ AMF_DATA_TYPE_STRING
Definition flv.h:170
@ AMF_DATA_TYPE_UNDEFINED
Definition flv.h:173
@ AMF_DATA_TYPE_ARRAY
Definition flv.h:177
@ AMF_DATA_TYPE_DATE
Definition flv.h:178
#define FLV_AUDIO_SAMPLESIZE_MASK
Definition flv.h:46
#define KEYFRAMES_TAG
Definition flv.h:55
#define FLV_AUDIO_CODECID_MASK
Definition flv.h:48
#define KEYFRAMES_BYTEOFFSET_TAG
Definition flv.h:57
#define AMF_END_OF_OBJECT
Definition flv.h:53
@ AudioChannelOrderNative
Definition flv.h:149
@ AudioChannelOrderCustom
Definition flv.h:150
@ FLV_CODECID_NELLYMOSER_16KHZ_MONO
Definition flv.h:101
@ FLV_CODECID_PCM
Definition flv.h:97
@ FLV_CODECID_EX_HEADER
Definition flv.h:106
@ FLV_CODECID_AAC
Definition flv.h:107
@ FLV_CODECID_MP3
Definition flv.h:99
@ FLV_CODECID_PCM_LE
Definition flv.h:100
@ FLV_CODECID_NELLYMOSER
Definition flv.h:103
@ FLV_CODECID_PCM_MULAW
Definition flv.h:105
@ FLV_CODECID_PCM_ALAW
Definition flv.h:104
@ FLV_CODECID_SPEEX
Definition flv.h:108
@ FLV_CODECID_ADPCM
Definition flv.h:98
@ FLV_CODECID_NELLYMOSER_8KHZ_MONO
Definition flv.h:102
#define FLV_AUDIO_CODECID_OFFSET
Definition flv.h:34
@ MultitrackTypeOneTrack
Definition flv.h:154
@ MultitrackTypeManyTracksManyCodecs
Definition flv.h:156
#define FLV_AUDIO_SAMPLERATE_MASK
Definition flv.h:47
@ FLV_FRAME_DISP_INTER
disposable inter frame (H.263 only)
Definition flv.h:162
@ FLV_FRAME_KEY
key frame (for AVC, a seekable frame)
Definition flv.h:160
@ FLV_FRAME_VIDEO_INFO_CMD
video info/command frame
Definition flv.h:164
#define FLV_VIDEO_CODECID_MASK
Definition flv.h:50
#define FLV_AUDIO_CHANNEL_MASK
Definition flv.h:45
@ PacketModExTypeTimestampOffsetNano
Definition flv.h:144
@ AudioPacketTypeMultichannelConfig
Definition flv.h:139
@ AudioPacketTypeMultitrack
Definition flv.h:140
static const int32_t max_pos[4]
Size of the MP-MLQ fixed excitation codebooks.
Definition g723_1dec.c:97
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
@ AV_CODEC_ID_ADPCM_SWF
Definition codec_id.h:387
@ AV_CODEC_ID_FLV1
Definition codec_id.h:71
@ AV_CODEC_ID_VP6F
Definition codec_id.h:142
@ AV_CODEC_ID_EAC3
Definition codec_id.h:499
@ AV_CODEC_ID_PCM_U8
Definition codec_id.h:338
@ AV_CODEC_ID_PCM_S16LE
Definition codec_id.h:333
@ AV_CODEC_ID_TEXT
raw UTF-8 text
Definition codec_id.h:574
@ AV_CODEC_ID_H264
Definition codec_id.h:77
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_PCM_S16BE
Definition codec_id.h:334
@ AV_CODEC_ID_VVC
Definition codec_id.h:247
@ AV_CODEC_ID_AV1
Definition codec_id.h:275
@ AV_CODEC_ID_FLASHSV2
Definition codec_id.h:181
@ AV_CODEC_ID_PCM_ALAW
Definition codec_id.h:340
@ AV_CODEC_ID_VP6A
Definition codec_id.h:156
@ AV_CODEC_ID_HEVC
Definition codec_id.h:223
@ AV_CODEC_ID_AAC
Definition codec_id.h:461
@ AV_CODEC_ID_NELLYMOSER
Definition codec_id.h:492
@ AV_CODEC_ID_FLAC
Definition codec_id.h:471
@ AV_CODEC_ID_H263
Definition codec_id.h:54
@ AV_CODEC_ID_AC3
Definition codec_id.h:462
@ AV_CODEC_ID_MPEG4
Definition codec_id.h:62
@ AV_CODEC_ID_SPEEX
Definition codec_id.h:494
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition codec_id.h:460
@ AV_CODEC_ID_VP9
Definition codec_id.h:217
@ AV_CODEC_ID_FLASHSV
Definition codec_id.h:136
@ AV_CODEC_ID_OPUS
Definition codec_id.h:519
@ AV_CODEC_ID_PCM_MULAW
Definition codec_id.h:339
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
@ AVDISCARD_ALL
discard all
Definition defs.h:248
@ AVDISCARD_NONKEY
discard all frames except keyframes
Definition defs.h:247
@ AVDISCARD_BIDIR
discard all bidirectional frames
Definition defs.h:245
AVPacketSideData * av_packet_side_data_add(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, void *data, size_t size, int flags)
Wrap existing data as packet side data.
Definition packet.c:614
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition packet.h:219
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
Definition packet.h:56
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition packet.h:232
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:435
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition packet.h:657
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as a packet side data.
Definition packet.c:197
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
Definition seek.c:122
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
@ AV_CHAN_UNUSED
Channel is empty can be safely skipped.
@ AV_CHAN_LOW_FREQUENCY_2
@ AV_CHAN_UNKNOWN
Channel contains data, but its position is unknown.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition dict.c:61
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition dict.c:87
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition error.h:64
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition error.h:52
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition log.h:236
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:247
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
Definition rational.c:110
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition mem.c:318
AVMediaType
Definition avutil.h:198
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AVMEDIA_TYPE_SUBTITLE
Definition avutil.h:203
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition avutil.h:202
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition avstring.c:85
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
#define AV_TIME_BASE
Internal time base represented as integer.
Definition avutil.h:253
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
Definition intfloat.h:60
#define AV_RB32(p)
#define AV_RB24(x)
enum MPFType type
Definition jpegmpfenc.c:55
unsigned offset
Definition libaomenc.c:763
static const int factor[16]
Definition vf_pp7.c:98
static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
Definition flvdec.c:861
static void add_keyframes_index(AVFormatContext *s)
Definition flvdec.c:169
static int flv_read_header(AVFormatContext *s)
Definition flvdec.c:918
static int flv_parse_video_color_info(AVFormatContext *s, AVStream *st, int64_t next_pos)
Definition flvdec.c:1210
static AVStream * create_stream(AVFormatContext *s, int codec_type, int track_idx)
Definition flvdec.c:200
static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition flvdec.c:1380
static const AVClass flv_kux_class
Definition flvdec.c:1985
#define RESYNC_BUFFER_SIZE
Definition flvdec.c:46
static int flv_update_video_color_info(AVFormatContext *s, AVStream *st)
Definition flvdec.c:1247
static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth)
Definition flvdec.c:619
FLVMetaColorInfoFlag
Definition flvdec.c:72
@ FLV_COLOR_INFO_FLAG_NONE
Definition flvdec.c:73
@ FLV_COLOR_INFO_FLAG_GOT
Definition flvdec.c:74
@ FLV_COLOR_INFO_FLAG_PARSING
Definition flvdec.c:75
static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
Definition flvdec.c:972
#define MAX_DEPTH
arbitrary limit to prevent unbounded recursion
Definition flvdec.c:48
static int kux_probe(const AVProbeData *p)
Definition flvdec.c:155
#define TYPE_UNKNOWN
Definition flvdec.c:859
static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize)
Definition flvdec.c:504
#define TYPE_ONCAPTIONINFO
Definition flvdec.c:858
#define VALIDATE_INDEX_TS_THRESH
Definition flvdec.c:44
static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t max_pos)
Definition flvdec.c:524
#define TYPE_ONTEXTDATA
Definition flvdec.c:856
#define TYPE_ONCAPTION
Definition flvdec.c:857
static int flv_data_packet(AVFormatContext *s, AVPacket *pkt, int64_t dts, int64_t next)
Definition flvdec.c:1099
static int resync(AVFormatContext *s)
Definition flvdec.c:1168
static int flv_probe(const AVProbeData *p)
Definition flvdec.c:145
static int probe(const AVProbeData *p, int live)
Definition flvdec.c:126
static int flv_set_audio_codec(AVFormatContext *s, AVStream *astream, AVCodecParameters *apar, int flv_codecid)
Definition flvdec.c:306
static int live_flv_probe(const AVProbeData *p)
Definition flvdec.c:150
static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid)
Definition flvdec.c:395
#define OFFSET(x)
Definition flvdec.c:1976
static int flv_same_audio_codec(AVCodecParameters *apar, int flags, uint32_t codec_fourcc)
Definition flvdec.c:234
static void clear_index_entries(AVFormatContext *s, int64_t pos)
Definition flvdec.c:1033
static int flv_queue_extradata(FLVContext *flv, AVIOContext *pb, int stream, int size, int multitrack)
Definition flvdec.c:984
static int flv_read_close(AVFormatContext *s)
Definition flvdec.c:957
static int amf_skip_tag(AVIOContext *pb, AMFDataType type, int depth)
Definition flvdec.c:1048
static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, uint32_t flv_codecid, int read)
Definition flvdec.c:428
static int flv_parse_mod_ex_data(AVFormatContext *s, int *pkt_type, int *size, int64_t *dts)
Definition flvdec.c:1324
static int flv_read_seek(AVFormatContext *s, int stream_index, int64_t ts, int flags)
Definition flvdec.c:1968
int ff_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
Set a dictionary value to an ISO-8601 compliant timestamp string.
Definition utils.c:626
static av_always_inline FFStream * ffstream(AVStream *st)
Definition internal.h:390
int ff_alloc_extradata(AVCodecParameters *par, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0.
Definition utils.c:237
static av_always_inline FFFormatContext * ffformatcontext(AVFormatContext *s)
Definition internal.h:135
Macro definitions for various function/variable attributes.
#define av_fallthrough
Definition attributes.h:67
#define av_unused
Definition attributes.h:164
#define av_uninit(x)
Definition attributes.h:187
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition libcdio.c:151
version
Definition libkvazaar.c:313
static const uint16_t mask[17]
Definition lzw.c:38
#define FFMIN(a, b)
Definition macros.h:49
#define MKBETAG(a, b, c, d)
Definition macros.h:56
AVContentLightMetadata * av_content_light_metadata_alloc(size_t *size)
Allocate an AVContentLightMetadata structure and set its fields to default values.
AVMasteringDisplayMetadata * av_mastering_display_metadata_alloc_size(size_t *size)
Allocate an AVMasteringDisplayMetadata structure and set its fields to default values.
Memory handling functions.
#define av_malloc(s)
Definition ops_static.c:52
AVOptions.
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition pixfmt.h:647
@ AVCOL_PRI_RESERVED
Definition pixfmt.h:651
@ AVCOL_PRI_RESERVED0
Definition pixfmt.h:648
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition pixfmt.h:677
@ AVCOL_TRC_RESERVED
Definition pixfmt.h:681
@ AVCOL_TRC_RESERVED0
Definition pixfmt.h:678
AVColorSpace
YUV colorspace type.
Definition pixfmt.h:711
@ AVCOL_SPC_RESERVED
reserved for future use by ITU-T and ISO/IEC just like 15-255 are
Definition pixfmt.h:715
enum AVMediaType codec_type
Definition rtp.c:37
unsigned int pos
Definition spdifenc.c:431
enum AVChannel id
union AVChannelLayout::@162063043056170047076125117143030261346263330336 u
Details about which channels are present in this layout.
int nb_channels
Number of channels in this layout.
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
Describe the class of an AVClass context structure.
Definition log.h:76
This struct describes the properties of an encoded stream.
Definition codec_par.h:49
enum AVColorSpace color_space
Definition codec_par.h:192
int extradata_size
Size of the extradata content in bytes.
Definition codec_par.h:75
int height
The height of the video frame in pixels.
Definition codec_par.h:150
int nb_coded_side_data
Amount of entries in coded_side_data.
Definition codec_par.h:88
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition codec_par.h:113
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition codec_par.h:207
int width
The width of the video frame in pixels.
Definition codec_par.h:143
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition codec_par.h:99
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition codec_par.h:61
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition codec_par.h:71
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
enum AVColorPrimaries color_primaries
Definition codec_par.h:190
int sample_rate
The number of audio samples per second.
Definition codec_par.h:213
enum AVColorTransferCharacteristic color_trc
Definition codec_par.h:191
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
Definition codec_par.h:83
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
char * value
Definition dict.h:92
Format I/O context.
Definition avformat.h:1401
Bytestream IO Context.
Definition avio.h:160
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition avio.h:261
int eof_reached
true if was unable to read due to error or eof
Definition avio.h:238
int64_t pos
Definition avformat.h:623
Mastering display metadata capable of representing the color volume of the display used to master the...
AVOption.
Definition opt.h:428
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition packet.h:431
This structure stores compressed data.
Definition packet.h:587
This structure contains the data a format has to probe a file.
Definition avformat.h:473
Rational number (pair of numerator and denominator).
Definition rational.h:58
Stream structure.
Definition avformat.h:768
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:791
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition avformat.h:839
int id
Format-specific stream ID.
Definition avformat.h:780
int index
stream index in AVFormatContext
Definition avformat.h:774
AVRational avg_frame_rate
Average framerate.
Definition avformat.h:857
int nb_index_entries
Definition internal.h:198
int need_context_update
Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
Definition internal.h:185
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition internal.h:196
enum AVStreamParseType need_parsing
Definition internal.h:346
uint8_t resync_buffer[2 *RESYNC_BUFFER_SIZE]
Definition flvdec.c:96
FLVMetaVideoColor meta_color_info
Definition flvdec.c:112
int wrong_dts
wrong dts due to negative cts
Definition flvdec.c:83
int new_extradata_size[FLV_STREAM_TYPE_NB]
Definition flvdec.c:85
uint8_t ** mt_extradata
Definition flvdec.c:115
int trust_datasize
trust data size of FLVTag
Definition flvdec.c:81
int broken_sizes
Definition flvdec.c:98
int64_t sum_flv_tag_size
Definition flvdec.c:99
int last_keyframe_stream_index
Definition flvdec.c:101
int * mt_extradata_sz
Definition flvdec.c:116
uint8_t * new_extradata[FLV_STREAM_TYPE_NB]
Definition flvdec.c:84
AVRational framerate
Definition flvdec.c:107
int searched_for_end
Definition flvdec.c:94
int keyframe_count
Definition flvdec.c:102
enum FLVMetaColorInfoFlag meta_color_info_flag
Definition flvdec.c:113
int64_t * keyframe_filepositions
Definition flvdec.c:106
int64_t pos
Definition flvdec.c:90
int64_t last_ts
Definition flvdec.c:108
int validate_next
Definition flvdec.c:92
int validate_count
Definition flvdec.c:93
int dump_full_metadata
Dump full metadata of the onMetadata.
Definition flvdec.c:82
int last_channels
Definition flvdec.c:87
int trust_metadata
configure streams according onMetaData
Definition flvdec.c:80
int64_t * keyframe_times
Definition flvdec.c:105
int64_t time_pos
Definition flvdec.c:110
int64_t time_offset
Definition flvdec.c:109
int64_t video_bit_rate
Definition flvdec.c:103
int64_t audio_bit_rate
Definition flvdec.c:104
int64_t dts
Definition flvdec.c:89
int mt_extradata_cnt
Definition flvdec.c:117
int last_sample_rate
Definition flvdec.c:86
struct FLVContext::@173004043364206277106171202240343110252007345313 validate_index[2]
float white_y
Definition flvdec.c:58
float min_luminance
Definition flvdec.c:60
float white_x
Definition flvdec.c:57
float max_luminance
Definition flvdec.c:59
FLVMasteringMeta mastering_meta
Definition flvdec.c:69
uint16_t max_cll
Definition flvdec.c:67
enum AVColorPrimaries primaries
Definition flvdec.c:66
enum AVColorSpace matrix_coefficients
Definition flvdec.c:64
enum AVColorTransferCharacteristic trc
Definition flvdec.c:65
uint16_t max_fall
Definition flvdec.c:68
int16_t timezone
Definition flvdec.c:123
double milliseconds
Definition flvdec.c:122
#define av_free(p)
#define av_mallocz(s)
#define avpriv_request_sample(...)
#define av_freep(p)
#define av_log(a,...)
static uint8_t tmp[40]
Definition aes_ctr.c:52
static int array[MAX_W *MAX_W]
static char buffer[20]
Definition seek.c:33
static int64_t pts
int size
enum AVCodecID codec_id