* qatar/master: doc: Improve references to external URLs. h264: move decode_mb_skip() from h264.h to h.264_mvpred.h ffplay: skip return value of avcodec_decode_video2 / avcodec_decode_subtitle2 dnxhdenc: Replace a forward declaration by the proper #include. h264: move h264_mvpred.h include. pix_fmt: Fix number of bits per component in yuv444p9be lavf: deprecate AVFormatContext.timestamp ffmpeg: merge input_files_ts_scale into InputStream. ffmpeg: don't abuse a global for passing sample format from input to output ffmpeg: don't abuse a global for passing channel layout from input to output ffmpeg: factor common code from new_a/v/s/d_stream to new_output_stream() matroskaenc: make SSA default subtitle codec. oggdec: prevent heap corruption. Conflicts: doc/developer.texi doc/faq.texi doc/general.texi ffmpeg.c ffplay.c
Unified · Split
| @@ -34,6 +34,7 @@ You can use libavcodec or libavformat in your commercial program, but · 33 unmodified lines | ||
| 34 | 34 | @emph{any patch you make must be published}. The best way to proceed is |
| 35 | 35 | to send your patches to the FFmpeg mailing list. |
| 36 | 36 | |
| 37 | + | |
| 37 | 38 | @anchor{Coding Rules} |
| 38 | 39 | @section Coding Rules |
| 39 | 40 | |
| @@ -47,7 +47,7 @@ Likely reasons · 46 unmodified lines | ||
| 47 | 47 | @item We are busy and haven't had time yet to read your report or |
| 48 | 48 | investigate the issue. |
| 49 | 49 | @item You didn't follow @url{http://ffmpeg.org/bugreports.html}. |
| 50 | −@item You didn't use git HEAD. | |
| 50 | +@item You didn't use git master. | |
| 51 | 51 | @item You reported a segmentation fault without gdb output. |
| 52 | 52 | @item You describe a problem but not how to reproduce it. |
| 53 | 53 | @item It's unclear if you use ffmpeg as command line tool or use |
| @@ -123,7 +123,8 @@ problem and an NP-hard problem... · 69 unmodified lines | ||
| 123 | 123 | |
| 124 | 124 | @section ffmpeg does not work; what is wrong? |
| 125 | 125 | |
| 126 | −Try a @code{make distclean} in the ffmpeg source directory before the build. If this does not help see | |
| 126 | +Try a @code{make distclean} in the ffmpeg source directory before the build. | |
| 127 | +If this does not help see | |
| 127 | 128 | (@url{http://ffmpeg.org/bugreports.html}). |
| 128 | 129 | |
| 129 | 130 | @section How do I encode single pictures into movies? |
| @@ -285,7 +286,8 @@ Just create an "input.avs" text file with this single line ... · 155 unmodified lines | ||
| 285 | 286 | ffmpeg -i input.avs |
| 286 | 287 | @end example |
| 287 | 288 | |
| 288 | −For ANY other help on Avisynth, please visit @url{http://www.avisynth.org/}. | |
| 289 | +For ANY other help on Avisynth, please visit the | |
| 290 | +@uref{http://www.avisynth.org/, Avisynth homepage}. | |
| 289 | 291 | |
| 290 | 292 | @section How can I join video files? |
| 291 | 293 | |
| @@ -417,7 +419,7 @@ No. These tools are too bloated and they complicate the build. · 125 unmodified lines | ||
| 417 | 419 | FFmpeg is already organized in a highly modular manner and does not need to |
| 418 | 420 | be rewritten in a formal object language. Further, many of the developers |
| 419 | 421 | favor straight C; it works for them. For more arguments on this matter, |
| 420 | −read "Programming Religion" at (@url{http://www.tux.org/lkml/#s15}). | |
| 422 | +read @uref{http://www.tux.org/lkml/#s15, "Programming Religion"}. | |
| 421 | 423 | |
| 422 | 424 | @section Why are the ffmpeg programs devoid of debugging symbols? |
| 423 | 425 | |
| @@ -888,8 +888,8 @@ ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg · 887 unmodified lines | ||
| 888 | 888 | @end example |
| 889 | 889 | |
| 890 | 890 | Note that you must activate the right video source and channel before |
| 891 | −launching ffmpeg with any TV viewer such as xawtv | |
| 892 | −(@url{http://linux.bytesex.org/xawtv/}) by Gerd Knorr. You also | |
| 891 | +launching ffmpeg with any TV viewer such as | |
| 892 | +@uref{http://linux.bytesex.org/xawtv/, xawtv} by Gerd Knorr. You also | |
| 893 | 893 | have to set the audio recording levels correctly with a |
| 894 | 894 | standard mixer. |
| 895 | 895 | |
| @@ -848,7 +848,7 @@ noticeable when running make for a second time (for example in · 847 unmodified lines | ||
| 848 | 848 | @code{make install}). |
| 849 | 849 | |
| 850 | 850 | @item In order to compile FFplay, you must have the MinGW development library |
| 851 | −of SDL. Get it from @url{http://www.libsdl.org}. | |
| 851 | +of @uref{http://www.libsdl.org/, SDL}. | |
| 852 | 852 | Edit the @file{bin/sdl-config} script so that it points to the correct prefix |
| 853 | 853 | where SDL was installed. Verify that @file{sdl-config} can be launched from |
| 854 | 854 | the MSYS command line. |
| @@ -1044,8 +1044,7 @@ Then configure FFmpeg with the following options: · 189 unmodified lines | ||
| 1044 | 1044 | (you can change the cross-prefix according to the prefix chosen for the |
| 1045 | 1045 | MinGW tools). |
| 1046 | 1046 | |
| 1047 | −Then you can easily test FFmpeg with Wine | |
| 1048 | −(@url{http://www.winehq.com/}). | |
| 1047 | +Then you can easily test FFmpeg with @uref{http://www.winehq.com/, Wine}. | |
| 1049 | 1048 | |
| 1050 | 1049 | @subsection Compilation under Cygwin |
| 1051 | 1050 | |
| @@ -1084,8 +1083,8 @@ If you want to build FFmpeg with additional libraries, download Cygwin · 32 unmodified lines | ||
| 1084 | 1083 | libogg-devel, libvorbis-devel |
| 1085 | 1084 | @end example |
| 1086 | 1085 | |
| 1087 | −These library packages are only available from Cygwin Ports | |
| 1088 | −(@url{http://sourceware.org/cygwinports/}) : | |
| 1086 | +These library packages are only available from | |
| 1087 | +@uref{http://sourceware.org/cygwinports/, Cygwin Ports}: | |
| 1089 | 1088 | |
| 1090 | 1089 | @example |
| 1091 | 1090 | yasm, libSDL-devel, libdirac-devel, libfaac-devel, libgsm-devel, |
| @@ -242,7 +242,7 @@ data transferred over RDT). · 241 unmodified lines | ||
| 242 | 242 | |
| 243 | 243 | The muxer can be used to send a stream using RTSP ANNOUNCE to a server |
| 244 | 244 | supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's |
| 245 | −RTSP server, @url{http://github.com/revmischa/rtsp-server}). | |
| 245 | +@uref{http://github.com/revmischa/rtsp-server, RTSP server}). | |
| 246 | 246 | |
| 247 | 247 | The required syntax for a RTSP url is: |
| 248 | 248 | @example |
| @@ -117,8 +117,8 @@ static const OptionDef options[]; · 116 unmodified lines | ||
| 117 | 117 | #define MAX_STREAMS 1024 /* arbitrary sanity check value */ |
| 118 | 118 | |
| 119 | 119 | static const char *last_asked_format = NULL; |
| 120 | −static double *input_files_ts_scale[MAX_FILES] = {NULL}; | |
| 121 | −static int nb_input_files_ts_scale[MAX_FILES] = {0}; | |
| 120 | +static double *ts_scale; | |
| 121 | +static int nb_ts_scale; | |
| 122 | 122 | |
| 123 | 123 | static AVFormatContext *output_files[MAX_FILES]; |
| 124 | 124 | static int nb_output_files = 0; |
| @@ -171,7 +171,6 @@ static char *vfilters = NULL; · 46 unmodified lines | ||
| 171 | 171 | |
| 172 | 172 | static int intra_only = 0; |
| 173 | 173 | static int audio_sample_rate = 0; |
| 174 | −static int64_t channel_layout = 0; | |
| 175 | 174 | #define QSCALE_NONE -99999 |
| 176 | 175 | static float audio_qscale = QSCALE_NONE; |
| 177 | 176 | static int audio_disable = 0; |
| @@ -194,7 +193,6 @@ static float mux_max_delay= 0.7; · 16 unmodified lines | ||
| 194 | 193 | |
| 195 | 194 | static int64_t recording_time = INT64_MAX; |
| 196 | 195 | static int64_t start_time = 0; |
| 197 | −static int64_t recording_timestamp = 0; | |
| 198 | 196 | static int64_t input_ts_offset = 0; |
| 199 | 197 | static int file_overwrite = 0; |
| 200 | 198 | static AVDictionary *metadata; |
| @@ -327,6 +325,7 @@ typedef struct InputStream { · 126 unmodified lines | ||
| 327 | 325 | int64_t next_pts; /* synthetic pts for cases where pkt.pts |
| 328 | 326 | is not defined */ |
| 329 | 327 | int64_t pts; /* current pts */ |
| 328 | + double ts_scale; | |
| 330 | 329 | int is_start; /* is 1 at the start and after a discontinuity */ |
| 331 | 330 | int showed_multi_packet_warning; |
| 332 | 331 | int is_past_recording_time; |
| @@ -538,7 +537,6 @@ static int ffmpeg_exit(int ret) · 205 unmodified lines | ||
| 538 | 537 | } |
| 539 | 538 | for(i=0;i<nb_input_files;i++) { |
| 540 | 539 | av_close_input_file(input_files[i].ctx); |
| 541 | − av_free(input_files_ts_scale[i]); | |
| 542 | 540 | } |
| 543 | 541 | |
| 544 | 542 | av_free(intra_matrix); |
| @@ -671,10 +669,16 @@ static void choose_pixel_fmt(AVStream *st, AVCodec *codec) · 126 unmodified lines | ||
| 671 | 669 | } |
| 672 | 670 | } |
| 673 | 671 | |
| 674 | −static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx) | |
| 672 | +static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx, AVCodec *codec) | |
| 675 | 673 | { |
| 676 | − int idx = oc->nb_streams - 1; | |
| 677 | 674 | OutputStream *ost; |
| 675 | + AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); | |
| 676 | + int idx = oc->nb_streams - 1; | |
| 677 | + | |
| 678 | + if (!st) { | |
| 679 | + av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n"); | |
| 680 | + ffmpeg_exit(1); | |
| 681 | + } | |
| 678 | 682 | |
| 679 | 683 | output_streams_for_file[file_idx] = |
| 680 | 684 | grow_array(output_streams_for_file[file_idx], |
| @@ -689,6 +693,10 @@ static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx) · 8 unmodified lines | ||
| 689 | 693 | } |
| 690 | 694 | ost->file_index = file_idx; |
| 691 | 695 | ost->index = idx; |
| 696 | + ost->st = st; | |
| 697 | + ost->enc = codec; | |
| 698 | + | |
| 699 | + avcodec_get_context_defaults3(st->codec, codec); | |
| 692 | 700 | |
| 693 | 701 | ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); |
| 694 | 702 | return ost; |
| @@ -704,28 +712,21 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename) · 9 unmodified lines | ||
| 704 | 712 | if (err < 0) |
| 705 | 713 | return err; |
| 706 | 714 | /* copy stream format */ |
| 707 | − s->nb_streams = 0; | |
| 708 | − s->streams = av_mallocz(sizeof(AVStream *) * ic->nb_streams); | |
| 709 | 715 | for(i=0;i<ic->nb_streams;i++) { |
| 710 | 716 | AVStream *st; |
| 717 | + OutputStream *ost; | |
| 711 | 718 | AVCodec *codec; |
| 712 | 719 | |
| 713 | − s->nb_streams++; | |
| 720 | + codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id); | |
| 721 | + ost = new_output_stream(s, nb_output_files, codec); | |
| 722 | + st = ost->st; | |
| 714 | 723 | |
| 715 | 724 | // FIXME: a more elegant solution is needed |
| 716 | − st = av_mallocz(sizeof(AVStream)); | |
| 717 | 725 | memcpy(st, ic->streams[i], sizeof(AVStream)); |
| 718 | 726 | st->info = av_malloc(sizeof(*st->info)); |
| 719 | 727 | memcpy(st->info, ic->streams[i]->info, sizeof(*st->info)); |
| 720 | − st->codec = avcodec_alloc_context(); | |
| 721 | − if (!st->codec) { | |
| 722 | − print_error(filename, AVERROR(ENOMEM)); | |
| 723 | − ffmpeg_exit(1); | |
| 724 | − } | |
| 725 | 728 | avcodec_copy_context(st->codec, ic->streams[i]->codec); |
| 726 | − s->streams[i] = st; | |
| 727 | 729 | |
| 728 | − codec = avcodec_find_encoder(st->codec->codec_id); | |
| 729 | 730 | if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { |
| 730 | 731 | if (audio_stream_copy) { |
| 731 | 732 | st->stream_copy = 1; |
| @@ -740,13 +741,8 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename) · 8 unmodified lines | ||
| 740 | 741 | |
| 741 | 742 | if(st->codec->flags & CODEC_FLAG_BITEXACT) |
| 742 | 743 | nopts = 1; |
| 743 | − | |
| 744 | − new_output_stream(s, nb_output_files); | |
| 745 | 744 | } |
| 746 | 745 | |
| 747 | − if (!nopts) | |
| 748 | − s->timestamp = av_gettime(); | |
| 749 | − | |
| 750 | 746 | av_close_input_file(ic); |
| 751 | 747 | return 0; |
| 752 | 748 | } |
| @@ -2102,7 +2098,6 @@ static int transcode(AVFormatContext **output_files, · 1349 unmodified lines | ||
| 2102 | 2098 | for(i=0;i<os->nb_streams;i++,n++) { |
| 2103 | 2099 | int found; |
| 2104 | 2100 | ost = ost_table[n] = output_streams_for_file[k][i]; |
| 2105 | − ost->st = os->streams[i]; | |
| 2106 | 2101 | if (nb_stream_maps > 0) { |
| 2107 | 2102 | ost->source_index = input_files[stream_maps[n].file_index].ist_index + |
| 2108 | 2103 | stream_maps[n].stream_index; |
| @@ -2278,6 +2273,9 @@ static int transcode(AVFormatContext **output_files, · 169 unmodified lines | ||
| 2278 | 2273 | } |
| 2279 | 2274 | choose_sample_rate(ost->st, ost->enc); |
| 2280 | 2275 | codec->time_base = (AVRational){1, codec->sample_rate}; |
| 2276 | + if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) | |
| 2277 | + codec->sample_fmt = icodec->sample_fmt; | |
| 2278 | + choose_sample_fmt(ost->st, ost->enc); | |
| 2281 | 2279 | if (!codec->channels) { |
| 2282 | 2280 | codec->channels = icodec->channels; |
| 2283 | 2281 | codec->channel_layout = icodec->channel_layout; |
| @@ -2738,12 +2736,11 @@ static int transcode(AVFormatContext **output_files, · 454 unmodified lines | ||
| 2738 | 2736 | if (pkt.pts != AV_NOPTS_VALUE) |
| 2739 | 2737 | pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); |
| 2740 | 2738 | |
| 2741 | − if (pkt.stream_index < nb_input_files_ts_scale[file_index] | |
| 2742 | − && input_files_ts_scale[file_index][pkt.stream_index]){ | |
| 2739 | + if (ist->ts_scale) { | |
| 2743 | 2740 | if(pkt.pts != AV_NOPTS_VALUE) |
| 2744 | − pkt.pts *= input_files_ts_scale[file_index][pkt.stream_index]; | |
| 2741 | + pkt.pts *= ist->ts_scale; | |
| 2745 | 2742 | if(pkt.dts != AV_NOPTS_VALUE) |
| 2746 | − pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index]; | |
| 2743 | + pkt.dts *= ist->ts_scale; | |
| 2747 | 2744 | } |
| 2748 | 2745 | |
| 2749 | 2746 | // fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files[ist->file_index].ts_offset, ist->st->codec->codec_type); |
| @@ -3203,8 +3200,8 @@ static int opt_input_ts_scale(const char *opt, const char *arg) · 453 unmodified lines | ||
| 3203 | 3200 | if(stream >= MAX_STREAMS) |
| 3204 | 3201 | ffmpeg_exit(1); |
| 3205 | 3202 | |
| 3206 | − input_files_ts_scale[nb_input_files] = grow_array(input_files_ts_scale[nb_input_files], sizeof(*input_files_ts_scale[nb_input_files]), &nb_input_files_ts_scale[nb_input_files], stream + 1); | |
| 3207 | − input_files_ts_scale[nb_input_files][stream]= scale; | |
| 3203 | + ts_scale = grow_array(ts_scale, sizeof(*ts_scale), &nb_ts_scale, stream + 1); | |
| 3204 | + ts_scale[stream] = scale; | |
| 3208 | 3205 | return 0; |
| 3209 | 3206 | } |
| 3210 | 3207 | |
| @@ -3222,7 +3219,14 @@ static int opt_start_time(const char *opt, const char *arg) · 11 unmodified lines | ||
| 3222 | 3219 | |
| 3223 | 3220 | static int opt_recording_timestamp(const char *opt, const char *arg) |
| 3224 | 3221 | { |
| 3225 | − recording_timestamp = parse_time_or_die(opt, arg, 0) / 1000000; | |
| 3222 | + char buf[128]; | |
| 3223 | + int64_t recording_timestamp = parse_time_or_die(opt, arg, 0) / 1E6; | |
| 3224 | + struct tm time = *gmtime((time_t*)&recording_timestamp); | |
| 3225 | + strftime(buf, sizeof(buf), "creation_time=%FT%T%z", &time); | |
| 3226 | + opt_metadata("metadata", buf); | |
| 3227 | + | |
| 3228 | + av_log(NULL, AV_LOG_WARNING, "%s is deprecated, set the 'creation_time' metadata " | |
| 3229 | + "tag instead.\n", opt); | |
| 3226 | 3230 | return 0; |
| 3227 | 3231 | } |
| 3228 | 3232 | |
| @@ -3401,14 +3405,15 @@ static int opt_input_file(const char *opt, const char *filename) · 172 unmodified lines | ||
| 3401 | 3405 | ist->file_index = nb_input_files; |
| 3402 | 3406 | ist->discard = 1; |
| 3403 | 3407 | |
| 3408 | + if (i < nb_ts_scale) | |
| 3409 | + ist->ts_scale = ts_scale[i]; | |
| 3410 | + | |
| 3404 | 3411 | switch (dec->codec_type) { |
| 3405 | 3412 | case AVMEDIA_TYPE_AUDIO: |
| 3406 | 3413 | ist->dec = avcodec_find_decoder_by_name(audio_codec_name); |
| 3407 | 3414 | if(!ist->dec) |
| 3408 | 3415 | ist->dec = avcodec_find_decoder(dec->codec_id); |
| 3409 | 3416 | set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, ist->dec); |
| 3410 | − channel_layout = dec->channel_layout; | |
| 3411 | − audio_sample_fmt = dec->sample_fmt; | |
| 3412 | 3417 | if(audio_disable) |
| 3413 | 3418 | st->discard= AVDISCARD_ALL; |
| 3414 | 3419 | break; |
| @@ -3475,6 +3480,9 @@ static int opt_input_file(const char *opt, const char *filename) · 60 unmodified lines | ||
| 3475 | 3480 | frame_width = 0; |
| 3476 | 3481 | audio_sample_rate = 0; |
| 3477 | 3482 | audio_channels = 0; |
| 3483 | + audio_sample_fmt = AV_SAMPLE_FMT_NONE; | |
| 3484 | + av_freep(&ts_scale); | |
| 3485 | + nb_ts_scale = 0; | |
| 3478 | 3486 | |
| 3479 | 3487 | av_freep(&video_codec_name); |
| 3480 | 3488 | av_freep(&audio_codec_name); |
| @@ -3535,23 +3543,20 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) · 54 unmodified lines | ||
| 3535 | 3543 | enum CodecID codec_id = CODEC_ID_NONE; |
| 3536 | 3544 | AVCodec *codec= NULL; |
| 3537 | 3545 | |
| 3538 | − st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); | |
| 3539 | − if (!st) { | |
| 3540 | − fprintf(stderr, "Could not alloc stream\n"); | |
| 3541 | − ffmpeg_exit(1); | |
| 3542 | − } | |
| 3543 | − ost = new_output_stream(oc, file_idx); | |
| 3544 | − | |
| 3545 | 3546 | if(!video_stream_copy){ |
| 3546 | 3547 | if (video_codec_name) { |
| 3547 | 3548 | codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1, |
| 3548 | 3549 | avcodec_opts[AVMEDIA_TYPE_VIDEO]->strict_std_compliance); |
| 3549 | 3550 | codec = avcodec_find_encoder_by_name(video_codec_name); |
| 3550 | − ost->enc = codec; | |
| 3551 | 3551 | } else { |
| 3552 | 3552 | codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO); |
| 3553 | 3553 | codec = avcodec_find_encoder(codec_id); |
| 3554 | 3554 | } |
| 3555 | + } | |
| 3556 | + | |
| 3557 | + ost = new_output_stream(oc, file_idx, codec); | |
| 3558 | + st = ost->st; | |
| 3559 | + if (!video_stream_copy) { | |
| 3555 | 3560 | ost->frame_aspect_ratio = frame_aspect_ratio; |
| 3556 | 3561 | frame_aspect_ratio = 0; |
| 3557 | 3562 | #if CONFIG_AVFILTER |
| @@ -3560,7 +3565,6 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) · 2 unmodified lines | ||
| 3560 | 3565 | #endif |
| 3561 | 3566 | } |
| 3562 | 3567 | |
| 3563 | − avcodec_get_context_defaults3(st->codec, codec); | |
| 3564 | 3568 | ost->bitstream_filters = video_bitstream_filters; |
| 3565 | 3569 | video_bitstream_filters= NULL; |
| 3566 | 3570 | |
| @@ -3674,26 +3678,18 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) · 107 unmodified lines | ||
| 3674 | 3678 | AVCodecContext *audio_enc; |
| 3675 | 3679 | enum CodecID codec_id = CODEC_ID_NONE; |
| 3676 | 3680 | |
| 3677 | − st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); | |
| 3678 | − if (!st) { | |
| 3679 | − fprintf(stderr, "Could not alloc stream\n"); | |
| 3680 | − ffmpeg_exit(1); | |
| 3681 | − } | |
| 3682 | − ost = new_output_stream(oc, file_idx); | |
| 3683 | − | |
| 3684 | 3681 | if(!audio_stream_copy){ |
| 3685 | 3682 | if (audio_codec_name) { |
| 3686 | 3683 | codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1, |
| 3687 | 3684 | avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance); |
| 3688 | 3685 | codec = avcodec_find_encoder_by_name(audio_codec_name); |
| 3689 | − ost->enc = codec; | |
| 3690 | 3686 | } else { |
| 3691 | 3687 | codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO); |
| 3692 | 3688 | codec = avcodec_find_encoder(codec_id); |
| 3693 | 3689 | } |
| 3694 | 3690 | } |
| 3695 | − | |
| 3696 | − avcodec_get_context_defaults3(st->codec, codec); | |
| 3691 | + ost = new_output_stream(oc, file_idx, codec); | |
| 3692 | + st = ost->st; | |
| 3697 | 3693 | |
| 3698 | 3694 | ost->bitstream_filters = audio_bitstream_filters; |
| 3699 | 3695 | audio_bitstream_filters= NULL; |
| @@ -3722,11 +3718,10 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) · 22 unmodified lines | ||
| 3722 | 3718 | } |
| 3723 | 3719 | if (audio_channels) |
| 3724 | 3720 | audio_enc->channels = audio_channels; |
| 3725 | − audio_enc->sample_fmt = audio_sample_fmt; | |
| 3721 | + if (audio_sample_fmt != AV_SAMPLE_FMT_NONE) | |
| 3722 | + audio_enc->sample_fmt = audio_sample_fmt; | |
| 3726 | 3723 | if (audio_sample_rate) |
| 3727 | 3724 | audio_enc->sample_rate = audio_sample_rate; |
| 3728 | − audio_enc->channel_layout = channel_layout; | |
| 3729 | − choose_sample_fmt(st, codec); | |
| 3730 | 3725 | } |
| 3731 | 3726 | if (audio_language) { |
| 3732 | 3727 | av_dict_set(&st->metadata, "language", audio_language, 0); |
| @@ -3742,21 +3737,16 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) · 9 unmodified lines | ||
| 3742 | 3737 | static void new_data_stream(AVFormatContext *oc, int file_idx) |
| 3743 | 3738 | { |
| 3744 | 3739 | AVStream *st; |
| 3745 | − AVCodec *codec=NULL; | |
| 3740 | + OutputStream *ost; | |
| 3746 | 3741 | AVCodecContext *data_enc; |
| 3747 | 3742 | |
| 3748 | − st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); | |
| 3749 | − if (!st) { | |
| 3750 | − fprintf(stderr, "Could not alloc stream\n"); | |
| 3751 | − ffmpeg_exit(1); | |
| 3752 | − } | |
| 3753 | − new_output_stream(oc, file_idx); | |
| 3743 | + ost = new_output_stream(oc, file_idx, NULL); | |
| 3744 | + st = ost->st; | |
| 3754 | 3745 | data_enc = st->codec; |
| 3755 | 3746 | if (!data_stream_copy) { |
| 3756 | 3747 | fprintf(stderr, "Data stream encoding not supported yet (only streamcopy)\n"); |
| 3757 | 3748 | ffmpeg_exit(1); |
| 3758 | 3749 | } |
| 3759 | − avcodec_get_context_defaults3(st->codec, codec); | |
| 3760 | 3750 | |
| 3761 | 3751 | data_enc->codec_type = AVMEDIA_TYPE_DATA; |
| 3762 | 3752 | |
| @@ -3784,25 +3774,19 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) · 21 unmodified lines | ||
| 3784 | 3774 | AVCodecContext *subtitle_enc; |
| 3785 | 3775 | enum CodecID codec_id = CODEC_ID_NONE; |
| 3786 | 3776 | |
| 3787 | − st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); | |
| 3788 | − if (!st) { | |
| 3789 | − fprintf(stderr, "Could not alloc stream\n"); | |
| 3790 | − ffmpeg_exit(1); | |
| 3791 | − } | |
| 3792 | − ost = new_output_stream(oc, file_idx); | |
| 3793 | − subtitle_enc = st->codec; | |
| 3794 | 3777 | if(!subtitle_stream_copy){ |
| 3795 | 3778 | if (subtitle_codec_name) { |
| 3796 | 3779 | codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, |
| 3797 | 3780 | avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); |
| 3798 | 3781 | codec = avcodec_find_encoder_by_name(subtitle_codec_name); |
| 3799 | − ost->enc = codec; | |
| 3800 | 3782 | } else { |
| 3801 | 3783 | codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE); |
| 3802 | 3784 | codec = avcodec_find_encoder(codec_id); |
| 3803 | 3785 | } |
| 3804 | 3786 | } |
| 3805 | − avcodec_get_context_defaults3(st->codec, codec); | |
| 3787 | + ost = new_output_stream(oc, file_idx, codec); | |
| 3788 | + st = ost->st; | |
| 3789 | + subtitle_enc = st->codec; | |
| 3806 | 3790 | |
| 3807 | 3791 | ost->bitstream_filters = subtitle_bitstream_filters; |
| 3808 | 3792 | subtitle_bitstream_filters= NULL; |
| @@ -3938,8 +3922,6 @@ static int opt_output_file(const char *opt, const char *filename) · 129 unmodified lines | ||
| 3938 | 3922 | if (use_subtitle) new_subtitle_stream(oc, nb_output_files); |
| 3939 | 3923 | if (use_data) new_data_stream(oc, nb_output_files); |
| 3940 | 3924 | |
| 3941 | − oc->timestamp = recording_timestamp; | |
| 3942 | − | |
| 3943 | 3925 | av_dict_copy(&oc->metadata, metadata, 0); |
| 3944 | 3926 | av_dict_free(&metadata); |
| 3945 | 3927 | } |
| @@ -4005,6 +3987,7 @@ static int opt_output_file(const char *opt, const char *filename) · 59 unmodified lines | ||
| 4005 | 3987 | frame_height = 0; |
| 4006 | 3988 | audio_sample_rate = 0; |
| 4007 | 3989 | audio_channels = 0; |
| 3990 | + audio_sample_fmt = AV_SAMPLE_FMT_NONE; | |
| 4008 | 3991 | |
| 4009 | 3992 | av_freep(&forced_key_frames); |
| 4010 | 3993 | uninit_opts(); |
| @@ -1431,7 +1431,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_ · 1430 unmodified lines | ||
| 1431 | 1431 | |
| 1432 | 1432 | static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt) |
| 1433 | 1433 | { |
| 1434 | − int len1 av_unused, got_picture, i; | |
| 1434 | + int got_picture, i; | |
| 1435 | 1435 | |
| 1436 | 1436 | if (packet_queue_get(&is->videoq, pkt, 1) < 0) |
| 1437 | 1437 | return -1; |
| @@ -1458,9 +1458,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke · 20 unmodified lines | ||
| 1458 | 1458 | return 0; |
| 1459 | 1459 | } |
| 1460 | 1460 | |
| 1461 | − len1 = avcodec_decode_video2(is->video_st->codec, | |
| 1462 | − frame, &got_picture, | |
| 1463 | − pkt); | |
| 1461 | + avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt); | |
| 1464 | 1462 | |
| 1465 | 1463 | if (got_picture) { |
| 1466 | 1464 | if (decoder_reorder_pts == -1) { |
| @@ -1807,7 +1805,7 @@ static int subtitle_thread(void *arg) · 340 unmodified lines | ||
| 1807 | 1805 | VideoState *is = arg; |
| 1808 | 1806 | SubPicture *sp; |
| 1809 | 1807 | AVPacket pkt1, *pkt = &pkt1; |
| 1810 | − int len1 av_unused, got_subtitle; | |
| 1808 | + int got_subtitle; | |
| 1811 | 1809 | double pts; |
| 1812 | 1810 | int i, j; |
| 1813 | 1811 | int r, g, b, y, u, v, a; |
| @@ -1841,9 +1839,9 @@ static int subtitle_thread(void *arg) · 27 unmodified lines | ||
| 1841 | 1839 | if (pkt->pts != AV_NOPTS_VALUE) |
| 1842 | 1840 | pts = av_q2d(is->subtitle_st->time_base)*pkt->pts; |
| 1843 | 1841 | |
| 1844 | − len1 = avcodec_decode_subtitle2(is->subtitle_st->codec, | |
| 1845 | − &sp->sub, &got_subtitle, | |
| 1846 | − pkt); | |
| 1842 | + avcodec_decode_subtitle2(is->subtitle_st->codec, &sp->sub, | |
| 1843 | + &got_subtitle, pkt); | |
| 1844 | + | |
| 1847 | 1845 | if (got_subtitle && sp->sub.format == 0) { |
| 1848 | 1846 | sp->pts = pts; |
| 1849 | 1847 | |
| @@ -28,6 +28,7 @@ · 27 unmodified lines | ||
| 28 | 28 | #include "avcodec.h" |
| 29 | 29 | #include "dsputil.h" |
| 30 | 30 | #include "mpegvideo.h" |
| 31 | +#include "mpegvideo_common.h" | |
| 31 | 32 | #include "dnxhdenc.h" |
| 32 | 33 | |
| 33 | 34 | #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
| @@ -38,8 +39,6 @@ static const AVOption options[]={ · 4 unmodified lines | ||
| 38 | 39 | }; |
| 39 | 40 | static const AVClass class = { "dnxhd", av_default_item_name, options, LIBAVUTIL_VERSION_INT }; |
| 40 | 41 | |
| 41 | −int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); | |
| 42 | − | |
| 43 | 42 | #define LAMBDA_FRAC_BITS 10 |
| 44 | 43 | |
| 45 | 44 | static av_always_inline void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, int line_size) |
| @@ -770,8 +770,6 @@ static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){ · 769 unmodified lines | ||
| 770 | 770 | return h->pps.chroma_qp_table[t][qscale]; |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | −static av_always_inline void pred_pskip_motion(H264Context * const h); | |
| 774 | − | |
| 775 | 773 | static void fill_decode_neighbors(H264Context *h, int mb_type){ |
| 776 | 774 | MpegEncContext * const s = &h->s; |
| 777 | 775 | const int mb_xy= h->mb_xy; |
| @@ -1302,45 +1300,4 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h){ · 524 unmodified lines | ||
| 1302 | 1300 | return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8|MB_TYPE_DIRECT2)*0x0001000100010001ULL)); |
| 1303 | 1301 | } |
| 1304 | 1302 | |
| 1305 | −/** | |
| 1306 | − * decodes a P_SKIP or B_SKIP macroblock | |
| 1307 | − */ | |
| 1308 | −static void av_unused decode_mb_skip(H264Context *h){ | |
| 1309 | − MpegEncContext * const s = &h->s; | |
| 1310 | − const int mb_xy= h->mb_xy; | |
| 1311 | − int mb_type=0; | |
| 1312 | − | |
| 1313 | − memset(h->non_zero_count[mb_xy], 0, 48); | |
| 1314 | − | |
| 1315 | − if(MB_FIELD) | |
| 1316 | − mb_type|= MB_TYPE_INTERLACED; | |
| 1317 | − | |
| 1318 | − if( h->slice_type_nos == AV_PICTURE_TYPE_B ) | |
| 1319 | − { | |
| 1320 | − // just for fill_caches. pred_direct_motion will set the real mb_type | |
| 1321 | − mb_type|= MB_TYPE_L0L1|MB_TYPE_DIRECT2|MB_TYPE_SKIP; | |
| 1322 | − if(h->direct_spatial_mv_pred){ | |
| 1323 | − fill_decode_neighbors(h, mb_type); | |
| 1324 | − fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ... | |
| 1325 | − } | |
| 1326 | − ff_h264_pred_direct_motion(h, &mb_type); | |
| 1327 | − mb_type|= MB_TYPE_SKIP; | |
| 1328 | − } | |
| 1329 | − else | |
| 1330 | − { | |
| 1331 | − mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP; | |
| 1332 | − | |
| 1333 | − fill_decode_neighbors(h, mb_type); | |
| 1334 | − pred_pskip_motion(h); | |
| 1335 | − } | |
| 1336 | − | |
| 1337 | − write_back_motion(h, mb_type); | |
| 1338 | − s->current_picture.f.mb_type[mb_xy] = mb_type; | |
| 1339 | − s->current_picture.f.qscale_table[mb_xy] = s->qscale; | |
| 1340 | − h->slice_table[ mb_xy ]= h->slice_num; | |
| 1341 | − h->prev_mb_skipped= 1; | |
| 1342 | −} | |
| 1343 | − | |
| 1344 | −#include "h264_mvpred.h" //For pred_pskip_motion() | |
| 1345 | − | |
| 1346 | 1303 | #endif /* AVCODEC_H264_H */ |
| @@ -327,4 +327,43 @@ zeromv: · 326 unmodified lines | ||
| 327 | 327 | return; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | +/** | |
| 331 | + * decodes a P_SKIP or B_SKIP macroblock | |
| 332 | + */ | |
| 333 | +static void av_unused decode_mb_skip(H264Context *h){ | |
| 334 | + MpegEncContext * const s = &h->s; | |
| 335 | + const int mb_xy= h->mb_xy; | |
| 336 | + int mb_type=0; | |
| 337 | + | |
| 338 | + memset(h->non_zero_count[mb_xy], 0, 48); | |
| 339 | + | |
| 340 | + if(MB_FIELD) | |
| 341 | + mb_type|= MB_TYPE_INTERLACED; | |
| 342 | + | |
| 343 | + if( h->slice_type_nos == AV_PICTURE_TYPE_B ) | |
| 344 | + { | |
| 345 | + // just for fill_caches. pred_direct_motion will set the real mb_type | |
| 346 | + mb_type|= MB_TYPE_L0L1|MB_TYPE_DIRECT2|MB_TYPE_SKIP; | |
| 347 | + if(h->direct_spatial_mv_pred){ | |
| 348 | + fill_decode_neighbors(h, mb_type); | |
| 349 | + fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ... | |
| 350 | + } | |
| 351 | + ff_h264_pred_direct_motion(h, &mb_type); | |
| 352 | + mb_type|= MB_TYPE_SKIP; | |
| 353 | + } | |
| 354 | + else | |
| 355 | + { | |
| 356 | + mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP; | |
| 357 | + | |
| 358 | + fill_decode_neighbors(h, mb_type); | |
| 359 | + pred_pskip_motion(h); | |
| 360 | + } | |
| 361 | + | |
| 362 | + write_back_motion(h, mb_type); | |
| 363 | + s->current_picture.f.mb_type[mb_xy] = mb_type; | |
| 364 | + s->current_picture.f.qscale_table[mb_xy] = s->qscale; | |
| 365 | + h->slice_table[ mb_xy ]= h->slice_num; | |
| 366 | + h->prev_mb_skipped= 1; | |
| 367 | +} | |
| 368 | + | |
| 330 | 369 | #endif /* AVCODEC_H264_MVPRED_H */ |
| @@ -698,7 +698,12 @@ typedef struct AVFormatContext { · 697 unmodified lines | ||
| 698 | 698 | AVStream **streams; |
| 699 | 699 | char filename[1024]; /**< input or output filename */ |
| 700 | 700 | /* stream info */ |
| 701 | − int64_t timestamp; | |
| 701 | +#if FF_API_TIMESTAMP | |
| 702 | + /** | |
| 703 | + * @deprecated use 'creation_time' metadata tag instead | |
| 704 | + */ | |
| 705 | + attribute_deprecated int64_t timestamp; | |
| 706 | +#endif | |
| 702 | 707 | |
| 703 | 708 | int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ |
| 704 | 709 | /* private data for pts handling (do not modify directly). */ |
| @@ -43,7 +43,7 @@ struct DVMuxContext { · 42 unmodified lines | ||
| 43 | 43 | AVStream *ast[2]; /* stereo audio streams */ |
| 44 | 44 | AVFifoBuffer *audio_data[2]; /* FIFO for storing excessive amounts of PCM */ |
| 45 | 45 | int frames; /* current frame number */ |
| 46 | − time_t start_time; /* recording start time */ | |
| 46 | + int64_t start_time; /* recording start time */ | |
| 47 | 47 | int has_audio; /* frame under contruction has audio */ |
| 48 | 48 | int has_video; /* frame under contruction has video */ |
| 49 | 49 | uint8_t frame_buf[DV_MAX_FRAME_SIZE]; /* frame under contruction */ |
| @@ -290,6 +290,7 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) · 240 unmodified lines | ||
| 290 | 290 | { |
| 291 | 291 | DVMuxContext *c = s->priv_data; |
| 292 | 292 | AVStream *vst = NULL; |
| 293 | + AVDictionaryEntry *t; | |
| 293 | 294 | int i; |
| 294 | 295 | |
| 295 | 296 | /* we support at most 1 video and 2 audio streams */ |
| @@ -337,7 +338,16 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) · 41 unmodified lines | ||
| 337 | 338 | c->frames = 0; |
| 338 | 339 | c->has_audio = 0; |
| 339 | 340 | c->has_video = 0; |
| 340 | − c->start_time = (time_t)s->timestamp; | |
| 341 | +#if FF_API_TIMESTAMP | |
| 342 | + if (s->timestamp) | |
| 343 | + c->start_time = s->timestamp; | |
| 344 | + else | |
| 345 | +#endif | |
| 346 | + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { | |
| 347 | + struct tm time = {0}; | |
| 348 | + strptime(t->value, "%Y - %m - %dT%T", &time); | |
| 349 | + c->start_time = mktime(&time); | |
| 350 | + } | |
| 341 | 351 | |
| 342 | 352 | for (i=0; i < c->n_ast; i++) { |
| 343 | 353 | if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc(100*AVCODEC_MAX_AUDIO_FRAME_SIZE))) { |
| @@ -394,6 +394,20 @@ static int gxf_write_umf_material_description(AVFormatContext *s) · 393 unmodified lines | ||
| 394 | 394 | GXFContext *gxf = s->priv_data; |
| 395 | 395 | AVIOContext *pb = s->pb; |
| 396 | 396 | int timecode_base = gxf->time_base.den == 60000 ? 60 : 50; |
| 397 | + int64_t timestamp = 0; | |
| 398 | + AVDictionaryEntry *t; | |
| 399 | + | |
| 400 | +#if FF_API_TIMESTAMP | |
| 401 | + if (s->timestamp) | |
| 402 | + timestamp = s->timestamp; | |
| 403 | + else | |
| 404 | +#endif | |
| 405 | + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { | |
| 406 | + struct tm time = {0}; | |
| 407 | + strptime(t->value, "%Y - %m - %dT%T", &time); | |
| 408 | + timestamp = mktime(&time); | |
| 409 | + } | |
| 410 | + | |
| 397 | 411 | |
| 398 | 412 | // XXX drop frame |
| 399 | 413 | uint32_t timecode = |
| @@ -409,8 +423,8 @@ static int gxf_write_umf_material_description(AVFormatContext *s) · 9 unmodified lines | ||
| 409 | 423 | avio_wl32(pb, gxf->nb_fields); /* mark out */ |
| 410 | 424 | avio_wl32(pb, 0); /* timecode mark in */ |
| 411 | 425 | avio_wl32(pb, timecode); /* timecode mark out */ |
| 412 | − avio_wl64(pb, s->timestamp); /* modification time */ | |
| 413 | − avio_wl64(pb, s->timestamp); /* creation time */ | |
| 426 | + avio_wl64(pb, timestamp); /* modification time */ | |
| 427 | + avio_wl64(pb, timestamp); /* creation time */ | |
| 414 | 428 | avio_wl16(pb, 0); /* reserved */ |
| 415 | 429 | avio_wl16(pb, 0); /* reserved */ |
| 416 | 430 | avio_wl16(pb, gxf->audio_tracks); |
| @@ -1212,7 +1212,7 @@ AVOutputFormat ff_matroska_muxer = { · 1211 unmodified lines | ||
| 1212 | 1212 | mkv_write_trailer, |
| 1213 | 1213 | .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, |
| 1214 | 1214 | .codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0}, |
| 1215 | − .subtitle_codec = CODEC_ID_TEXT, | |
| 1215 | + .subtitle_codec = CODEC_ID_SSA, | |
| 1216 | 1216 | }; |
| 1217 | 1217 | #endif |
| 1218 | 1218 | |
| @@ -2142,6 +2142,7 @@ static int mov_write_header(AVFormatContext *s) · 2141 unmodified lines | ||
| 2142 | 2142 | { |
| 2143 | 2143 | AVIOContext *pb = s->pb; |
| 2144 | 2144 | MOVMuxContext *mov = s->priv_data; |
| 2145 | + AVDictionaryEntry *t; | |
| 2145 | 2146 | int i, hint_track = 0; |
| 2146 | 2147 | |
| 2147 | 2148 | if (!s->pb->seekable) { |
| @@ -2272,7 +2273,18 @@ static int mov_write_header(AVFormatContext *s) · 124 unmodified lines | ||
| 2272 | 2273 | } |
| 2273 | 2274 | |
| 2274 | 2275 | mov_write_mdat_tag(pb, mov); |
| 2275 | − mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based | |
| 2276 | + | |
| 2277 | +#if FF_API_TIMESTAMP | |
| 2278 | + if (s->timestamp) | |
| 2279 | + mov->time = s->timestamp; | |
| 2280 | + else | |
| 2281 | +#endif | |
| 2282 | + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { | |
| 2283 | + struct tm time = {0}; | |
| 2284 | + strptime(t->value, "%Y - %m - %dT%T", &time); | |
| 2285 | + mov->time = mktime(&time); | |
| 2286 | + } | |
| 2287 | + mov->time += 0x7C25B080; //1970 based -> 1904 based | |
| 2276 | 2288 | |
| 2277 | 2289 | if (mov->chapter_track) |
| 2278 | 2290 | mov_create_chapter_track(s, mov->chapter_track); |
| @@ -1407,6 +1407,8 @@ static int mxf_write_header(AVFormatContext *s) · 1406 unmodified lines | ||
| 1407 | 1407 | int i; |
| 1408 | 1408 | uint8_t present[FF_ARRAY_ELEMS(mxf_essence_container_uls)] = {0}; |
| 1409 | 1409 | const int *samples_per_frame = NULL; |
| 1410 | + AVDictionaryEntry *t; | |
| 1411 | + int64_t timestamp = 0; | |
| 1410 | 1412 | |
| 1411 | 1413 | if (!s->nb_streams) |
| 1412 | 1414 | return -1; |
| @@ -1512,8 +1514,18 @@ static int mxf_write_header(AVFormatContext *s) · 99 unmodified lines | ||
| 1512 | 1514 | sc->order = AV_RB32(sc->track_essence_element_key+12); |
| 1513 | 1515 | } |
| 1514 | 1516 | |
| 1517 | +#if FF_API_TIMESTAMP | |
| 1515 | 1518 | if (s->timestamp) |
| 1516 | − mxf->timestamp = mxf_parse_timestamp(s->timestamp); | |
| 1519 | + timestamp = s->timestamp; | |
| 1520 | + else | |
| 1521 | +#endif | |
| 1522 | + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { | |
| 1523 | + struct tm time = {0}; | |
| 1524 | + strptime(t->value, "%Y - %m - %dT%T", &time); | |
| 1525 | + timestamp = mktime(&time); | |
| 1526 | + } | |
| 1527 | + if (timestamp) | |
| 1528 | + mxf->timestamp = mxf_parse_timestamp(timestamp); | |
| 1517 | 1529 | mxf->duration = -1; |
| 1518 | 1530 | |
| 1519 | 1531 | mxf->timecode_track = av_mallocz(sizeof(*mxf->timecode_track)); |
| @@ -605,15 +605,15 @@ static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index, · 604 unmodified lines | ||
| 605 | 605 | int64_t *pos_arg, int64_t pos_limit) |
| 606 | 606 | { |
| 607 | 607 | struct ogg *ogg = s->priv_data; |
| 608 | − struct ogg_stream *os = ogg->streams + stream_index; | |
| 609 | 608 | AVIOContext *bc = s->pb; |
| 610 | 609 | int64_t pts = AV_NOPTS_VALUE; |
| 611 | − int i; | |
| 610 | + int i = -1; | |
| 612 | 611 | avio_seek(bc, *pos_arg, SEEK_SET); |
| 613 | 612 | ogg_reset(ogg); |
| 614 | 613 | |
| 615 | 614 | while (avio_tell(bc) < pos_limit && !ogg_packet(s, &i, NULL, NULL, pos_arg)) { |
| 616 | 615 | if (i == stream_index) { |
| 616 | + struct ogg_stream *os = ogg->streams + stream_index; | |
| 617 | 617 | pts = ogg_calc_pts(s, i, NULL); |
| 618 | 618 | if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY)) |
| 619 | 619 | pts = AV_NOPTS_VALUE; |
| @@ -639,6 +639,7 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index, · 19 unmodified lines | ||
| 639 | 639 | os->keyframe_seek = 1; |
| 640 | 640 | |
| 641 | 641 | ret = av_seek_frame_binary(s, stream_index, timestamp, flags); |
| 642 | + os = ogg->streams + stream_index; | |
| 642 | 643 | if (ret < 0) |
| 643 | 644 | os->keyframe_seek = 0; |
| 644 | 645 | return ret; |
| @@ -86,5 +86,8 @@ · 85 unmodified lines | ||
| 86 | 86 | #ifndef FF_API_LOOP_OUTPUT |
| 87 | 87 | #define FF_API_LOOP_OUTPUT (LIBAVFORMAT_VERSION_MAJOR < 54) |
| 88 | 88 | #endif |
| 89 | +#ifndef FF_API_TIMESTAMP | |
| 90 | +#define FF_API_TIMESTAMP (LIBAVFORMAT_VERSION_MAJOR < 54) | |
| 91 | +#endif | |
| 89 | 92 | |
| 90 | 93 | #endif /* AVFORMAT_VERSION_H */ |
| @@ -918,9 +918,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { · 917 unmodified lines | ||
| 918 | 918 | .log2_chroma_w= 0, |
| 919 | 919 | .log2_chroma_h= 0, |
| 920 | 920 | .comp = { |
| 921 | − {0,1,1,0,9}, /* Y */ | |
| 922 | − {1,1,1,0,9}, /* U */ | |
| 923 | − {2,1,1,0,9}, /* V */ | |
| 921 | + {0,1,1,0,8}, /* Y */ | |
| 922 | + {1,1,1,0,8}, /* U */ | |
| 923 | + {2,1,1,0,8}, /* V */ | |
| 924 | 924 | }, |
| 925 | 925 | .flags = PIX_FMT_BE, |
| 926 | 926 | }, |