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 num_val >= 0 && num_val < INT64_MAX / AV_TIME_BASE)
724 s->duration = num_val * AV_TIME_BASE;
725 else if (!strcmp(key, "videodatarate") &&
726 0 <= num_val && num_val < INT_MAX / 1024.0)
727 flv->video_bit_rate = num_val * 1024.0;
728 else if (!strcmp(key, "audiodatarate") &&
729 0 <= num_val && num_val < INT_MAX / 1024.0)
730 flv->audio_bit_rate = num_val * 1024.0;
731 else if (!strcmp(key, "framerate")) {
732 flv->framerate = av_d2q(num_val, 1000);
733 if (vstream)
734 vstream->avg_frame_rate = flv->framerate;
735 } else if (flv->trust_metadata) {
736 if (!strcmp(key, "videocodecid") && vpar) {
737 int ret = flv_set_video_codec(s, vstream, num_val, 0);
738 if (ret < 0)
739 return ret;
740 } else if (!strcmp(key, "audiocodecid") && apar) {
741 int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET;
742 int ret = flv_set_audio_codec(s, astream, apar, id);
743 if (ret < 0)
744 return ret;
745 } else if (!strcmp(key, "audiosamplerate") && apar) {
746 apar->sample_rate = num_val;
747 } else if (!strcmp(key, "audiosamplesize") && apar) {
748 apar->bits_per_coded_sample = num_val;
749 } else if (!strcmp(key, "stereo") && apar) {
750 av_channel_layout_default(&apar->ch_layout, num_val + 1);
751 } else if (!strcmp(key, "width") && vpar) {
752 vpar->width = num_val;
753 } else if (!strcmp(key, "height") && vpar) {
754 vpar->height = num_val;
755 } else if (!strcmp(key, "datastream")) {
757 if (!st)
758 return AVERROR(ENOMEM);
760 }
761 }
762 }
763 if (amf_type == AMF_DATA_TYPE_STRING) {
764 if (!strcmp(key, "encoder")) {
765 int version = -1;
766 if (1 == sscanf(str_val, "Open Broadcaster Software v0.%d", &version)) {
767 if (version > 0 && version <= 655)
768 flv->broken_sizes = 1;
769 }
770 } else if (!strcmp(key, "metadatacreator")) {
771 if ( !strcmp (str_val, "MEGA")
772 || !strncmp(str_val, "FlixEngine", 10))
773 flv->broken_sizes = 1;
774 }
775 }
776 }
777
779 FLVMetaVideoColor *meta_video_color = &flv->meta_color_info;
780 if (!strcmp(key, "colorPrimaries")) {
781 meta_video_color->primaries = num_val;
782 } else if (!strcmp(key, "transferCharacteristics")) {
783 meta_video_color->trc = num_val;
784 } else if (!strcmp(key, "matrixCoefficients")) {
785 meta_video_color->matrix_coefficients = num_val;
786 } else if (!strcmp(key, "maxFall")) {
787 meta_video_color->max_fall = num_val;
788 } else if (!strcmp(key, "maxCLL")) {
789 meta_video_color->max_cll = num_val;
790 } else if (!strcmp(key, "redX")) {
791 meta_video_color->mastering_meta.r_x = num_val;
792 } else if (!strcmp(key, "redY")) {
793 meta_video_color->mastering_meta.r_y = num_val;
794 } else if (!strcmp(key, "greenX")) {
795 meta_video_color->mastering_meta.g_x = num_val;
796 } else if (!strcmp(key, "greenY")) {
797 meta_video_color->mastering_meta.g_y = num_val;
798 } else if (!strcmp(key, "blueX")) {
799 meta_video_color->mastering_meta.b_x = num_val;
800 } else if (!strcmp(key, "blueY")) {
801 meta_video_color->mastering_meta.b_y = num_val;
802 } else if (!strcmp(key, "whitePointX")) {
803 meta_video_color->mastering_meta.white_x = num_val;
804 } else if (!strcmp(key, "whitePointY")) {
805 meta_video_color->mastering_meta.white_y = num_val;
806 } else if (!strcmp(key, "maxLuminance")) {
807 meta_video_color->mastering_meta.max_luminance = num_val;
808 } else if (!strcmp(key, "minLuminance")) {
809 meta_video_color->mastering_meta.min_luminance = num_val;
810 }
811 }
812
813 if (amf_type == AMF_DATA_TYPE_OBJECT && s->nb_streams == 1 &&
814 ((!apar && !strcmp(key, "audiocodecid")) ||
815 (!vpar && !strcmp(key, "videocodecid"))))
816 s->ctx_flags &= ~AVFMTCTX_NOHEADER; //If there is either audio/video missing, codecid will be an empty object
817
818 if ((!strcmp(key, "duration") ||
819 !strcmp(key, "filesize") ||
820 !strcmp(key, "width") ||
821 !strcmp(key, "height") ||
822 !strcmp(key, "videodatarate") ||
823 !strcmp(key, "framerate") ||
824 !strcmp(key, "videocodecid") ||
825 !strcmp(key, "audiodatarate") ||
826 !strcmp(key, "audiosamplerate") ||
827 !strcmp(key, "audiosamplesize") ||
828 !strcmp(key, "stereo") ||
829 !strcmp(key, "audiocodecid") ||
830 !strcmp(key, "datastream")) && !flv->dump_full_metadata)
831 return 0;
832
833 s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
834 if (amf_type == AMF_DATA_TYPE_BOOL) {
835 av_strlcpy(str_val, num_val > 0 ? "true" : "false",
836 sizeof(str_val));
837 av_dict_set(&s->metadata, key, str_val, 0);
838 } else if (amf_type == AMF_DATA_TYPE_NUMBER) {
839 snprintf(str_val, sizeof(str_val), "%.f", num_val);
840 av_dict_set(&s->metadata, key, str_val, 0);
841 } else if (amf_type == AMF_DATA_TYPE_STRING) {
842 av_dict_set(&s->metadata, key, str_val, 0);
843 } else if ( amf_type == AMF_DATA_TYPE_DATE
844 && isfinite(date.milliseconds)
845 && date.milliseconds > INT64_MIN/1000
846 && date.milliseconds < INT64_MAX/1000
847 ) {
848 // timezone is ignored, since there is no easy way to offset the UTC
849 // timestamp into the specified timezone
850 ff_dict_set_timestamp(&s->metadata, key, 1000 * (int64_t)date.milliseconds);
851 }
852 }
853
854 return 0;
855}
856
857#define TYPE_ONTEXTDATA 1
858#define TYPE_ONCAPTION 2
859#define TYPE_ONCAPTIONINFO 3
860#define TYPE_UNKNOWN 9
861
863{
864 FLVContext *flv = s->priv_data;
866 AVStream *stream, *astream, *vstream;
867 av_unused AVStream *dstream;
868 AVIOContext *ioc;
869 int i;
870 char buffer[32];
871
872 astream = NULL;
873 vstream = NULL;
874 dstream = NULL;
875 ioc = s->pb;
876
877 // first object needs to be "onMetaData" string
878 type = avio_r8(ioc);
879 if (type != AMF_DATA_TYPE_STRING ||
880 amf_get_string(ioc, buffer, sizeof(buffer)) < 0)
881 return TYPE_UNKNOWN;
882
883 if (!strcmp(buffer, "onTextData"))
884 return TYPE_ONTEXTDATA;
885
886 if (!strcmp(buffer, "onCaption"))
887 return TYPE_ONCAPTION;
888
889 if (!strcmp(buffer, "onCaptionInfo"))
890 return TYPE_ONCAPTIONINFO;
891
892 if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint") && strcmp(buffer, "|RtmpSampleAccess")) {
893 av_log(s, AV_LOG_DEBUG, "Unknown type %s\n", buffer);
894 return TYPE_UNKNOWN;
895 }
896
897 // find the streams now so that amf_parse_object doesn't need to do
898 // the lookup every time it is called.
899 for (i = 0; i < s->nb_streams; i++) {
900 stream = s->streams[i];
901 if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
902 vstream = stream;
904 } else if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
905 astream = stream;
906 if (flv->last_keyframe_stream_index == -1)
908 } else if (stream->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
909 dstream = stream;
910 }
911
912 // parse the second object (we want a mixed array)
913 if (amf_parse_object(s, astream, vstream, buffer, next_pos, 0) < 0)
914 return -1;
915
916 return 0;
917}
918
920{
921 FFFormatContext *const si = ffformatcontext(s);
922 int flags;
923 FLVContext *flv = s->priv_data;
924 int offset;
925 int pre_tag_size = 0;
926
927 /* Actual FLV data at 0xe40000 in KUX file */
928 if(!strcmp(s->iformat->name, "kux"))
929 avio_skip(s->pb, 0xe40000);
930
931 avio_skip(s->pb, 4);
932 flags = avio_r8(s->pb);
933
935
936 s->ctx_flags |= AVFMTCTX_NOHEADER;
937
938 offset = avio_rb32(s->pb);
939 avio_seek(s->pb, offset, SEEK_SET);
940
941 /* Annex E. The FLV File Format
942 * E.3 TheFLVFileBody
943 * Field Type Comment
944 * PreviousTagSize0 UI32 Always 0
945 * */
946 pre_tag_size = avio_rb32(s->pb);
947 if (pre_tag_size) {
948 av_log(s, AV_LOG_WARNING, "Read FLV header error, input file is not a standard flv format, first PreviousTagSize0 always is 0\n");
949 }
950
951 s->start_time = 0;
952 flv->sum_flv_tag_size = 0;
954
955 return 0;
956}
957
959{
960 int i;
961 FLVContext *flv = s->priv_data;
962 for (i = 0; i < FLV_STREAM_TYPE_NB; i++)
963 av_freep(&flv->new_extradata[i]);
964 for (i = 0; i < flv->mt_extradata_cnt; i++)
965 av_freep(&flv->mt_extradata[i]);
966 av_freep(&flv->mt_extradata);
970 return 0;
971}
972
974{
975 int ret;
976 if (!size)
977 return 0;
978
979 if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0)
980 return ret;
982 return 0;
983}
984
985static int flv_queue_extradata(FLVContext *flv, AVIOContext *pb, int stream,
986 int size, int multitrack)
987{
988 if (!size)
989 return 0;
990
991 if (!multitrack) {
992 av_free(flv->new_extradata[stream]);
993 flv->new_extradata[stream] = av_mallocz(size +
995 if (!flv->new_extradata[stream])
996 return AVERROR(ENOMEM);
997 flv->new_extradata_size[stream] = size;
998 avio_read(pb, flv->new_extradata[stream], size);
999 } else {
1000 int new_count = stream + 1;
1001
1002 if (flv->mt_extradata_cnt < new_count) {
1003 void *tmp = av_realloc_array(flv->mt_extradata, new_count,
1004 sizeof(*flv->mt_extradata));
1005 if (!tmp)
1006 return AVERROR(ENOMEM);
1007 flv->mt_extradata = tmp;
1008
1009 tmp = av_realloc_array(flv->mt_extradata_sz, new_count,
1010 sizeof(*flv->mt_extradata_sz));
1011 if (!tmp)
1012 return AVERROR(ENOMEM);
1013 flv->mt_extradata_sz = tmp;
1014
1015 // Set newly allocated pointers/sizes to 0
1016 for (int i = flv->mt_extradata_cnt; i < new_count; i++) {
1017 flv->mt_extradata[i] = NULL;
1018 flv->mt_extradata_sz[i] = 0;
1019 }
1020 flv->mt_extradata_cnt = new_count;
1021 }
1022
1023 av_free(flv->mt_extradata[stream]);
1025 if (!flv->mt_extradata[stream])
1026 return AVERROR(ENOMEM);
1027 flv->mt_extradata_sz[stream] = size;
1028 avio_read(pb, flv->mt_extradata[stream], size);
1029 }
1030
1031 return 0;
1032}
1033
1035{
1037 "Found invalid index entries, clearing the index.\n");
1038 for (unsigned i = 0; i < s->nb_streams; i++) {
1039 FFStream *const sti = ffstream(s->streams[i]);
1040 int out = 0;
1041 /* Remove all index entries that point to >= pos */
1042 for (int j = 0; j < sti->nb_index_entries; j++)
1043 if (sti->index_entries[j].pos < pos)
1044 sti->index_entries[out++] = sti->index_entries[j];
1045 sti->nb_index_entries = out;
1046 }
1047}
1048
1049static int amf_skip_tag(AVIOContext *pb, AMFDataType type, int depth)
1050{
1051 int nb = -1, ret, parse_name = 1;
1052
1053 if (depth > MAX_DEPTH)
1054 return AVERROR_PATCHWELCOME;
1055
1056 if (avio_feof(pb))
1057 return AVERROR_EOF;
1058
1059 switch (type) {
1061 avio_skip(pb, 8);
1062 break;
1063 case AMF_DATA_TYPE_BOOL:
1064 avio_skip(pb, 1);
1065 break;
1067 avio_skip(pb, avio_rb16(pb));
1068 break;
1070 parse_name = 0;
1073 nb = avio_rb32(pb);
1074 if (nb < 0)
1075 return AVERROR_INVALIDDATA;
1078 while(!pb->eof_reached && (nb-- > 0 || type != AMF_DATA_TYPE_ARRAY)) {
1079 if (parse_name) {
1080 int size = avio_rb16(pb);
1081 if (!size) {
1082 avio_skip(pb, 1);
1083 break;
1084 }
1085 avio_skip(pb, size);
1086 }
1087 if ((ret = amf_skip_tag(pb, avio_r8(pb), depth + 1)) < 0)
1088 return ret;
1089 }
1090 break;
1091 case AMF_DATA_TYPE_NULL:
1093 break;
1094 default:
1095 return AVERROR_INVALIDDATA;
1096 }
1097 return 0;
1098}
1099
1101 int64_t dts, int64_t next)
1102{
1103 AVIOContext *pb = s->pb;
1104 AVStream *st = NULL;
1105 char buf[20];
1107 int i, length = -1;
1108 int array = 0;
1109
1110 switch (avio_r8(pb)) {
1112 array = 1;
1115 avio_seek(pb, 4, SEEK_CUR);
1118 break;
1119 default:
1120 goto skip;
1121 }
1122
1123 while (array || (ret = amf_get_string(pb, buf, sizeof(buf))) > 0) {
1124 AMFDataType type = avio_r8(pb);
1125 if (type == AMF_DATA_TYPE_STRING && (array || !strcmp(buf, "text"))) {
1126 length = avio_rb16(pb);
1127 ret = av_get_packet(pb, pkt, length);
1128 if (ret < 0)
1129 goto skip;
1130 else
1131 break;
1132 } else {
1133 if ((ret = amf_skip_tag(pb, type, 0)) < 0)
1134 goto skip;
1135 }
1136 }
1137
1138 if (length < 0) {
1140 goto skip;
1141 }
1142
1143 for (i = 0; i < s->nb_streams; i++) {
1144 st = s->streams[i];
1146 break;
1147 }
1148
1149 if (i == s->nb_streams) {
1151 if (!st)
1152 return AVERROR(ENOMEM);
1154 }
1155
1156 pkt->dts = dts;
1157 pkt->pts = dts;
1158 pkt->size = ret;
1159
1160 pkt->stream_index = st->index;
1161 pkt->flags |= AV_PKT_FLAG_KEY;
1162
1163skip:
1164 avio_seek(s->pb, next + 4, SEEK_SET);
1165
1166 return ret;
1167}
1168
1170{
1171 FLVContext *flv = s->priv_data;
1172 int64_t i;
1173 int64_t pos = avio_tell(s->pb);
1174
1175 for (i=0; !avio_feof(s->pb); i++) {
1176 int j = i & (RESYNC_BUFFER_SIZE-1);
1177 int j1 = j + RESYNC_BUFFER_SIZE;
1178 flv->resync_buffer[j ] =
1179 flv->resync_buffer[j1] = avio_r8(s->pb);
1180
1181 if (i >= 8 && pos) {
1182 uint8_t *d = flv->resync_buffer + j1 - 8;
1183 if (d[0] == 'F' &&
1184 d[1] == 'L' &&
1185 d[2] == 'V' &&
1186 d[3] < 5 && d[5] == 0) {
1187 av_log(s, AV_LOG_WARNING, "Concatenated FLV detected, might fail to demux, decode and seek %"PRId64"\n", flv->last_ts);
1188 flv->time_offset = flv->last_ts + 1;
1189 flv->time_pos = avio_tell(s->pb);
1190 }
1191 }
1192
1193 if (i > 22) {
1194 unsigned lsize2 = AV_RB32(flv->resync_buffer + j1 - 4);
1195 if (lsize2 >= 11 && lsize2 + 8LL < FFMIN(i, RESYNC_BUFFER_SIZE)) {
1196 unsigned size2 = AV_RB24(flv->resync_buffer + j1 - lsize2 + 1 - 4);
1197 unsigned lsize1 = AV_RB32(flv->resync_buffer + j1 - lsize2 - 8);
1198 if (lsize1 >= 11 && lsize1 + 8LL + lsize2 < FFMIN(i, RESYNC_BUFFER_SIZE)) {
1199 unsigned size1 = AV_RB24(flv->resync_buffer + j1 - lsize1 + 1 - lsize2 - 8);
1200 if (size1 == lsize1 - 11 && size2 == lsize2 - 11) {
1201 avio_seek(s->pb, pos + i - lsize1 - lsize2 - 8, SEEK_SET);
1202 return 1;
1203 }
1204 }
1205 }
1206 }
1207 }
1208 return AVERROR_EOF;
1209}
1210
1212{
1213 int ret;
1214 FLVContext *flv = s->priv_data;
1216 AVIOContext *ioc;
1217 char buffer[32];
1218 ioc = s->pb;
1219
1220 // first object needs to be "colorInfo" string
1221 type = avio_r8(ioc);
1222 if (type != AMF_DATA_TYPE_STRING) {
1223 av_log(s, AV_LOG_WARNING, "Ignore invalid colorInfo\n");
1224 return 0;
1225 }
1226
1227 ret = amf_get_string(ioc, buffer, sizeof(buffer));
1228 if (ret < 0)
1229 return ret;
1230
1231 if (strcmp(buffer, "colorInfo") != 0) {
1232 av_log(s, AV_LOG_WARNING, "Ignore invalid colorInfo type %s\n", buffer);
1233 return 0;
1234 }
1235
1237 ret = amf_parse_object(s, NULL, NULL, buffer, next_pos, 0); // parse metadata
1238 if (ret < 0) {
1240 return ret;
1241 }
1242
1244
1245 return 0;
1246}
1247
1249{
1250 FLVContext *flv = s->priv_data;
1251 const FLVMetaVideoColor* meta_video_color = &flv->meta_color_info;
1252 const FLVMasteringMeta *mastering_meta = &meta_video_color->mastering_meta;
1253
1254 int has_mastering_primaries, has_mastering_luminance;
1255 // Mastering primaries are CIE 1931 coords, and must be > 0.
1256 has_mastering_primaries =
1257 mastering_meta->r_x > 0 && mastering_meta->r_y > 0 &&
1258 mastering_meta->g_x > 0 && mastering_meta->g_y > 0 &&
1259 mastering_meta->b_x > 0 && mastering_meta->b_y > 0 &&
1260 mastering_meta->white_x > 0 && mastering_meta->white_y > 0;
1261 has_mastering_luminance = mastering_meta->max_luminance > 0 && mastering_meta->min_luminance > 0;
1262
1263 if (meta_video_color->matrix_coefficients != AVCOL_SPC_RESERVED)
1264 st->codecpar->color_space = meta_video_color->matrix_coefficients;
1265 if (meta_video_color->primaries != AVCOL_PRI_RESERVED &&
1266 meta_video_color->primaries != AVCOL_PRI_RESERVED0)
1267 st->codecpar->color_primaries = meta_video_color->primaries;
1268 if (meta_video_color->trc != AVCOL_TRC_RESERVED &&
1269 meta_video_color->trc != AVCOL_TRC_RESERVED0)
1270 st->codecpar->color_trc = meta_video_color->trc;
1271
1272 if (meta_video_color->max_cll && meta_video_color->max_fall) {
1273 size_t size = 0;
1275 if (!metadata)
1276 return AVERROR(ENOMEM);
1280 return AVERROR(ENOMEM);
1281 }
1282 metadata->MaxCLL = meta_video_color->max_cll;
1283 metadata->MaxFALL = meta_video_color->max_fall;
1284 }
1285
1286 if (has_mastering_primaries || has_mastering_luminance) {
1287 size_t size = 0;
1289 AVPacketSideData *sd;
1290
1291 if (!metadata)
1292 return AVERROR(ENOMEM);
1293
1297 metadata, size, 0);
1298 if (!sd) {
1300 return AVERROR(ENOMEM);
1301 }
1302
1303 // hdrCll
1304 if (has_mastering_luminance) {
1305 metadata->max_luminance = av_d2q(mastering_meta->max_luminance, INT_MAX);
1306 metadata->min_luminance = av_d2q(mastering_meta->min_luminance, INT_MAX);
1307 metadata->has_luminance = 1;
1308 }
1309 // hdrMdcv
1310 if (has_mastering_primaries) {
1311 metadata->display_primaries[0][0] = av_d2q(mastering_meta->r_x, INT_MAX);
1312 metadata->display_primaries[0][1] = av_d2q(mastering_meta->r_y, INT_MAX);
1313 metadata->display_primaries[1][0] = av_d2q(mastering_meta->g_x, INT_MAX);
1314 metadata->display_primaries[1][1] = av_d2q(mastering_meta->g_y, INT_MAX);
1315 metadata->display_primaries[2][0] = av_d2q(mastering_meta->b_x, INT_MAX);
1316 metadata->display_primaries[2][1] = av_d2q(mastering_meta->b_y, INT_MAX);
1317 metadata->white_point[0] = av_d2q(mastering_meta->white_x, INT_MAX);
1318 metadata->white_point[1] = av_d2q(mastering_meta->white_y, INT_MAX);
1319 metadata->has_primaries = 1;
1320 }
1321 }
1322 return 0;
1323}
1324
1325static int flv_parse_mod_ex_data(AVFormatContext *s, int *pkt_type, int *size, int64_t *dts)
1326{
1327 int ex_type, ret;
1328 uint8_t *ex_data;
1329
1330 int ex_size = (uint8_t)avio_r8(s->pb) + 1;
1331 *size -= 1;
1332
1333 if (ex_size == 256) {
1334 ex_size = (uint16_t)avio_rb16(s->pb) + 1;
1335 *size -= 2;
1336 }
1337
1338 if (ex_size >= *size) {
1339 av_log(s, AV_LOG_WARNING, "ModEx size larger than remaining data!\n");
1340 return AVERROR(EINVAL);
1341 }
1342
1343 ex_data = av_malloc(ex_size);
1344 if (!ex_data)
1345 return AVERROR(ENOMEM);
1346
1347 ret = ffio_read_size(s->pb, ex_data, ex_size);
1348 if (ret < 0) {
1349 av_free(ex_data);
1350 return ret;
1351 }
1352 *size -= ex_size;
1353
1354 ex_type = (uint8_t)avio_r8(s->pb);
1355 *size -= 1;
1356
1357 *pkt_type = ex_type & 0x0f;
1358 ex_type &= 0xf0;
1359
1360 if (ex_type == PacketModExTypeTimestampOffsetNano) {
1361 uint32_t nano_offset;
1362
1363 if (ex_size != 3) {
1364 av_log(s, AV_LOG_WARNING, "Invalid ModEx size for Type TimestampOffsetNano!\n");
1365 nano_offset = 0;
1366 } else {
1367 nano_offset = (ex_data[0] << 16) | (ex_data[1] << 8) | ex_data[2];
1368 }
1369
1370 // this is not likely to ever add anything, but right now timestamps are with ms precision
1371 *dts += nano_offset / 1000000;
1372 } else {
1373 av_log(s, AV_LOG_INFO, "Unknown ModEx type: %d", ex_type);
1374 }
1375
1376 av_free(ex_data);
1377
1378 return 0;
1379}
1380
1382{
1383 FLVContext *flv = s->priv_data;
1384 int ret = AVERROR_BUG, i, size, flags;
1385 int res = 0;
1386 enum FlvTagType type;
1387 int stream_type = -1;
1388 int64_t next, pos, meta_pos;
1389 int64_t dts, pts = AV_NOPTS_VALUE;
1390 int av_uninit(channels);
1391 int av_uninit(sample_rate);
1392 AVStream *st = NULL;
1393 int last = -1;
1394 int orig_size;
1395 int enhanced_flv = 0;
1396 int multitrack = 0;
1397 int pkt_type = 0;
1398 uint8_t track_idx = 0;
1399 uint32_t codec_id = 0;
1400 int multitrack_type = MultitrackTypeOneTrack;
1401
1402retry:
1403 /* pkt size is repeated at end. skip it */
1404 pos = avio_tell(s->pb);
1405 type = (avio_r8(s->pb) & 0x1F);
1406 orig_size =
1407 size = avio_rb24(s->pb);
1408 flv->sum_flv_tag_size += size + 11LL;
1409 dts = avio_rb24(s->pb);
1410 dts |= (unsigned)avio_r8(s->pb) << 24;
1411 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));
1412 if (avio_feof(s->pb))
1413 return AVERROR_EOF;
1414 avio_skip(s->pb, 3); /* stream id, always 0 */
1415 flags = 0;
1416
1417 if (flv->validate_next < flv->validate_count) {
1418 int64_t validate_pos = flv->validate_index[flv->validate_next].pos;
1419 if (pos == validate_pos) {
1420 if (FFABS(dts - flv->validate_index[flv->validate_next].dts) <=
1422 flv->validate_next++;
1423 } else {
1424 clear_index_entries(s, validate_pos);
1425 flv->validate_count = 0;
1426 }
1427 } else if (pos > validate_pos) {
1428 clear_index_entries(s, validate_pos);
1429 flv->validate_count = 0;
1430 }
1431 }
1432
1433 if (size == 0) {
1434 ret = FFERROR_REDO;
1435 goto leave;
1436 }
1437
1438 next = size + avio_tell(s->pb);
1439
1440 if (type == FLV_TAG_TYPE_AUDIO) {
1441 stream_type = FLV_STREAM_TYPE_AUDIO;
1442 flags = avio_r8(s->pb);
1443 size--;
1444
1446 enhanced_flv = 1;
1447 pkt_type = flags & ~FLV_AUDIO_CODECID_MASK;
1448
1449 while (pkt_type == PacketTypeModEx) {
1450 ret = flv_parse_mod_ex_data(s, &pkt_type, &size, &dts);
1451 if (ret < 0)
1452 goto leave;
1453 }
1454
1455 if (pkt_type == AudioPacketTypeMultitrack) {
1456 uint8_t types = avio_r8(s->pb);
1457 multitrack_type = types & 0xF0;
1458 pkt_type = types & 0xF;
1459
1460 multitrack = 1;
1461 size--;
1462 }
1463
1464 codec_id = avio_rb32(s->pb);
1465 size -= 4;
1466
1467 if (multitrack) {
1468 track_idx = avio_r8(s->pb);
1469 size--;
1470 }
1471 }
1472 } else if (type == FLV_TAG_TYPE_VIDEO) {
1473 stream_type = FLV_STREAM_TYPE_VIDEO;
1474 flags = avio_r8(s->pb);
1476 /*
1477 * Reference Enhancing FLV 2023-03-v1.0.0-B.8
1478 * https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
1479 * */
1480 enhanced_flv = (flags >> 7) & 1;
1481 pkt_type = enhanced_flv ? codec_id : 0;
1482 size--;
1483
1484 while (pkt_type == PacketTypeModEx) {
1485 ret = flv_parse_mod_ex_data(s, &pkt_type, &size, &dts);
1486 if (ret < 0)
1487 goto leave;
1488 }
1489
1490 if (enhanced_flv && pkt_type != PacketTypeMetadata &&
1492 goto skip;
1493
1494 if (pkt_type == PacketTypeMultitrack) {
1495 uint8_t types = avio_r8(s->pb);
1496 multitrack_type = types & 0xF0;
1497 pkt_type = types & 0xF;
1498
1499 multitrack = 1;
1500 size--;
1501 }
1502
1503 if (enhanced_flv) {
1504 codec_id = avio_rb32(s->pb);
1505 size -= 4;
1506 }
1507 if (multitrack) {
1508 track_idx = avio_r8(s->pb);
1509 size--;
1510 }
1511
1512 if (enhanced_flv && (flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_VIDEO_INFO_CMD) {
1513 if (pkt_type == PacketTypeMetadata) {
1514 ret = flv_parse_video_color_info(s, st, next);
1515 if (ret < 0)
1516 goto leave;
1517 }
1518 goto skip;
1520 goto skip;
1521 }
1522 } else if (type == FLV_TAG_TYPE_META) {
1523 stream_type=FLV_STREAM_TYPE_SUBTITLE;
1524 if (size > 13 + 1 + 4) { // Header-type metadata stuff
1525 int type;
1526 meta_pos = avio_tell(s->pb);
1527 type = flv_read_metabody(s, next);
1528 if (type == 0 && dts == 0 || type < 0) {
1529 if (type < 0 && flv->validate_count &&
1530 flv->validate_index[0].pos > next &&
1531 flv->validate_index[0].pos - 4 < next) {
1532 av_log(s, AV_LOG_WARNING, "Adjusting next position due to index mismatch\n");
1533 next = flv->validate_index[0].pos - 4;
1534 }
1535 goto skip;
1536 } else if (type == TYPE_ONTEXTDATA) {
1537 avpriv_request_sample(s, "OnTextData packet");
1538 return flv_data_packet(s, pkt, dts, next);
1539 } else if (type == TYPE_ONCAPTION) {
1540 return flv_data_packet(s, pkt, dts, next);
1541 } else if (type == TYPE_UNKNOWN) {
1542 stream_type = FLV_STREAM_TYPE_DATA;
1543 }
1544 avio_seek(s->pb, meta_pos, SEEK_SET);
1545 }
1546 } else {
1548 "Skipping flv packet: type %d, size %d, flags %d.\n",
1549 type, size, flags);
1550skip:
1551 if (avio_seek(s->pb, next, SEEK_SET) != next) {
1552 // This can happen if flv_read_metabody above read past
1553 // next, on a non-seekable input, and the preceding data has
1554 // been flushed out from the IO buffer.
1555 av_log(s, AV_LOG_ERROR, "Unable to seek to the next packet\n");
1556 return AVERROR_INVALIDDATA;
1557 }
1558 ret = FFERROR_REDO;
1559 goto leave;
1560 }
1561
1562 /* skip empty data packets */
1563 if (!size) {
1564 ret = FFERROR_REDO;
1565 goto leave;
1566 }
1567
1568 if (flv->time_pos <= pos) {
1569 dts += flv->time_offset;
1570 }
1571
1572 for (;;) {
1573 int track_size = size;
1574 if (size < 0) {
1575 ret = FFERROR_REDO;
1576 goto leave;
1577 }
1578
1579 if (multitrack_type != MultitrackTypeOneTrack) {
1580 track_size = avio_rb24(s->pb);
1581 size -= 3;
1582 }
1583
1584 /* now find stream */
1585 for (i = 0; i < s->nb_streams; i++) {
1586 st = s->streams[i];
1587 if (stream_type == FLV_STREAM_TYPE_AUDIO) {
1589 (s->audio_codec_id || flv_same_audio_codec(st->codecpar, flags, codec_id)) &&
1590 st->id == track_idx)
1591 break;
1592 } else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
1594 (s->video_codec_id || flv_same_video_codec(st->codecpar, codec_id)) &&
1595 st->id == track_idx)
1596 break;
1597 } else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) {
1599 break;
1600 } else if (stream_type == FLV_STREAM_TYPE_DATA) {
1602 break;
1603 }
1604 }
1605 if (i == s->nb_streams) {
1607 st = create_stream(s, stream_types[stream_type], track_idx);
1608 if (!st)
1609 return AVERROR(ENOMEM);
1610 }
1611 av_log(s, AV_LOG_TRACE, "%d %X %d \n", stream_type, flags, st->discard);
1612
1613 if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
1615 stream_type == FLV_STREAM_TYPE_AUDIO))
1616 av_add_index_entry(st, pos, dts, track_size, 0, AVINDEX_KEYFRAME);
1617
1618 if ((st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || stream_type == FLV_STREAM_TYPE_AUDIO)) ||
1620 st->discard >= AVDISCARD_ALL) {
1621 avio_seek(s->pb, next, SEEK_SET);
1622 ret = FFERROR_REDO;
1623 goto leave;
1624 }
1625
1626 // if not streamed and no duration from metadata then seek to end to find
1627 // the duration from the timestamps
1628 if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
1629 (!s->duration || s->duration == AV_NOPTS_VALUE) &&
1630 !flv->searched_for_end) {
1631 int final_size;
1632 const int64_t pos = avio_tell(s->pb);
1633 // Read the last 4 bytes of the file, this should be the size of the
1634 // previous FLV tag. Use the timestamp of its payload as duration.
1635 int64_t fsize = avio_size(s->pb);
1636retry_duration:
1637 avio_seek(s->pb, fsize - 4, SEEK_SET);
1638 final_size = avio_rb32(s->pb);
1639 if (final_size > 0 && final_size < fsize) {
1640 // Seek to the start of the last FLV tag at position (fsize - 4 - final_size)
1641 // but skip the byte indicating the type.
1642 avio_seek(s->pb, fsize - 3 - final_size, SEEK_SET);
1643 if (final_size == avio_rb24(s->pb) + 11) {
1644 uint32_t ts = avio_rb24(s->pb);
1645 ts |= (unsigned)avio_r8(s->pb) << 24;
1646 if (ts)
1647 s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
1648 else if (fsize >= 8 && fsize - 8 >= final_size) {
1649 fsize -= final_size+4;
1650 goto retry_duration;
1651 }
1652 }
1653 }
1654
1655 avio_seek(s->pb, pos, SEEK_SET);
1656 flv->searched_for_end = 1;
1657 }
1658
1659 if (stream_type == FLV_STREAM_TYPE_AUDIO && !enhanced_flv) {
1660 int bits_per_coded_sample;
1662 sample_rate = 44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >>
1664 bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
1666 !st->codecpar->sample_rate ||
1670 st->codecpar->sample_rate = sample_rate;
1671 st->codecpar->bits_per_coded_sample = bits_per_coded_sample;
1672 }
1673 if (!st->codecpar->codec_id) {
1674 ret = flv_set_audio_codec(s, st, st->codecpar,
1676 if (ret < 0)
1677 goto leave;
1678 flv->last_sample_rate =
1679 sample_rate = st->codecpar->sample_rate;
1680 flv->last_channels =
1682 } else {
1684 if (!par) {
1685 ret = AVERROR(ENOMEM);
1686 goto leave;
1687 }
1688 par->sample_rate = sample_rate;
1689 par->bits_per_coded_sample = bits_per_coded_sample;
1691 if (ret < 0)
1692 goto leave;
1693 sample_rate = par->sample_rate;
1695 }
1696 } else if (stream_type == FLV_STREAM_TYPE_AUDIO) {
1697 if (!st->codecpar->codec_id) {
1698 ret = flv_set_audio_codec(s, st, st->codecpar,
1700 if (ret < 0)
1701 goto leave;
1702 }
1703
1704 // These are not signalled in the flags anymore
1705 channels = 0;
1706 sample_rate = 0;
1707
1708 if (pkt_type == AudioPacketTypeMultichannelConfig) {
1709 int channel_order = avio_r8(s->pb);
1710 channels = avio_r8(s->pb);
1711 size -= 2;
1712 track_size -= 2;
1713
1715
1716 if (channel_order == AudioChannelOrderCustom) {
1718 if (ret < 0)
1719 return ret;
1720
1721 for (i = 0; i < channels; i++) {
1722 uint8_t id = avio_r8(s->pb);
1723 size--;
1724 track_size--;
1725
1726 if (id < 18)
1727 st->codecpar->ch_layout.u.map[i].id = id;
1728 else if (id >= 18 && id <= 23)
1730 else if (id == 0xFE)
1732 else
1734 }
1735 } else if (channel_order == AudioChannelOrderNative) {
1736 uint64_t mask = avio_rb32(s->pb);
1737 size -= 4;
1738 track_size -= 4;
1739
1740 // The first 18 entries in the mask match ours, but the remaining 6 entries start at AV_CHAN_LOW_FREQUENCY_2
1741 mask = (mask & 0x3FFFF) | ((mask & 0xFC0000) << (AV_CHAN_LOW_FREQUENCY_2 - 18));
1743 if (ret < 0)
1744 return ret;
1745 } else {
1747 }
1748
1749 av_log(s, AV_LOG_DEBUG, "Set channel data from MultiChannel info.\n");
1750
1751 goto next_track;
1752 }
1753 } else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
1754 int sret = flv_set_video_codec(s, st, codec_id, 1);
1755 if (sret < 0)
1756 return sret;
1757 size -= sret;
1758 track_size -= sret;
1759 } else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) {
1761 } else if (stream_type == FLV_STREAM_TYPE_DATA) {
1762 st->codecpar->codec_id = AV_CODEC_ID_NONE; // Opaque AMF data
1763 }
1764
1765 if (st->codecpar->codec_id == AV_CODEC_ID_AAC ||
1774 int type = 0;
1775 if (enhanced_flv) {
1776 type = pkt_type;
1777 } else {
1778 type = avio_r8(s->pb);
1779 size--;
1780 track_size--;
1781 }
1782
1783 if (size < 0 || track_size < 0) {
1785 goto leave;
1786 }
1787
1788 if (enhanced_flv && stream_type == FLV_STREAM_TYPE_VIDEO &&
1790 flv_update_video_color_info(s, st); // update av packet side data
1792 }
1793
1794 if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
1798 (!enhanced_flv || type == PacketTypeCodedFrames))) {
1799 if (size < 3 || track_size < 3) {
1801 goto leave;
1802 }
1803 // sign extension
1804 int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
1805 pts = av_sat_add64(dts, cts);
1806 if (cts < 0) { // dts might be wrong
1807 if (!flv->wrong_dts)
1809 "Negative cts, previous timestamps might be wrong.\n");
1810 flv->wrong_dts = 1;
1811 } else if (FFABS(dts - pts) > 1000*60*15) {
1813 "invalid timestamps %"PRId64" %"PRId64"\n", dts, pts);
1814 dts = pts = AV_NOPTS_VALUE;
1815 }
1816 size -= 3;
1817 track_size -= 3;
1818 }
1819 if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC ||
1825
1826 if (st->codecpar->extradata) {
1827 if ((ret = flv_queue_extradata(flv, s->pb, multitrack ? track_idx : stream_type, track_size, multitrack)) < 0)
1828 return ret;
1829 ret = FFERROR_REDO;
1830 goto leave;
1831 }
1832 if ((ret = flv_get_extradata(s, st, track_size)) < 0)
1833 return ret;
1834
1835 /* Workaround for buggy Omnia A/XE encoder */
1836 t = av_dict_get(s->metadata, "Encoder", NULL, 0);
1837 if (st->codecpar->codec_id == AV_CODEC_ID_AAC && t && !strcmp(t->value, "Omnia A/XE"))
1838 st->codecpar->extradata_size = 2;
1839
1840 ret = FFERROR_REDO;
1841 goto leave;
1842 }
1843 }
1844
1845 /* skip empty or broken data packets */
1846 if (size <= 0 || track_size < 0) {
1847 ret = FFERROR_REDO;
1848 goto leave;
1849 }
1850
1851 /* skip empty data track */
1852 if (!track_size)
1853 goto next_track;
1854
1855 ret = av_get_packet(s->pb, pkt, track_size);
1856 if (ret < 0)
1857 return ret;
1858
1859 track_size -= ret;
1860 size -= ret;
1861
1862 pkt->dts = dts;
1863 pkt->pts = pts == AV_NOPTS_VALUE ? dts : pts;
1864 pkt->stream_index = st->index;
1865 pkt->pos = pos;
1866 if (!multitrack && flv->new_extradata[stream_type]) {
1868 flv->new_extradata[stream_type],
1869 flv->new_extradata_size[stream_type]);
1870 if (ret < 0)
1871 return ret;
1872
1873 flv->new_extradata[stream_type] = NULL;
1874 flv->new_extradata_size[stream_type] = 0;
1875 } else if (multitrack &&
1876 flv->mt_extradata_cnt > track_idx &&
1877 flv->mt_extradata[track_idx]) {
1879 flv->mt_extradata[track_idx],
1880 flv->mt_extradata_sz[track_idx]);
1881 if (ret < 0)
1882 return ret;
1883
1884 flv->mt_extradata[track_idx] = NULL;
1885 flv->mt_extradata_sz[track_idx] = 0;
1886 }
1887 if (stream_type == FLV_STREAM_TYPE_AUDIO && !enhanced_flv &&
1888 (sample_rate != flv->last_sample_rate ||
1889 channels != flv->last_channels)) {
1890 flv->last_sample_rate = sample_rate;
1891 flv->last_channels = channels;
1892 ff_add_param_change(pkt, channels, 0, sample_rate, 0, 0);
1893 }
1894
1895 if (stream_type == FLV_STREAM_TYPE_AUDIO ||
1897 stream_type == FLV_STREAM_TYPE_SUBTITLE ||
1898 stream_type == FLV_STREAM_TYPE_DATA)
1899 pkt->flags |= AV_PKT_FLAG_KEY;
1900
1902 if (ret < 0)
1903 return ret;
1904 res = FFERROR_REDO;
1905
1906next_track:
1907 if (track_size) {
1908 av_log(s, AV_LOG_WARNING, "Track size mismatch: %d!\n", track_size);
1909 if (!avio_feof(s->pb)) {
1910 if (track_size > 0) {
1911 avio_skip(s->pb, track_size);
1912 size -= track_size;
1913 } else {
1914 /* We have somehow read more than the track had to offer, leave and re-sync */
1915 ret = FFERROR_REDO;
1916 goto leave;
1917 }
1918 }
1919 }
1920
1921 if (!size)
1922 break;
1923
1924 if (multitrack_type == MultitrackTypeOneTrack) {
1925 av_log(s, AV_LOG_ERROR, "Attempted to read next track in single-track mode.\n");
1926 ret = FFERROR_REDO;
1927 goto leave;
1928 }
1929
1930 if (multitrack_type == MultitrackTypeManyTracksManyCodecs) {
1931 codec_id = avio_rb32(s->pb);
1932 size -= 4;
1933 }
1934
1935 track_idx = avio_r8(s->pb);
1936 size--;
1937
1938 if (avio_feof(s->pb)) {
1939 av_log(s, AV_LOG_WARNING, "Premature EOF\n");
1940 /* return REDO so that any potentially queued up packages can be drained first */
1941 return FFERROR_REDO;
1942 }
1943 }
1944
1945 ret = 0;
1946leave:
1947 last = avio_rb32(s->pb);
1948 if (!flv->trust_datasize) {
1949 if (last != orig_size + 11 && last != orig_size + 10 &&
1950 !avio_feof(s->pb) &&
1951 (last != orig_size || !last) && last != flv->sum_flv_tag_size &&
1952 !flv->broken_sizes) {
1953 av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %"PRId64"\n", last, orig_size + 11, flv->sum_flv_tag_size);
1954 avio_seek(s->pb, pos + 1, SEEK_SET);
1955 ret = resync(s);
1957 if (ret >= 0) {
1958 goto retry;
1959 }
1960 }
1961 }
1962
1963 if (ret >= 0)
1964 flv->last_ts = pkt->dts;
1965
1966 return ret ? ret : res;
1967}
1968
1969static int flv_read_seek(AVFormatContext *s, int stream_index,
1970 int64_t ts, int flags)
1971{
1972 FLVContext *flv = s->priv_data;
1973 flv->validate_count = 0;
1974 return avio_seek_time(s->pb, stream_index, ts, flags);
1975}
1976
1977#define OFFSET(x) offsetof(FLVContext, x)
1978#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1979static const AVOption options[] = {
1980 { "flv_metadata", "Allocate streams according to the onMetaData array", OFFSET(trust_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
1981 { "flv_full_metadata", "Dump full metadata of the onMetadata", OFFSET(dump_full_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
1982 { "flv_ignore_prevtag", "Ignore the Size of previous tag", OFFSET(trust_datasize), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
1983 { NULL }
1984};
1985
1986static const AVClass flv_kux_class = {
1987 .class_name = "(live) flv/kux demuxer",
1988 .item_name = av_default_item_name,
1989 .option = options,
1990 .version = LIBAVUTIL_VERSION_INT,
1991};
1992
1994 .p.name = "flv",
1995 .p.long_name = NULL_IF_CONFIG_SMALL("FLV (Flash Video)"),
1996 .p.extensions = "flv",
1997 .p.priv_class = &flv_kux_class,
1998 .priv_data_size = sizeof(FLVContext),
2004};
2005
2007 .p.name = "live_flv",
2008 .p.long_name = NULL_IF_CONFIG_SMALL("live RTMP FLV (Flash Video)"),
2009 .p.extensions = "flv",
2010 .p.priv_class = &flv_kux_class,
2011 .p.flags = AVFMT_TS_DISCONT,
2012 .priv_data_size = sizeof(FLVContext),
2018};
2019
2021 .p.name = "kux",
2022 .p.long_name = NULL_IF_CONFIG_SMALL("KUX (YouKu)"),
2023 .p.extensions = "kux",
2024 .p.priv_class = &flv_kux_class,
2025 .priv_data_size = sizeof(FLVContext),
2031};
const FFInputFormat ff_live_flv_demuxer
Definition flvdec.c:2006
const FFInputFormat ff_flv_demuxer
Definition flvdec.c:1993
const FFInputFormat ff_kux_demuxer
Definition flvdec.c:2020
#define VD
Definition amfdec.c:807
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:96
@ 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:812
static const int factor[16]
Definition vf_pp7.c:98
static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
Definition flvdec.c:862
static void add_keyframes_index(AVFormatContext *s)
Definition flvdec.c:169
static int flv_read_header(AVFormatContext *s)
Definition flvdec.c:919
static int flv_parse_video_color_info(AVFormatContext *s, AVStream *st, int64_t next_pos)
Definition flvdec.c:1211
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:1381
static const AVClass flv_kux_class
Definition flvdec.c:1986
#define RESYNC_BUFFER_SIZE
Definition flvdec.c:46
static int flv_update_video_color_info(AVFormatContext *s, AVStream *st)
Definition flvdec.c:1248
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:973
#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:860
static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize)
Definition flvdec.c:504
#define TYPE_ONCAPTIONINFO
Definition flvdec.c:859
#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:857
#define TYPE_ONCAPTION
Definition flvdec.c:858
static int flv_data_packet(AVFormatContext *s, AVPacket *pkt, int64_t dts, int64_t next)
Definition flvdec.c:1100
static int resync(AVFormatContext *s)
Definition flvdec.c:1169
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:1977
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:1034
static int flv_queue_extradata(FLVContext *flv, AVIOContext *pb, int stream, int size, int multitrack)
Definition flvdec.c:985
static int flv_read_close(AVFormatContext *s)
Definition flvdec.c:958
static int amf_skip_tag(AVIOContext *pb, AMFDataType type, int depth)
Definition flvdec.c:1049
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:1325
static int flv_read_seek(AVFormatContext *s, int stream_index, int64_t ts, int flags)
Definition flvdec.c:1969
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:392
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:98
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