* 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 | @emph{any patch you make must be published}. The best way to proceed is | 34 | @emph{any patch you make must be published}. The best way to proceed is |
| 35 | to send your patches to the FFmpeg mailing list. | 35 | to send your patches to the FFmpeg mailing list. |
| 36 | 36 | ||
| 37 | |||
| 37 | @anchor{Coding Rules} | 38 | @anchor{Coding Rules} |
| 38 | @section Coding Rules | 39 | @section Coding Rules |
| 39 | 40 | ||
| @@ -47,7 +47,7 @@ Likely reasons · 46 unmodified lines | |||
| 47 | @item We are busy and haven't had time yet to read your report or | 47 | @item We are busy and haven't had time yet to read your report or |
| 48 | investigate the issue. | 48 | investigate the issue. |
| 49 | @item You didn't follow @url{http://ffmpeg.org/bugreports.html}. | 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 | @item You reported a segmentation fault without gdb output. | 51 | @item You reported a segmentation fault without gdb output. |
| 52 | @item You describe a problem but not how to reproduce it. | 52 | @item You describe a problem but not how to reproduce it. |
| 53 | @item It's unclear if you use ffmpeg as command line tool or use | 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 | @section ffmpeg does not work; what is wrong? | 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 | (@url{http://ffmpeg.org/bugreports.html}). | 128 | (@url{http://ffmpeg.org/bugreports.html}). |
| 128 | 129 | ||
| 129 | @section How do I encode single pictures into movies? | 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 | ffmpeg -i input.avs | 286 | ffmpeg -i input.avs |
| 286 | @end example | 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 | @section How can I join video files? | 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 | FFmpeg is already organized in a highly modular manner and does not need to | 419 | FFmpeg is already organized in a highly modular manner and does not need to |
| 418 | be rewritten in a formal object language. Further, many of the developers | 420 | be rewritten in a formal object language. Further, many of the developers |
| 419 | favor straight C; it works for them. For more arguments on this matter, | 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 | @section Why are the ffmpeg programs devoid of debugging symbols? | 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 | @end example | 888 | @end example |
| 889 | 889 | ||
| 890 | Note that you must activate the right video source and channel before | 890 | Note that you must activate the right video source and channel before |
| 891 | launching ffmpeg with any TV viewer such as xawtv | 891 | launching ffmpeg with any TV viewer such as |
| 892 | (@url{http://linux.bytesex.org/xawtv/}) by Gerd Knorr. You also | 892 | @uref{http://linux.bytesex.org/xawtv/, xawtv} by Gerd Knorr. You also |
| 893 | have to set the audio recording levels correctly with a | 893 | have to set the audio recording levels correctly with a |
| 894 | standard mixer. | 894 | standard mixer. |
| 895 | 895 | ||
| @@ -848,7 +848,7 @@ noticeable when running make for a second time (for example in · 847 unmodified lines | |||
| 848 | @code{make install}). | 848 | @code{make install}). |
| 849 | 849 | ||
| 850 | @item In order to compile FFplay, you must have the MinGW development library | 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 | Edit the @file{bin/sdl-config} script so that it points to the correct prefix | 852 | Edit the @file{bin/sdl-config} script so that it points to the correct prefix |
| 853 | where SDL was installed. Verify that @file{sdl-config} can be launched from | 853 | where SDL was installed. Verify that @file{sdl-config} can be launched from |
| 854 | the MSYS command line. | 854 | the MSYS command line. |
| @@ -1044,8 +1044,7 @@ Then configure FFmpeg with the following options: · 189 unmodified lines | |||
| 1044 | (you can change the cross-prefix according to the prefix chosen for the | 1044 | (you can change the cross-prefix according to the prefix chosen for the |
| 1045 | MinGW tools). | 1045 | MinGW tools). |
| 1046 | 1046 | ||
| 1047 | Then you can easily test FFmpeg with Wine | 1047 | Then you can easily test FFmpeg with @uref{http://www.winehq.com/, Wine}. |
| 1048 | (@url{http://www.winehq.com/}). | ||
| 1049 | 1048 | ||
| 1050 | @subsection Compilation under Cygwin | 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 | libogg-devel, libvorbis-devel | 1083 | libogg-devel, libvorbis-devel |
| 1085 | @end example | 1084 | @end example |
| 1086 | 1085 | ||
| 1087 | These library packages are only available from Cygwin Ports | 1086 | These library packages are only available from |
| 1088 | (@url{http://sourceware.org/cygwinports/}) : | 1087 | @uref{http://sourceware.org/cygwinports/, Cygwin Ports}: |
| 1089 | 1088 | ||
| 1090 | @example | 1089 | @example |
| 1091 | yasm, libSDL-devel, libdirac-devel, libfaac-devel, libgsm-devel, | 1090 | yasm, libSDL-devel, libdirac-devel, libfaac-devel, libgsm-devel, |
| @@ -242,7 +242,7 @@ data transferred over RDT). · 241 unmodified lines | |||
| 242 | 242 | ||
| 243 | The muxer can be used to send a stream using RTSP ANNOUNCE to a server | 243 | The muxer can be used to send a stream using RTSP ANNOUNCE to a server |
| 244 | supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's | 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 | The required syntax for a RTSP url is: | 247 | The required syntax for a RTSP url is: |
| 248 | @example | 248 | @example |
| @@ -117,8 +117,8 @@ static const OptionDef options[]; · 116 unmodified lines | |||
| 117 | #define MAX_STREAMS 1024 /* arbitrary sanity check value */ | 117 | #define MAX_STREAMS 1024 /* arbitrary sanity check value */ |
| 118 | 118 | ||
| 119 | static const char *last_asked_format = NULL; | 119 | static const char *last_asked_format = NULL; |
| 120 | static double *input_files_ts_scale[MAX_FILES] = {NULL}; | 120 | static double *ts_scale; |
| 121 | static int nb_input_files_ts_scale[MAX_FILES] = {0}; | 121 | static int nb_ts_scale; |
| 122 | 122 | ||
| 123 | static AVFormatContext *output_files[MAX_FILES]; | 123 | static AVFormatContext *output_files[MAX_FILES]; |
| 124 | static int nb_output_files = 0; | 124 | static int nb_output_files = 0; |
| @@ -171,7 +171,6 @@ static char *vfilters = NULL; · 46 unmodified lines | |||
| 171 | 171 | ||
| 172 | static int intra_only = 0; | 172 | static int intra_only = 0; |
| 173 | static int audio_sample_rate = 0; | 173 | static int audio_sample_rate = 0; |
| 174 | static int64_t channel_layout = 0; | ||
| 175 | #define QSCALE_NONE -99999 | 174 | #define QSCALE_NONE -99999 |
| 176 | static float audio_qscale = QSCALE_NONE; | 175 | static float audio_qscale = QSCALE_NONE; |
| 177 | static int audio_disable = 0; | 176 | static int audio_disable = 0; |
| @@ -194,7 +193,6 @@ static float mux_max_delay= 0.7; · 16 unmodified lines | |||
| 194 | 193 | ||
| 195 | static int64_t recording_time = INT64_MAX; | 194 | static int64_t recording_time = INT64_MAX; |
| 196 | static int64_t start_time = 0; | 195 | static int64_t start_time = 0; |
| 197 | static int64_t recording_timestamp = 0; | ||
| 198 | static int64_t input_ts_offset = 0; | 196 | static int64_t input_ts_offset = 0; |
| 199 | static int file_overwrite = 0; | 197 | static int file_overwrite = 0; |
| 200 | static AVDictionary *metadata; | 198 | static AVDictionary *metadata; |
| @@ -327,6 +325,7 @@ typedef struct InputStream { · 126 unmodified lines | |||
| 327 | int64_t next_pts; /* synthetic pts for cases where pkt.pts | 325 | int64_t next_pts; /* synthetic pts for cases where pkt.pts |
| 328 | is not defined */ | 326 | is not defined */ |
| 329 | int64_t pts; /* current pts */ | 327 | int64_t pts; /* current pts */ |
| 328 | double ts_scale; | ||
| 330 | int is_start; /* is 1 at the start and after a discontinuity */ | 329 | int is_start; /* is 1 at the start and after a discontinuity */ |
| 331 | int showed_multi_packet_warning; | 330 | int showed_multi_packet_warning; |
| 332 | int is_past_recording_time; | 331 | int is_past_recording_time; |
| @@ -538,7 +537,6 @@ static int ffmpeg_exit(int ret) · 205 unmodified lines | |||
| 538 | } | 537 | } |
| 539 | for(i=0;i<nb_input_files;i++) { | 538 | for(i=0;i<nb_input_files;i++) { |
| 540 | av_close_input_file(input_files[i].ctx); | 539 | av_close_input_file(input_files[i].ctx); |
| 541 | av_free(input_files_ts_scale[i]); | ||
| 542 | } | 540 | } |
| 543 | 541 | ||
| 544 | av_free(intra_matrix); | 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 | OutputStream *ost; | 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 | output_streams_for_file[file_idx] = | 683 | output_streams_for_file[file_idx] = |
| 680 | grow_array(output_streams_for_file[file_idx], | 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 | ost->file_index = file_idx; | 694 | ost->file_index = file_idx; |
| 691 | ost->index = idx; | 695 | ost->index = idx; |
| 696 | ost->st = st; | ||
| 697 | ost->enc = codec; | ||
| 698 | |||
| 699 | avcodec_get_context_defaults3(st->codec, codec); | ||
| 692 | 700 | ||
| 693 | ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); | 701 | ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); |
| 694 | return ost; | 702 | return ost; |
| @@ -704,28 +712,21 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename) · 9 unmodified lines | |||
| 704 | if (err < 0) | 712 | if (err < 0) |
| 705 | return err; | 713 | return err; |
| 706 | /* copy stream format */ | 714 | /* copy stream format */ |
| 707 | s->nb_streams = 0; | ||
| 708 | s->streams = av_mallocz(sizeof(AVStream *) * ic->nb_streams); | ||
| 709 | for(i=0;i<ic->nb_streams;i++) { | 715 | for(i=0;i<ic->nb_streams;i++) { |
| 710 | AVStream *st; | 716 | AVStream *st; |
| 717 | OutputStream *ost; | ||
| 711 | AVCodec *codec; | 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 | // FIXME: a more elegant solution is needed | 724 | // FIXME: a more elegant solution is needed |
| 716 | st = av_mallocz(sizeof(AVStream)); | ||
| 717 | memcpy(st, ic->streams[i], sizeof(AVStream)); | 725 | memcpy(st, ic->streams[i], sizeof(AVStream)); |
| 718 | st->info = av_malloc(sizeof(*st->info)); | 726 | st->info = av_malloc(sizeof(*st->info)); |
| 719 | memcpy(st->info, ic->streams[i]->info, sizeof(*st->info)); | 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 | avcodec_copy_context(st->codec, ic->streams[i]->codec); | 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 | if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { | 730 | if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { |
| 730 | if (audio_stream_copy) { | 731 | if (audio_stream_copy) { |
| 731 | st->stream_copy = 1; | 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 | if(st->codec->flags & CODEC_FLAG_BITEXACT) | 742 | if(st->codec->flags & CODEC_FLAG_BITEXACT) |
| 742 | nopts = 1; | 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 | av_close_input_file(ic); | 746 | av_close_input_file(ic); |
| 751 | return 0; | 747 | return 0; |
| 752 | } | 748 | } |
| @@ -2102,7 +2098,6 @@ static int transcode(AVFormatContext **output_files, · 1349 unmodified lines | |||
| 2102 | for(i=0;i<os->nb_streams;i++,n++) { | 2098 | for(i=0;i<os->nb_streams;i++,n++) { |
| 2103 | int found; | 2099 | int found; |
| 2104 | ost = ost_table[n] = output_streams_for_file[k][i]; | 2100 | ost = ost_table[n] = output_streams_for_file[k][i]; |
| 2105 | ost->st = os->streams[i]; | ||
| 2106 | if (nb_stream_maps > 0) { | 2101 | if (nb_stream_maps > 0) { |
| 2107 | ost->source_index = input_files[stream_maps[n].file_index].ist_index + | 2102 | ost->source_index = input_files[stream_maps[n].file_index].ist_index + |
| 2108 | stream_maps[n].stream_index; | 2103 | stream_maps[n].stream_index; |
| @@ -2278,6 +2273,9 @@ static int transcode(AVFormatContext **output_files, · 169 unmodified lines | |||
| 2278 | } | 2273 | } |
| 2279 | choose_sample_rate(ost->st, ost->enc); | 2274 | choose_sample_rate(ost->st, ost->enc); |
| 2280 | codec->time_base = (AVRational){1, codec->sample_rate}; | 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 | if (!codec->channels) { | 2279 | if (!codec->channels) { |
| 2282 | codec->channels = icodec->channels; | 2280 | codec->channels = icodec->channels; |
| 2283 | codec->channel_layout = icodec->channel_layout; | 2281 | codec->channel_layout = icodec->channel_layout; |
| @@ -2738,12 +2736,11 @@ static int transcode(AVFormatContext **output_files, · 454 unmodified lines | |||
| 2738 | if (pkt.pts != AV_NOPTS_VALUE) | 2736 | if (pkt.pts != AV_NOPTS_VALUE) |
| 2739 | pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base); | 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] | 2739 | if (ist->ts_scale) { |
| 2742 | && input_files_ts_scale[file_index][pkt.stream_index]){ | ||
| 2743 | if(pkt.pts != AV_NOPTS_VALUE) | 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 | if(pkt.dts != AV_NOPTS_VALUE) | 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 | // 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); | 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 | if(stream >= MAX_STREAMS) | 3200 | if(stream >= MAX_STREAMS) |
| 3204 | ffmpeg_exit(1); | 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); | 3203 | ts_scale = grow_array(ts_scale, sizeof(*ts_scale), &nb_ts_scale, stream + 1); |
| 3207 | input_files_ts_scale[nb_input_files][stream]= scale; | 3204 | ts_scale[stream] = scale; |
| 3208 | return 0; | 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 | static int opt_recording_timestamp(const char *opt, const char *arg) | 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 | return 0; | 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 | ist->file_index = nb_input_files; | 3405 | ist->file_index = nb_input_files; |
| 3402 | ist->discard = 1; | 3406 | ist->discard = 1; |
| 3403 | 3407 | ||
| 3408 | if (i < nb_ts_scale) | ||
| 3409 | ist->ts_scale = ts_scale[i]; | ||
| 3410 | |||
| 3404 | switch (dec->codec_type) { | 3411 | switch (dec->codec_type) { |
| 3405 | case AVMEDIA_TYPE_AUDIO: | 3412 | case AVMEDIA_TYPE_AUDIO: |
| 3406 | ist->dec = avcodec_find_decoder_by_name(audio_codec_name); | 3413 | ist->dec = avcodec_find_decoder_by_name(audio_codec_name); |
| 3407 | if(!ist->dec) | 3414 | if(!ist->dec) |
| 3408 | ist->dec = avcodec_find_decoder(dec->codec_id); | 3415 | ist->dec = avcodec_find_decoder(dec->codec_id); |
| 3409 | set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, ist->dec); | 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 | if(audio_disable) | 3417 | if(audio_disable) |
| 3413 | st->discard= AVDISCARD_ALL; | 3418 | st->discard= AVDISCARD_ALL; |
| 3414 | break; | 3419 | break; |
| @@ -3475,6 +3480,9 @@ static int opt_input_file(const char *opt, const char *filename) · 60 unmodified lines | |||
| 3475 | frame_width = 0; | 3480 | frame_width = 0; |
| 3476 | audio_sample_rate = 0; | 3481 | audio_sample_rate = 0; |
| 3477 | audio_channels = 0; | 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 | av_freep(&video_codec_name); | 3487 | av_freep(&video_codec_name); |
| 3480 | av_freep(&audio_codec_name); | 3488 | av_freep(&audio_codec_name); |
| @@ -3535,23 +3543,20 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) · 54 unmodified lines | |||
| 3535 | enum CodecID codec_id = CODEC_ID_NONE; | 3543 | enum CodecID codec_id = CODEC_ID_NONE; |
| 3536 | AVCodec *codec= NULL; | 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 | if(!video_stream_copy){ | 3546 | if(!video_stream_copy){ |
| 3546 | if (video_codec_name) { | 3547 | if (video_codec_name) { |
| 3547 | codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1, | 3548 | codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1, |
| 3548 | avcodec_opts[AVMEDIA_TYPE_VIDEO]->strict_std_compliance); | 3549 | avcodec_opts[AVMEDIA_TYPE_VIDEO]->strict_std_compliance); |
| 3549 | codec = avcodec_find_encoder_by_name(video_codec_name); | 3550 | codec = avcodec_find_encoder_by_name(video_codec_name); |
| 3550 | ost->enc = codec; | ||
| 3551 | } else { | 3551 | } else { |
| 3552 | codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO); | 3552 | codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO); |
| 3553 | codec = avcodec_find_encoder(codec_id); | 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 | ost->frame_aspect_ratio = frame_aspect_ratio; | 3560 | ost->frame_aspect_ratio = frame_aspect_ratio; |
| 3556 | frame_aspect_ratio = 0; | 3561 | frame_aspect_ratio = 0; |
| 3557 | #if CONFIG_AVFILTER | 3562 | #if CONFIG_AVFILTER |
| @@ -3560,7 +3565,6 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) · 2 unmodified lines | |||
| 3560 | #endif | 3565 | #endif |
| 3561 | } | 3566 | } |
| 3562 | 3567 | ||
| 3563 | avcodec_get_context_defaults3(st->codec, codec); | ||
| 3564 | ost->bitstream_filters = video_bitstream_filters; | 3568 | ost->bitstream_filters = video_bitstream_filters; |
| 3565 | video_bitstream_filters= NULL; | 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 | AVCodecContext *audio_enc; | 3678 | AVCodecContext *audio_enc; |
| 3675 | enum CodecID codec_id = CODEC_ID_NONE; | 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 | if(!audio_stream_copy){ | 3681 | if(!audio_stream_copy){ |
| 3685 | if (audio_codec_name) { | 3682 | if (audio_codec_name) { |
| 3686 | codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1, | 3683 | codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1, |
| 3687 | avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance); | 3684 | avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance); |
| 3688 | codec = avcodec_find_encoder_by_name(audio_codec_name); | 3685 | codec = avcodec_find_encoder_by_name(audio_codec_name); |
| 3689 | ost->enc = codec; | ||
| 3690 | } else { | 3686 | } else { |
| 3691 | codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO); | 3687 | codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO); |
| 3692 | codec = avcodec_find_encoder(codec_id); | 3688 | codec = avcodec_find_encoder(codec_id); |
| 3693 | } | 3689 | } |
| 3694 | } | 3690 | } |
| 3695 | 3691 | ost = new_output_stream(oc, file_idx, codec); | |
| 3696 | avcodec_get_context_defaults3(st->codec, codec); | 3692 | st = ost->st; |
| 3697 | 3693 | ||
| 3698 | ost->bitstream_filters = audio_bitstream_filters; | 3694 | ost->bitstream_filters = audio_bitstream_filters; |
| 3699 | audio_bitstream_filters= NULL; | 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 | if (audio_channels) | 3719 | if (audio_channels) |
| 3724 | audio_enc->channels = audio_channels; | 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 | if (audio_sample_rate) | 3723 | if (audio_sample_rate) |
| 3727 | audio_enc->sample_rate = audio_sample_rate; | 3724 | audio_enc->sample_rate = audio_sample_rate; |
| 3728 | audio_enc->channel_layout = channel_layout; | ||
| 3729 | choose_sample_fmt(st, codec); | ||
| 3730 | } | 3725 | } |
| 3731 | if (audio_language) { | 3726 | if (audio_language) { |
| 3732 | av_dict_set(&st->metadata, "language", audio_language, 0); | 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 | static void new_data_stream(AVFormatContext *oc, int file_idx) | 3737 | static void new_data_stream(AVFormatContext *oc, int file_idx) |
| 3743 | { | 3738 | { |
| 3744 | AVStream *st; | 3739 | AVStream *st; |
| 3745 | AVCodec *codec=NULL; | 3740 | OutputStream *ost; |
| 3746 | AVCodecContext *data_enc; | 3741 | AVCodecContext *data_enc; |
| 3747 | 3742 | ||
| 3748 | st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); | 3743 | ost = new_output_stream(oc, file_idx, NULL); |
| 3749 | if (!st) { | 3744 | st = ost->st; |
| 3750 | fprintf(stderr, "Could not alloc stream\n"); | ||
| 3751 | ffmpeg_exit(1); | ||
| 3752 | } | ||
| 3753 | new_output_stream(oc, file_idx); | ||
| 3754 | data_enc = st->codec; | 3745 | data_enc = st->codec; |
| 3755 | if (!data_stream_copy) { | 3746 | if (!data_stream_copy) { |
| 3756 | fprintf(stderr, "Data stream encoding not supported yet (only streamcopy)\n"); | 3747 | fprintf(stderr, "Data stream encoding not supported yet (only streamcopy)\n"); |
| 3757 | ffmpeg_exit(1); | 3748 | ffmpeg_exit(1); |
| 3758 | } | 3749 | } |
| 3759 | avcodec_get_context_defaults3(st->codec, codec); | ||
| 3760 | 3750 | ||
| 3761 | data_enc->codec_type = AVMEDIA_TYPE_DATA; | 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 | AVCodecContext *subtitle_enc; | 3774 | AVCodecContext *subtitle_enc; |
| 3785 | enum CodecID codec_id = CODEC_ID_NONE; | 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 | if(!subtitle_stream_copy){ | 3777 | if(!subtitle_stream_copy){ |
| 3795 | if (subtitle_codec_name) { | 3778 | if (subtitle_codec_name) { |
| 3796 | codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, | 3779 | codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, |
| 3797 | avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); | 3780 | avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); |
| 3798 | codec = avcodec_find_encoder_by_name(subtitle_codec_name); | 3781 | codec = avcodec_find_encoder_by_name(subtitle_codec_name); |
| 3799 | ost->enc = codec; | ||
| 3800 | } else { | 3782 | } else { |
| 3801 | codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE); | 3783 | codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE); |
| 3802 | codec = avcodec_find_encoder(codec_id); | 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 | ost->bitstream_filters = subtitle_bitstream_filters; | 3791 | ost->bitstream_filters = subtitle_bitstream_filters; |
| 3808 | subtitle_bitstream_filters= NULL; | 3792 | subtitle_bitstream_filters= NULL; |
| @@ -3938,8 +3922,6 @@ static int opt_output_file(const char *opt, const char *filename) · 129 unmodified lines | |||
| 3938 | if (use_subtitle) new_subtitle_stream(oc, nb_output_files); | 3922 | if (use_subtitle) new_subtitle_stream(oc, nb_output_files); |
| 3939 | if (use_data) new_data_stream(oc, nb_output_files); | 3923 | if (use_data) new_data_stream(oc, nb_output_files); |
| 3940 | 3924 | ||
| 3941 | oc->timestamp = recording_timestamp; | ||
| 3942 | |||
| 3943 | av_dict_copy(&oc->metadata, metadata, 0); | 3925 | av_dict_copy(&oc->metadata, metadata, 0); |
| 3944 | av_dict_free(&metadata); | 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 | frame_height = 0; | 3987 | frame_height = 0; |
| 4006 | audio_sample_rate = 0; | 3988 | audio_sample_rate = 0; |
| 4007 | audio_channels = 0; | 3989 | audio_channels = 0; |
| 3990 | audio_sample_fmt = AV_SAMPLE_FMT_NONE; | ||
| 4008 | 3991 | ||
| 4009 | av_freep(&forced_key_frames); | 3992 | av_freep(&forced_key_frames); |
| 4010 | uninit_opts(); | 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 | static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt) | 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 | if (packet_queue_get(&is->videoq, pkt, 1) < 0) | 1436 | if (packet_queue_get(&is->videoq, pkt, 1) < 0) |
| 1437 | return -1; | 1437 | return -1; |
| @@ -1458,9 +1458,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke · 20 unmodified lines | |||
| 1458 | return 0; | 1458 | return 0; |
| 1459 | } | 1459 | } |
| 1460 | 1460 | ||
| 1461 | len1 = avcodec_decode_video2(is->video_st->codec, | 1461 | avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt); |
| 1462 | frame, &got_picture, | ||
| 1463 | pkt); | ||
| 1464 | 1462 | ||
| 1465 | if (got_picture) { | 1463 | if (got_picture) { |
| 1466 | if (decoder_reorder_pts == -1) { | 1464 | if (decoder_reorder_pts == -1) { |
| @@ -1807,7 +1805,7 @@ static int subtitle_thread(void *arg) · 340 unmodified lines | |||
| 1807 | VideoState *is = arg; | 1805 | VideoState *is = arg; |
| 1808 | SubPicture *sp; | 1806 | SubPicture *sp; |
| 1809 | AVPacket pkt1, *pkt = &pkt1; | 1807 | AVPacket pkt1, *pkt = &pkt1; |
| 1810 | int len1 av_unused, got_subtitle; | 1808 | int got_subtitle; |
| 1811 | double pts; | 1809 | double pts; |
| 1812 | int i, j; | 1810 | int i, j; |
| 1813 | int r, g, b, y, u, v, a; | 1811 | int r, g, b, y, u, v, a; |
| @@ -1841,9 +1839,9 @@ static int subtitle_thread(void *arg) · 27 unmodified lines | |||
| 1841 | if (pkt->pts != AV_NOPTS_VALUE) | 1839 | if (pkt->pts != AV_NOPTS_VALUE) |
| 1842 | pts = av_q2d(is->subtitle_st->time_base)*pkt->pts; | 1840 | pts = av_q2d(is->subtitle_st->time_base)*pkt->pts; |
| 1843 | 1841 | ||
| 1844 | len1 = avcodec_decode_subtitle2(is->subtitle_st->codec, | 1842 | avcodec_decode_subtitle2(is->subtitle_st->codec, &sp->sub, |
| 1845 | &sp->sub, &got_subtitle, | 1843 | &got_subtitle, pkt); |
| 1846 | pkt); | 1844 | |
| 1847 | if (got_subtitle && sp->sub.format == 0) { | 1845 | if (got_subtitle && sp->sub.format == 0) { |
| 1848 | sp->pts = pts; | 1846 | sp->pts = pts; |
| 1849 | 1847 | ||
| @@ -28,6 +28,7 @@ · 27 unmodified lines | |||
| 28 | #include "avcodec.h" | 28 | #include "avcodec.h" |
| 29 | #include "dsputil.h" | 29 | #include "dsputil.h" |
| 30 | #include "mpegvideo.h" | 30 | #include "mpegvideo.h" |
| 31 | #include "mpegvideo_common.h" | ||
| 31 | #include "dnxhdenc.h" | 32 | #include "dnxhdenc.h" |
| 32 | 33 | ||
| 33 | #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM | 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 | static const AVClass class = { "dnxhd", av_default_item_name, options, LIBAVUTIL_VERSION_INT }; | 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 | #define LAMBDA_FRAC_BITS 10 | 42 | #define LAMBDA_FRAC_BITS 10 |
| 44 | 43 | ||
| 45 | static av_always_inline void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, int line_size) | 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 | return h->pps.chroma_qp_table[t][qscale]; | 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 | static void fill_decode_neighbors(H264Context *h, int mb_type){ | 773 | static void fill_decode_neighbors(H264Context *h, int mb_type){ |
| 776 | MpegEncContext * const s = &h->s; | 774 | MpegEncContext * const s = &h->s; |
| 777 | const int mb_xy= h->mb_xy; | 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 | return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8|MB_TYPE_DIRECT2)*0x0001000100010001ULL)); | 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 | #endif /* AVCODEC_H264_H */ | 1303 | #endif /* AVCODEC_H264_H */ |
| @@ -327,4 +327,43 @@ zeromv: · 326 unmodified lines | |||
| 327 | return; | 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 | #endif /* AVCODEC_H264_MVPRED_H */ | 369 | #endif /* AVCODEC_H264_MVPRED_H */ |
| @@ -698,7 +698,12 @@ typedef struct AVFormatContext { · 697 unmodified lines | |||
| 698 | AVStream **streams; | 698 | AVStream **streams; |
| 699 | char filename[1024]; /**< input or output filename */ | 699 | char filename[1024]; /**< input or output filename */ |
| 700 | /* stream info */ | 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 | int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ | 708 | int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ |
| 704 | /* private data for pts handling (do not modify directly). */ | 709 | /* private data for pts handling (do not modify directly). */ |
| @@ -43,7 +43,7 @@ struct DVMuxContext { · 42 unmodified lines | |||
| 43 | AVStream *ast[2]; /* stereo audio streams */ | 43 | AVStream *ast[2]; /* stereo audio streams */ |
| 44 | AVFifoBuffer *audio_data[2]; /* FIFO for storing excessive amounts of PCM */ | 44 | AVFifoBuffer *audio_data[2]; /* FIFO for storing excessive amounts of PCM */ |
| 45 | int frames; /* current frame number */ | 45 | int frames; /* current frame number */ |
| 46 | time_t start_time; /* recording start time */ | 46 | int64_t start_time; /* recording start time */ |
| 47 | int has_audio; /* frame under contruction has audio */ | 47 | int has_audio; /* frame under contruction has audio */ |
| 48 | int has_video; /* frame under contruction has video */ | 48 | int has_video; /* frame under contruction has video */ |
| 49 | uint8_t frame_buf[DV_MAX_FRAME_SIZE]; /* frame under contruction */ | 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 | DVMuxContext *c = s->priv_data; | 291 | DVMuxContext *c = s->priv_data; |
| 292 | AVStream *vst = NULL; | 292 | AVStream *vst = NULL; |
| 293 | AVDictionaryEntry *t; | ||
| 293 | int i; | 294 | int i; |
| 294 | 295 | ||
| 295 | /* we support at most 1 video and 2 audio streams */ | 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 | c->frames = 0; | 338 | c->frames = 0; |
| 338 | c->has_audio = 0; | 339 | c->has_audio = 0; |
| 339 | c->has_video = 0; | 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 | for (i=0; i < c->n_ast; i++) { | 352 | for (i=0; i < c->n_ast; i++) { |
| 343 | if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc(100*AVCODEC_MAX_AUDIO_FRAME_SIZE))) { | 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 | GXFContext *gxf = s->priv_data; | 394 | GXFContext *gxf = s->priv_data; |
| 395 | AVIOContext *pb = s->pb; | 395 | AVIOContext *pb = s->pb; |
| 396 | int timecode_base = gxf->time_base.den == 60000 ? 60 : 50; | 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 | // XXX drop frame | 412 | // XXX drop frame |
| 399 | uint32_t timecode = | 413 | uint32_t timecode = |
| @@ -409,8 +423,8 @@ static int gxf_write_umf_material_description(AVFormatContext *s) · 9 unmodified lines | |||
| 409 | avio_wl32(pb, gxf->nb_fields); /* mark out */ | 423 | avio_wl32(pb, gxf->nb_fields); /* mark out */ |
| 410 | avio_wl32(pb, 0); /* timecode mark in */ | 424 | avio_wl32(pb, 0); /* timecode mark in */ |
| 411 | avio_wl32(pb, timecode); /* timecode mark out */ | 425 | avio_wl32(pb, timecode); /* timecode mark out */ |
| 412 | avio_wl64(pb, s->timestamp); /* modification time */ | 426 | avio_wl64(pb, timestamp); /* modification time */ |
| 413 | avio_wl64(pb, s->timestamp); /* creation time */ | 427 | avio_wl64(pb, timestamp); /* creation time */ |
| 414 | avio_wl16(pb, 0); /* reserved */ | 428 | avio_wl16(pb, 0); /* reserved */ |
| 415 | avio_wl16(pb, 0); /* reserved */ | 429 | avio_wl16(pb, 0); /* reserved */ |
| 416 | avio_wl16(pb, gxf->audio_tracks); | 430 | avio_wl16(pb, gxf->audio_tracks); |
| @@ -1212,7 +1212,7 @@ AVOutputFormat ff_matroska_muxer = { · 1211 unmodified lines | |||
| 1212 | mkv_write_trailer, | 1212 | mkv_write_trailer, |
| 1213 | .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, | 1213 | .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, |
| 1214 | .codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0}, | 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 | #endif | 1217 | #endif |
| 1218 | 1218 | ||
| @@ -2142,6 +2142,7 @@ static int mov_write_header(AVFormatContext *s) · 2141 unmodified lines | |||
| 2142 | { | 2142 | { |
| 2143 | AVIOContext *pb = s->pb; | 2143 | AVIOContext *pb = s->pb; |
| 2144 | MOVMuxContext *mov = s->priv_data; | 2144 | MOVMuxContext *mov = s->priv_data; |
| 2145 | AVDictionaryEntry *t; | ||
| 2145 | int i, hint_track = 0; | 2146 | int i, hint_track = 0; |
| 2146 | 2147 | ||
| 2147 | if (!s->pb->seekable) { | 2148 | if (!s->pb->seekable) { |
| @@ -2272,7 +2273,18 @@ static int mov_write_header(AVFormatContext *s) · 124 unmodified lines | |||
| 2272 | } | 2273 | } |
| 2273 | 2274 | ||
| 2274 | mov_write_mdat_tag(pb, mov); | 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 | if (mov->chapter_track) | 2289 | if (mov->chapter_track) |
| 2278 | mov_create_chapter_track(s, mov->chapter_track); | 2290 | mov_create_chapter_track(s, mov->chapter_track); |
| @@ -1407,6 +1407,8 @@ static int mxf_write_header(AVFormatContext *s) · 1406 unmodified lines | |||
| 1407 | int i; | 1407 | int i; |
| 1408 | uint8_t present[FF_ARRAY_ELEMS(mxf_essence_container_uls)] = {0}; | 1408 | uint8_t present[FF_ARRAY_ELEMS(mxf_essence_container_uls)] = {0}; |
| 1409 | const int *samples_per_frame = NULL; | 1409 | const int *samples_per_frame = NULL; |
| 1410 | AVDictionaryEntry *t; | ||
| 1411 | int64_t timestamp = 0; | ||
| 1410 | 1412 | ||
| 1411 | if (!s->nb_streams) | 1413 | if (!s->nb_streams) |
| 1412 | return -1; | 1414 | return -1; |
| @@ -1512,8 +1514,18 @@ static int mxf_write_header(AVFormatContext *s) · 99 unmodified lines | |||
| 1512 | sc->order = AV_RB32(sc->track_essence_element_key+12); | 1514 | sc->order = AV_RB32(sc->track_essence_element_key+12); |
| 1513 | } | 1515 | } |
| 1514 | 1516 | ||
| 1517 | #if FF_API_TIMESTAMP | ||
| 1515 | if (s->timestamp) | 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 | mxf->duration = -1; | 1529 | mxf->duration = -1; |
| 1518 | 1530 | ||
| 1519 | mxf->timecode_track = av_mallocz(sizeof(*mxf->timecode_track)); | 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 | int64_t *pos_arg, int64_t pos_limit) | 605 | int64_t *pos_arg, int64_t pos_limit) |
| 606 | { | 606 | { |
| 607 | struct ogg *ogg = s->priv_data; | 607 | struct ogg *ogg = s->priv_data; |
| 608 | struct ogg_stream *os = ogg->streams + stream_index; | ||
| 609 | AVIOContext *bc = s->pb; | 608 | AVIOContext *bc = s->pb; |
| 610 | int64_t pts = AV_NOPTS_VALUE; | 609 | int64_t pts = AV_NOPTS_VALUE; |
| 611 | int i; | 610 | int i = -1; |
| 612 | avio_seek(bc, *pos_arg, SEEK_SET); | 611 | avio_seek(bc, *pos_arg, SEEK_SET); |
| 613 | ogg_reset(ogg); | 612 | ogg_reset(ogg); |
| 614 | 613 | ||
| 615 | while (avio_tell(bc) < pos_limit && !ogg_packet(s, &i, NULL, NULL, pos_arg)) { | 614 | while (avio_tell(bc) < pos_limit && !ogg_packet(s, &i, NULL, NULL, pos_arg)) { |
| 616 | if (i == stream_index) { | 615 | if (i == stream_index) { |
| 616 | struct ogg_stream *os = ogg->streams + stream_index; | ||
| 617 | pts = ogg_calc_pts(s, i, NULL); | 617 | pts = ogg_calc_pts(s, i, NULL); |
| 618 | if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY)) | 618 | if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY)) |
| 619 | pts = AV_NOPTS_VALUE; | 619 | pts = AV_NOPTS_VALUE; |
| @@ -639,6 +639,7 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index, · 19 unmodified lines | |||
| 639 | os->keyframe_seek = 1; | 639 | os->keyframe_seek = 1; |
| 640 | 640 | ||
| 641 | ret = av_seek_frame_binary(s, stream_index, timestamp, flags); | 641 | ret = av_seek_frame_binary(s, stream_index, timestamp, flags); |
| 642 | os = ogg->streams + stream_index; | ||
| 642 | if (ret < 0) | 643 | if (ret < 0) |
| 643 | os->keyframe_seek = 0; | 644 | os->keyframe_seek = 0; |
| 644 | return ret; | 645 | return ret; |
| @@ -86,5 +86,8 @@ · 85 unmodified lines | |||
| 86 | #ifndef FF_API_LOOP_OUTPUT | 86 | #ifndef FF_API_LOOP_OUTPUT |
| 87 | #define FF_API_LOOP_OUTPUT (LIBAVFORMAT_VERSION_MAJOR < 54) | 87 | #define FF_API_LOOP_OUTPUT (LIBAVFORMAT_VERSION_MAJOR < 54) |
| 88 | #endif | 88 | #endif |
| 89 | #ifndef FF_API_TIMESTAMP | ||
| 90 | #define FF_API_TIMESTAMP (LIBAVFORMAT_VERSION_MAJOR < 54) | ||
| 91 | #endif | ||
| 89 | 92 | ||
| 90 | #endif /* AVFORMAT_VERSION_H */ | 93 | #endif /* AVFORMAT_VERSION_H */ |
| @@ -918,9 +918,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { · 917 unmodified lines | |||
| 918 | .log2_chroma_w= 0, | 918 | .log2_chroma_w= 0, |
| 919 | .log2_chroma_h= 0, | 919 | .log2_chroma_h= 0, |
| 920 | .comp = { | 920 | .comp = { |
| 921 | {0,1,1,0,9}, /* Y */ | 921 | {0,1,1,0,8}, /* Y */ |
| 922 | {1,1,1,0,9}, /* U */ | 922 | {1,1,1,0,8}, /* U */ |
| 923 | {2,1,1,0,9}, /* V */ | 923 | {2,1,1,0,8}, /* V */ |
| 924 | }, | 924 | }, |
| 925 | .flags = PIX_FMT_BE, | 925 | .flags = PIX_FMT_BE, |
| 926 | }, | 926 | }, |