History

Merge remote-tracking branch 'qatar/master'

* qatar/master: (58 commits) amrnbdec: check frame size before decoding. cscd: use negative error values to indicate decode_init() failures. h264: prevent overreads in intra PCM decoding. FATE: do not decode audio in the nuv test. dxa: set audio stream time base using the sample rate psx-str: do not allow seeking by bytes asfdec: Do not set AVCodecContext.frame_size vqf: set packet parameters after av_new_packet() mpegaudiodec: use DSPUtil.butterflies_float(). FATE: add mp3 test for sample that exhibited false overreads fate: add cdxl test for bit line plane arrangement vmnc: return error on decode_init() failure. libvorbis: add/update error messages libvorbis: use AVFifoBuffer for output packet buffer libvorbis: remove unneeded e_o_s check libvorbis: check return values for functions that can return errors libvorbis: use float input instead of s16 libvorbis: do not flush libvorbis analysis if dsp state was not initialized libvorbis: use VBR by default, with default quality of 3 libvorbis: fix use of minrate/maxrate AVOptions ... Conflicts: Changelog doc/APIchanges libavcodec/avcodec.h libavcodec/dpxenc.c libavcodec/libvorbis.c libavcodec/vmnc.c libavformat/asfdec.c libavformat/id3v2enc.c libavformat/internal.h libavformat/mp3enc.c libavformat/utils.c libavformat/version.h libswscale/utils.c tests/fate/video.mak tests/ref/fate/nuv tests/ref/fate/prores-alpha tests/ref/lavf/ffm tests/ref/vsynth1/prores tests/ref/vsynth2/prores

Michael Niedermayer committed 14 years ago

Commit 79ae0842 parents a77c8ad 882abda64 files · +1217 −519Browse files

Unified · Split

64 files
  1. Changelog +1 −0
  2. doc/APIchanges +8 −0
  3. doc/muxers.texi +34 −0
  4. libavcodec/aacdec.c +84 −70
  5. libavcodec/ac3enc.c +22 −6
  6. libavcodec/ac3enc_fixed.c +1 −0
  7. libavcodec/ac3enc_float.c +1 −0
  8. libavcodec/ac3enc_opts_template.c +6 −0
  9. libavcodec/amrnbdec.c +8 −0
  10. libavcodec/avcodec.h +20 −14
  11. libavcodec/cscd.c +2 −2
  12. libavcodec/dpxenc.c +1 −2
  13. libavcodec/eac3enc.c +1 −0
  14. libavcodec/flvenc.c +3 −0
  15. libavcodec/h261enc.c +3 −0
  16. libavcodec/h263.h +1 −1
  17. libavcodec/h264_cabac.c +2 −0
  18. libavcodec/libvorbis.c +170 −138
  19. libavcodec/mpeg12enc.c +2 −0
  20. libavcodec/mpeg4videoenc.c +2 −1
  21. libavcodec/mpegaudiodec.c +7 −0
  22. libavcodec/mpegvideo.h +35 −0
  23. libavcodec/mpegvideo_enc.c +56 −17
  24. libavcodec/options.c +21 −7
  25. libavcodec/proresdec_lgpl.c +32 −13
  26. libavcodec/proresenc_kostya.c +35 −22
  27. libavcodec/qtrle.c +1 −1
  28. libavcodec/rpza.c +4 −0
  29. libavcodec/rv10enc.c +3 −0
  30. libavcodec/rv20enc.c +3 −0
  31. libavcodec/version.h +9 −0
  32. libavcodec/vmnc.c +1 −1
  33. libavcodec/vp5.c +5 −0
  34. libavcodec/vp6.c +5 −1
  35. libavformat/asfdec.c +5 −21
  36. libavformat/avformat.h +16 −0
  37. libavformat/dxa.c +2 −0
  38. libavformat/ffmdec.c +0 −2
  39. libavformat/ffmenc.c +0 −2
  40. libavformat/id3v2.c +147 −6
  41. libavformat/id3v2.h +49 −8
  42. libavformat/id3v2enc.c +145 −47
  43. libavformat/internal.h +5 −0
  44. libavformat/matroska.h +1 −5
  45. libavformat/mov.c +4 −3
  46. libavformat/mp3enc.c +183 −74
  47. libavformat/omadec.c +1 −1
  48. libavformat/omaenc.c +1 −1
  49. libavformat/psxstr.c +1 −0
  50. libavformat/rtpenc.c +1 −1
  51. libavformat/swfdec.c +0 −2
  52. libavformat/utils.c +36 −19
  53. libavformat/version.h +1 −1
  54. libavformat/vqf.c +3 −3
  55. libswscale/utils.c +1 −1
  56. tests/codec-regression.sh +3 −3
  57. tests/fate/cdxl.mak +3 −0
  58. tests/fate/mp3.mak +5 −0
  59. tests/fate/video.mak +1 −1
  60. tests/ref/fate/cdxl-bitline-ham6 +11 −0
  61. tests/ref/fate/nuv +0 −19
  62. tests/ref/lavf/ffm +1 −1
  63. tests/ref/vsynth1/prores_kostya +1 −1
  64. tests/ref/vsynth2/prores_kostya +1 −1
Changelog+1−0
@@ -8,6 +8,7 @@ version next: · 7 unmodified lines
88 - Apple ProRes encoder
99 - ffprobe -count_packets and -count_frames options
1010 - Sun Rasterfile Encoder
11+- ID3v2 attached pictures reading and writing
1112
1213
1314 version 0.10:
doc/APIchanges+8−0
@@ -13,6 +13,7 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+<<<<<<< HEAD
1617 2012-02-21 - xxxxxxx - lavc 54.4.100
1718 Add av_get_pcm_codec() function.
1819
@@ -35,6 +36,13 @@ API changes, most recent first: · 16 unmodified lines
3536 2012-01-24 - xxxxxxx - lavfi 2.60.100
3637 Add avfilter_graph_dump.
3738
39+||||||| merged common ancestors
40+=======
41+2012-xx-xx - xxxxxxx - lavf 54.2.0 - avformat.h
42+ Add AVStream.attached_pic and AV_DISPOSITION_ATTACHED_PIC,
43+ used for dealing with attached pictures/cover art.
44+
45+>>>>>>> qatar/master
3846 2012-02-25 - c9bca80 - lavu 51.24.0 - error.h
3947 Add AVERROR_UNKNOWN
4048
doc/muxers.texi+34−0
@@ -370,5 +370,39 @@ Wrap around segment index once it reaches @var{limit}. · 369 unmodified lines
370370 ffmpeg -i in.mkv -c copy -map 0 -f segment -list out.list out%03d.nut
371371 @end example
372372
373+@section mp3
374+
375+The MP3 muxer writes a raw MP3 stream with an ID3v2 header at the beginning and
376+optionally an ID3v1 tag at the end. ID3v2.3 and ID3v2.4 are supported, the
377+@code{id3v2_version} option controls which one is used. The legacy ID3v1 tag is
378+not written by default, but may be enabled with the @code{write_id3v1} option.
379+
380+For seekable output the muxer also writes a Xing frame at the beginning, which
381+contains the number of frames in the file. It is useful for computing duration
382+of VBR files.
383+
384+The muxer supports writing ID3v2 attached pictures (APIC frames). The pictures
385+are supplied to the muxer in form of a video stream with a single packet. There
386+can be any number of those streams, each will correspond to a single APIC frame.
387+The stream metadata tags @var{title} and @var{comment} map to APIC
388+@var{description} and @var{picture type} respectively. See
389+@url{http://id3.org/id3v2.4.0-frames} for allowed picture types.
390+
391+Note that the APIC frames must be written at the beginning, so the muxer will
392+buffer the audio frames until it gets all the pictures. It is therefore advised
393+to provide the pictures as soon as possible to avoid excessive buffering.
394+
395+Examples:
396+
397+Write an mp3 with an ID3v2.3 header and an ID3v1 footer:
398+@example
399+ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3
400+@end example
401+
402+Attach a picture to an mp3:
403+@example
404+ffmpeg -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover"
405+-metadata:s:v comment="Cover (Front)" out.mp3
406+@end example
373407
374408 @c man end MUXERS
libavcodec/aacdec.c+84−70
@@ -114,55 +114,6 @@ static VLC vlc_spectral[11]; · 113 unmodified lines
114114
115115 static const char overread_err[] = "Input buffer exhausted before END element found\n";
116116
117−static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
118−{
119− // For PCE based channel configurations map the channels solely based on tags.
120− if (!ac->m4ac.chan_config) {
121− return ac->tag_che_map[type][elem_id];
122− }
123− // For indexed channel configurations map the channels solely based on position.
124− switch (ac->m4ac.chan_config) {
125− case 7:
126− if (ac->tags_mapped == 3 && type == TYPE_CPE) {
127− ac->tags_mapped++;
128− return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
129− }
130− case 6:
131− /* Some streams incorrectly code 5.1 audio as SCE[0] CPE[0] CPE[1] SCE[1]
132− instead of SCE[0] CPE[0] CPE[1] LFE[0]. If we seem to have
133− encountered such a stream, transfer the LFE[0] element to the SCE[1]'s mapping */
134− if (ac->tags_mapped == tags_per_config[ac->m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) {
135− ac->tags_mapped++;
136− return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0];
137− }
138− case 5:
139− if (ac->tags_mapped == 2 && type == TYPE_CPE) {
140− ac->tags_mapped++;
141− return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1];
142− }
143− case 4:
144− if (ac->tags_mapped == 2 && ac->m4ac.chan_config == 4 && type == TYPE_SCE) {
145− ac->tags_mapped++;
146− return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
147− }
148− case 3:
149− case 2:
150− if (ac->tags_mapped == (ac->m4ac.chan_config != 2) && type == TYPE_CPE) {
151− ac->tags_mapped++;
152− return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0];
153− } else if (ac->m4ac.chan_config == 2) {
154− return NULL;
155− }
156− case 1:
157− if (!ac->tags_mapped && type == TYPE_SCE) {
158− ac->tags_mapped++;
159− return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0];
160− }
161− default:
162− return NULL;
163− }
164−}
165−
166117 static int count_channels(uint8_t (*layout)[3], int tags)
167118 {
168119 int i, sum = 0;
@@ -454,6 +405,90 @@ static void flush(AVCodecContext *avctx) · 285 unmodified lines
454405 }
455406 }
456407
408+/**
409+ * Set up channel positions based on a default channel configuration
410+ * as specified in table 1.17.
411+ *
412+ * @return Returns error status. 0 - OK, !0 - error
413+ */
414+static av_cold int set_default_channel_config(AVCodecContext *avctx,
415+ uint8_t (*layout_map)[3],
416+ int *tags,
417+ int channel_config)
418+{
419+ if (channel_config < 1 || channel_config > 7) {
420+ av_log(avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n",
421+ channel_config);
422+ return -1;
423+ }
424+ *tags = tags_per_config[channel_config];
425+ memcpy(layout_map, aac_channel_layout_map[channel_config-1], *tags * sizeof(*layout_map));
426+ return 0;
427+}
428+
429+static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
430+{
431+ // For PCE based channel configurations map the channels solely based on tags.
432+ if (!ac->m4ac.chan_config) {
433+ return ac->tag_che_map[type][elem_id];
434+ }
435+ // Allow single CPE stereo files to be signalled with mono configuration.
436+ if (!ac->tags_mapped && type == TYPE_CPE && ac->m4ac.chan_config == 1) {
437+ uint8_t layout_map[MAX_ELEM_ID*4][3];
438+ int layout_map_tags;
439+
440+ if (set_default_channel_config(ac->avctx, layout_map, &layout_map_tags,
441+ 2) < 0)
442+ return NULL;
443+ if (output_configure(ac, layout_map, layout_map_tags,
444+ 2, OC_TRIAL_FRAME) < 0)
445+ return NULL;
446+
447+ ac->m4ac.chan_config = 2;
448+ }
449+ // For indexed channel configurations map the channels solely based on position.
450+ switch (ac->m4ac.chan_config) {
451+ case 7:
452+ if (ac->tags_mapped == 3 && type == TYPE_CPE) {
453+ ac->tags_mapped++;
454+ return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
455+ }
456+ case 6:
457+ /* Some streams incorrectly code 5.1 audio as SCE[0] CPE[0] CPE[1] SCE[1]
458+ instead of SCE[0] CPE[0] CPE[1] LFE[0]. If we seem to have
459+ encountered such a stream, transfer the LFE[0] element to the SCE[1]'s mapping */
460+ if (ac->tags_mapped == tags_per_config[ac->m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) {
461+ ac->tags_mapped++;
462+ return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0];
463+ }
464+ case 5:
465+ if (ac->tags_mapped == 2 && type == TYPE_CPE) {
466+ ac->tags_mapped++;
467+ return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1];
468+ }
469+ case 4:
470+ if (ac->tags_mapped == 2 && ac->m4ac.chan_config == 4 && type == TYPE_SCE) {
471+ ac->tags_mapped++;
472+ return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
473+ }
474+ case 3:
475+ case 2:
476+ if (ac->tags_mapped == (ac->m4ac.chan_config != 2) && type == TYPE_CPE) {
477+ ac->tags_mapped++;
478+ return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0];
479+ } else if (ac->m4ac.chan_config == 2) {
480+ return NULL;
481+ }
482+ case 1:
483+ if (!ac->tags_mapped && type == TYPE_SCE) {
484+ ac->tags_mapped++;
485+ return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0];
486+ }
487+ default:
488+ return NULL;
489+ }
490+}
491+
457492 /**
458493 * Decode an array of 4 bit element IDs, optionally interleaved with a stereo/mono switching bit.
459494 *
@@ -550,27 +585,6 @@ static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac, · 90 unmodified lines
550585 return tags;
551586 }
552587
553−/**
554− * Set up channel positions based on a default channel configuration
555− * as specified in table 1.17.
556− *
557− * @return Returns error status. 0 - OK, !0 - error
558− */
559−static av_cold int set_default_channel_config(AVCodecContext *avctx,
560− uint8_t (*layout_map)[3],
561− int *tags,
562− int channel_config)
563−{
564− if (channel_config < 1 || channel_config > 7) {
565− av_log(avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n",
566− channel_config);
567− return -1;
568− }
569− *tags = tags_per_config[channel_config];
570− memcpy(layout_map, aac_channel_layout_map[channel_config-1], *tags * sizeof(*layout_map));
571− return 0;
572−}
573−
574588 /**
575589 * Decode GA "General Audio" specific configuration; reference: table 4.1.
576590 *
libavcodec/ac3enc.c+22−6
@@ -2138,6 +2138,17 @@ static av_cold int validate_options(AC3EncodeContext *s) · 2137 unmodified lines
21382138 s->bit_alloc.sr_code = i % 3;
21392139 s->bitstream_id = s->eac3 ? 16 : 8 + s->bit_alloc.sr_shift;
21402140
2141+ /* select a default bit rate if not set by the user */
2142+ if (!avctx->bit_rate) {
2143+ switch (s->fbw_channels) {
2144+ case 1: avctx->bit_rate = 96000; break;
2145+ case 2: avctx->bit_rate = 192000; break;
2146+ case 3: avctx->bit_rate = 320000; break;
2147+ case 4: avctx->bit_rate = 384000; break;
2148+ case 5: avctx->bit_rate = 448000; break;
2149+ }
2150+ }
2151+
21412152 /* validate bit rate */
21422153 if (s->eac3) {
21432154 int max_br, min_br, wpf, min_br_dist, min_br_code;
@@ -2186,15 +2197,20 @@ static av_cold int validate_options(AC3EncodeContext *s) · 42 unmodified lines
21862197 wpf--;
21872198 s->frame_size_min = 2 * wpf;
21882199 } else {
2200+ int best_br = 0, best_code = 0, best_diff = INT_MAX;
21892201 for (i = 0; i < 19; i++) {
2190− if ((ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate)
2202+ int br = (ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift) * 1000;
2203+ int diff = abs(br - avctx->bit_rate);
2204+ if (diff < best_diff) {
2205+ best_br = br;
2206+ best_code = i;
2207+ best_diff = diff;
2208+ }
2209+ if (!best_diff)
21912210 break;
21922211 }
2193− if (i == 19) {
2194− av_log(avctx, AV_LOG_ERROR, "invalid bit rate\n");
2195− return AVERROR(EINVAL);
2196− }
2197− s->frame_size_code = i << 1;
2212+ avctx->bit_rate = best_br;
2213+ s->frame_size_code = best_code << 1;
21982214 s->frame_size_min = 2 * ff_ac3_frame_size_tab[s->frame_size_code][s->bit_alloc.sr_code];
21992215 s->num_blks_code = 0x3;
22002216 s->num_blocks = 6;
libavcodec/ac3enc_fixed.c+1−0
@@ -157,4 +157,5 @@ AVCodec ff_ac3_fixed_encoder = { · 156 unmodified lines
157157 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
158158 .priv_class = &ac3enc_class,
159159 .channel_layouts = ff_ac3_channel_layouts,
160+ .defaults = ac3_defaults,
160161 };
libavcodec/ac3enc_float.c+1−0
@@ -155,5 +155,6 @@ AVCodec ff_ac3_encoder = { · 154 unmodified lines
155155 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
156156 .priv_class = &ac3enc_class,
157157 .channel_layouts = ff_ac3_channel_layouts,
158+ .defaults = ac3_defaults,
158159 };
159160 #endif
libavcodec/ac3enc_opts_template.c+6−0
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 */
2121
2222 #include "libavutil/opt.h"
23+#include "internal.h"
2324 #include "ac3.h"
2425
2526 #if AC3ENC_TYPE == AC3ENC_TYPE_AC3_FIXED
@@ -78,3 +79,8 @@ static const AVOption eac3_options[] = { · 52 unmodified lines
7879 {"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "cpl_start_band"},
7980 {NULL}
8081 };
82+
83+static const AVCodecDefault ac3_defaults[] = {
84+ { "b", "0" },
85+ { NULL }
86+};
libavcodec/amrnbdec.c+8−0
@@ -200,6 +200,10 @@ static enum Mode unpack_bitstream(AMRContext *p, const uint8_t *buf, · 199 unmodified lines
200200 p->bad_frame_indicator = !get_bits1(&gb); // quality bit
201201 skip_bits(&gb, 2); // two padding bits
202202
203+ if (mode >= N_MODES || buf_size < frame_sizes_nb[mode] + 1) {
204+ return NO_DATA;
205+ }
206+
203207 if (mode < MODE_DTX)
204208 ff_amr_bit_reorder((uint16_t *) &p->frame, sizeof(AMRNBFrame), buf + 1,
205209 amr_unpacking_bitmaps_per_mode[mode]);
@@ -947,6 +951,10 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, · 741 unmodified lines
947951 buf_out = (float *)p->avframe.data[0];
948952
949953 p->cur_frame_mode = unpack_bitstream(p, buf, buf_size);
954+ if (p->cur_frame_mode == NO_DATA) {
955+ av_log(avctx, AV_LOG_ERROR, "Corrupt bitstream\n");
956+ return AVERROR_INVALIDDATA;
957+ }
950958 if (p->cur_frame_mode == MODE_DTX) {
951959 av_log_missing_feature(avctx, "dtx mode", 0);
952960 av_log(avctx, AV_LOG_INFO, "Note: libopencore_amrnb supports dtx\n");
libavcodec/avcodec.h+20−14
@@ -582,17 +582,19 @@ typedef struct RcOverride{ · 581 unmodified lines
582582 #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
583583 /* Fx : Flag for h263+ extra options */
584584 #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
585−#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
586−#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
587585 #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
588586 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
589587 #define CODEC_FLAG_CLOSED_GOP 0x80000000
590588 #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
591−#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
592589 #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
593590 #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
594591 #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. DEPRECATED!!!!
592+#if FF_API_MPV_GLOBAL_OPTS
593+#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
594+#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
595+#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
595596 #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
597+#endif
596598 #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
597599 #define CODEC_FLAG2_SHOW_ALL 0x00400000 ///< Show all frames before the first keyframe
598600
@@ -1492,19 +1494,21 @@ typedef struct AVCodecContext { · 893 unmodified lines
14921494
14931495 int b_frame_strategy;
14941496
1497+#if FF_API_MPV_GLOBAL_OPTS
14951498 /**
14961499 * luma single coefficient elimination threshold
14971500 * - encoding: Set by user.
14981501 * - decoding: unused
14991502 */
1500− int luma_elim_threshold;
1503+ attribute_deprecated int luma_elim_threshold;
15011504
15021505 /**
15031506 * chroma single coeff elimination threshold
15041507 * - encoding: Set by user.
15051508 * - decoding: unused
15061509 */
1507− int chroma_elim_threshold;
1510+ attribute_deprecated int chroma_elim_threshold;
1511+#endif
15081512
15091513 /**
15101514 * qscale offset between IP and B-frames
@@ -1735,13 +1739,15 @@ typedef struct AVCodecContext { · 224 unmodified lines
17351739 */
17361740 int inter_quant_bias;
17371741
1742+#if FF_API_COLOR_TABLE_ID
17381743 /**
17391744 * color table ID
17401745 * - encoding: unused
17411746 * - decoding: Which clrtable should be used for 8bit RGB images.
17421747 * Tables have to be stored somewhere. FIXME
17431748 */
1744− int color_table_id;
1749+ attribute_deprecated int color_table_id;
1750+#endif
17451751
17461752 /**
17471753 * slice flags
@@ -1799,19 +1805,19 @@ typedef struct AVCodecContext { · 51 unmodified lines
17991805 */
18001806 int noise_reduction;
18011807
1808+#if FF_API_INTER_THRESHOLD
18021809 /**
1803− *
1804− * - encoding: Set by user.
1805− * - decoding: unused
1810+ * @deprecated this field is unused
18061811 */
1807− int inter_threshold;
1812+ attribute_deprecated int inter_threshold;
1813+#endif
18081814
1815+#if FF_API_MPV_GLOBAL_OPTS
18091816 /**
1810− * quantizer noise shaping
1811− * - encoding: Set by user.
1812− * - decoding: unused
1817+ * @deprecated use mpegvideo private options instead
18131818 */
1814− int quantizer_noise_shaping;
1819+ attribute_deprecated int quantizer_noise_shaping;
1820+#endif
18151821
18161822 /**
18171823 * Motion estimation threshold below which no motion estimation is
libavcodec/cscd.c+2−2
@@ -228,7 +228,7 @@ static av_cold int decode_init(AVCodecContext *avctx) { · 227 unmodified lines
228228 av_log(avctx, AV_LOG_ERROR,
229229 "CamStudio codec error: invalid depth %i bpp\n",
230230 avctx->bits_per_coded_sample);
231− return 1;
231+ return AVERROR_INVALIDDATA;
232232 }
233233 c->bpp = avctx->bits_per_coded_sample;
234234 avcodec_get_frame_defaults(&c->pic);
@@ -242,7 +242,7 @@ static av_cold int decode_init(AVCodecContext *avctx) { · 7 unmodified lines
242242 c->decomp_buf = av_malloc(c->decomp_size + AV_LZO_OUTPUT_PADDING);
243243 if (!c->decomp_buf) {
244244 av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
245− return 1;
245+ return AVERROR(ENOMEM);
246246 }
247247 return 0;
248248 }
libavcodec/dpxenc.c+1−2
@@ -131,9 +131,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 130 unmodified lines
131131 memcpy (buf + 8, "V1.0", 4);
132132 write32(buf + 20, 1); /* new image */
133133 write32(buf + 24, HEADER_SIZE);
134− if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
134+ if (!(avctx->flags & CODEC_FLAG_BITEXACT))
135135 memcpy (buf + 160, LIBAVCODEC_IDENT, FFMIN(sizeof(LIBAVCODEC_IDENT), 100));
136− }
137136 write32(buf + 660, 0xFFFFFFFF); /* unencrypted */
138137
139138 /* Image information header */
libavcodec/eac3enc.c+1−0
@@ -258,5 +258,6 @@ AVCodec ff_eac3_encoder = { · 257 unmodified lines
258258 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52 E-AC-3"),
259259 .priv_class = &eac3enc_class,
260260 .channel_layouts = ff_ac3_channel_layouts,
261+ .defaults = ac3_defaults,
261262 };
262263 #endif
libavcodec/flvenc.c+3−0
@@ -84,6 +84,8 @@ void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, in · 83 unmodified lines
8484 }
8585 }
8686
87+FF_MPV_GENERIC_CLASS(flv)
88+
8789 AVCodec ff_flv_encoder = {
8890 .name = "flv",
8991 .type = AVMEDIA_TYPE_VIDEO,
@@ -94,4 +96,5 @@ AVCodec ff_flv_encoder = { · 4 unmodified lines
9496 .close = ff_MPV_encode_end,
9597 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
9698 .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),
99+ .priv_class = &flv_class,
97100 };
libavcodec/h261enc.c+3−0
@@ -321,6 +321,8 @@ static void h261_encode_block(H261Context * h, DCTELEM * block, int n){ · 320 unmodified lines
321321 }
322322 }
323323
324+FF_MPV_GENERIC_CLASS(h261)
325+
324326 AVCodec ff_h261_encoder = {
325327 .name = "h261",
326328 .type = AVMEDIA_TYPE_VIDEO,
@@ -331,4 +333,5 @@ AVCodec ff_h261_encoder = { · 4 unmodified lines
331333 .close = ff_MPV_encode_end,
332334 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
333335 .long_name= NULL_IF_CONFIG_SMALL("H.261"),
336+ .priv_class = &h261_class,
334337 };
libavcodec/h263.h+1−1
@@ -148,7 +148,7 @@ static inline int get_p_cbp(MpegEncContext * s, · 147 unmodified lines
148148 int motion_x, int motion_y){
149149 int cbp, i;
150150
151− if(s->flags & CODEC_FLAG_CBP_RD){
151+ if (s->mpv_flags & FF_MPV_FLAG_CBP_RD) {
152152 int best_cbpy_score= INT_MAX;
153153 int best_cbpc_score= INT_MAX;
154154 int cbpc = (-1), cbpy= (-1);
libavcodec/h264_cabac.c+2−0
@@ -1998,6 +1998,8 @@ decode_intra_mb: · 1997 unmodified lines
19981998 }
19991999
20002000 // The pixels are stored in the same order as levels in h->mb array.
2001+ if ((int) (h->cabac.bytestream_end - ptr) < mb_size)
2002+ return -1;
20012003 memcpy(h->mb, ptr, mb_size); ptr+=mb_size;
20022004
20032005 ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
libavcodec/libvorbis.c+170−138
@@ -20,12 +20,13 @@ · 19 unmodified lines
2020
2121 /**
2222 * @file
23− * Ogg Vorbis codec support via libvorbisenc.
23+ * Vorbis encoding support via libvorbisenc.
2424 * @author Mark Hills <mark@pogo.org.uk>
2525 */
2626
2727 #include <vorbis/vorbisenc.h>
2828
29+#include "libavutil/fifo.h"
2930 #include "libavutil/opt.h"
3031 #include "avcodec.h"
3132 #include "bytestream.h"
@@ -35,32 +36,41 @@ · 3 unmodified lines
3536 #undef NDEBUG
3637 #include <assert.h>
3738
39+/* Number of samples the user should send in each call.
40+ * This value is used because it is the LCD of all possible frame sizes, so
41+ * an output packet will always start at the same point as one of the input
42+ * packets.
43+ */
3844 #define OGGVORBIS_FRAME_SIZE 64
3945
4046 #define BUFFER_SIZE (1024 * 64)
4147
4248 typedef struct OggVorbisContext {
43− AVClass *av_class;
44− vorbis_info vi;
45− vorbis_dsp_state vd;
46− vorbis_block vb;
47− uint8_t buffer[BUFFER_SIZE];
48− int buffer_index;
49− int eof;
50−
51− /* decoder */
52− vorbis_comment vc;
53− ogg_packet op;
54−
55− double iblock;
49+ AVClass *av_class; /**< class for AVOptions */
50+ vorbis_info vi; /**< vorbis_info used during init */
51+ vorbis_dsp_state vd; /**< DSP state used for analysis */
52+ vorbis_block vb; /**< vorbis_block used for analysis */
53+ AVFifoBuffer *pkt_fifo; /**< output packet buffer */
54+ int eof; /**< end-of-file flag */
55+ int dsp_initialized; /**< vd has been initialized */
56+ vorbis_comment vc; /**< VorbisComment info */
57+ ogg_packet op; /**< ogg packet */
58+ double iblock; /**< impulse block bias option */
5659 } OggVorbisContext;
5760
5861 static const AVOption options[] = {
5962 { "iblock", "Sets the impulse block bias", offsetof(OggVorbisContext, iblock), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -15, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
6063 { NULL }
6164 };
65+
66+static const AVCodecDefault defaults[] = {
67+ { "b", "0" },
68+ { NULL },
69+};
70+
6271 static const AVClass class = { "libvorbis", av_default_item_name, options, LIBAVUTIL_VERSION_INT };
6372
73+
6474 static int vorbis_error_to_averror(int ov_err)
6575 {
6676 switch (ov_err) {
@@ -71,27 +81,34 @@ static int vorbis_error_to_averror(int ov_err) · 4 unmodified lines
7181 }
7282 }
7383
74−static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext)
84+static av_cold int oggvorbis_init_encoder(vorbis_info *vi,
85+ AVCodecContext *avctx)
7586 {
76− OggVorbisContext *context = avccontext->priv_data;
87+ OggVorbisContext *s = avctx->priv_data;
7788 double cfreq;
7889 int ret;
7990
80− if (avccontext->flags & CODEC_FLAG_QSCALE) {
81− /* variable bitrate */
82− float q = avccontext->global_quality / (float)FF_QP2LAMBDA;
83− if ((ret = vorbis_encode_setup_vbr(vi, avccontext->channels,
84− avccontext->sample_rate,
91+ if (avctx->flags & CODEC_FLAG_QSCALE || !avctx->bit_rate) {
92+ /* variable bitrate
93+ * NOTE: we use the oggenc range of -1 to 10 for global_quality for
94+ * user convenience, but libvorbis uses -0.1 to 1.0.
95+ */
96+ float q = avctx->global_quality / (float)FF_QP2LAMBDA;
97+ /* default to 3 if the user did not set quality or bitrate */
98+ if (!(avctx->flags & CODEC_FLAG_QSCALE))
99+ q = 3.0;
100+ if ((ret = vorbis_encode_setup_vbr(vi, avctx->channels,
101+ avctx->sample_rate,
85102 q / 10.0)))
86103 goto error;
87104 } else {
88− int minrate = avccontext->rc_min_rate > 0 ? avccontext->rc_min_rate : -1;
89− int maxrate = avccontext->rc_min_rate > 0 ? avccontext->rc_max_rate : -1;
105+ int minrate = avctx->rc_min_rate > 0 ? avctx->rc_min_rate : -1;
106+ int maxrate = avctx->rc_max_rate > 0 ? avctx->rc_max_rate : -1;
90107
91− /* constant bitrate */
92− if ((ret = vorbis_encode_setup_managed(vi, avccontext->channels,
93− avccontext->sample_rate, minrate,
94− avccontext->bit_rate, maxrate)))
108+ /* average bitrate */
109+ if ((ret = vorbis_encode_setup_managed(vi, avctx->channels,
110+ avctx->sample_rate, maxrate,
111+ avctx->bit_rate, minrate)))
95112 goto error;
96113
97114 /* variable bitrate by estimate, disable slow rate management */
@@ -101,43 +118,44 @@ static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avcco · 3 unmodified lines
101118 }
102119
103120 /* cutoff frequency */
104− if (avccontext->cutoff > 0) {
105− cfreq = avccontext->cutoff / 1000.0;
121+ if (avctx->cutoff > 0) {
122+ cfreq = avctx->cutoff / 1000.0;
106123 if ((ret = vorbis_encode_ctl(vi, OV_ECTL_LOWPASS_SET, &cfreq)))
107124 goto error; /* should not happen */
108125 }
109126
110− if (context->iblock) {
111− if ((ret = vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock)))
127+ /* impulse block bias */
128+ if (s->iblock) {
129+ if ((ret = vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &s->iblock)))
112130 goto error;
113131 }
114132
115− if (avccontext->channels == 3 &&
116− avccontext->channel_layout != (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) ||
117− avccontext->channels == 4 &&
118− avccontext->channel_layout != AV_CH_LAYOUT_2_2 &&
119− avccontext->channel_layout != AV_CH_LAYOUT_QUAD ||
120− avccontext->channels == 5 &&
121− avccontext->channel_layout != AV_CH_LAYOUT_5POINT0 &&
122− avccontext->channel_layout != AV_CH_LAYOUT_5POINT0_BACK ||
123− avccontext->channels == 6 &&
124− avccontext->channel_layout != AV_CH_LAYOUT_5POINT1 &&
125− avccontext->channel_layout != AV_CH_LAYOUT_5POINT1_BACK ||
126− avccontext->channels == 7 &&
127− avccontext->channel_layout != (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) ||
128− avccontext->channels == 8 &&
129− avccontext->channel_layout != AV_CH_LAYOUT_7POINT1) {
130− if (avccontext->channel_layout) {
133+ if (avctx->channels == 3 &&
134+ avctx->channel_layout != (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) ||
135+ avctx->channels == 4 &&
136+ avctx->channel_layout != AV_CH_LAYOUT_2_2 &&
137+ avctx->channel_layout != AV_CH_LAYOUT_QUAD ||
138+ avctx->channels == 5 &&
139+ avctx->channel_layout != AV_CH_LAYOUT_5POINT0 &&
140+ avctx->channel_layout != AV_CH_LAYOUT_5POINT0_BACK ||
141+ avctx->channels == 6 &&
142+ avctx->channel_layout != AV_CH_LAYOUT_5POINT1 &&
143+ avctx->channel_layout != AV_CH_LAYOUT_5POINT1_BACK ||
144+ avctx->channels == 7 &&
145+ avctx->channel_layout != (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) ||
146+ avctx->channels == 8 &&
147+ avctx->channel_layout != AV_CH_LAYOUT_7POINT1) {
148+ if (avctx->channel_layout) {
131149 char name[32];
132− av_get_channel_layout_string(name, sizeof(name), avccontext->channels,
133− avccontext->channel_layout);
134− av_log(avccontext, AV_LOG_ERROR, "%s not supported by Vorbis: "
150+ av_get_channel_layout_string(name, sizeof(name), avctx->channels,
151+ avctx->channel_layout);
152+ av_log(avctx, AV_LOG_ERROR, "%s not supported by Vorbis: "
135153 "output stream will have incorrect "
136154 "channel layout.\n", name);
137155 } else {
138− av_log(avccontext, AV_LOG_WARNING, "No channel layout specified. The encoder "
156+ av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The encoder "
139157 "will use Vorbis channel layout for "
140− "%d channels.\n", avccontext->channels);
158+ "%d channels.\n", avctx->channels);
141159 }
142160 }
143161
@@ -155,59 +173,64 @@ static int xiph_len(int l) · 11 unmodified lines
155173 return 1 + l / 255 + l;
156174 }
157175
158−static av_cold int oggvorbis_encode_close(AVCodecContext *avccontext)
176+static av_cold int oggvorbis_encode_close(AVCodecContext *avctx)
159177 {
160− OggVorbisContext *context = avccontext->priv_data;
161−/* ogg_packet op ; */
178+ OggVorbisContext *s = avctx->priv_data;
162179
163− vorbis_analysis_wrote(&context->vd, 0); /* notify vorbisenc this is EOF */
180+ /* notify vorbisenc this is EOF */
181+ if (s->dsp_initialized)
182+ vorbis_analysis_wrote(&s->vd, 0);
164183
165− vorbis_block_clear(&context->vb);
166− vorbis_dsp_clear(&context->vd);
167− vorbis_info_clear(&context->vi);
184+ vorbis_block_clear(&s->vb);
185+ vorbis_dsp_clear(&s->vd);
186+ vorbis_info_clear(&s->vi);
168187
169− av_freep(&avccontext->coded_frame);
170− av_freep(&avccontext->extradata);
188+ av_fifo_free(s->pkt_fifo);
189+ av_freep(&avctx->coded_frame);
190+ av_freep(&avctx->extradata);
171191
172192 return 0;
173193 }
174194
175−static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext)
195+static av_cold int oggvorbis_encode_init(AVCodecContext *avctx)
176196 {
177− OggVorbisContext *context = avccontext->priv_data;
197+ OggVorbisContext *s = avctx->priv_data;
178198 ogg_packet header, header_comm, header_code;
179199 uint8_t *p;
180200 unsigned int offset;
181201 int ret;
182202
183− vorbis_info_init(&context->vi);
184− if ((ret = oggvorbis_init_encoder(&context->vi, avccontext))) {
185− av_log(avccontext, AV_LOG_ERROR, "oggvorbis_encode_init: init_encoder failed\n");
203+ vorbis_info_init(&s->vi);
204+ if ((ret = oggvorbis_init_encoder(&s->vi, avctx))) {
205+ av_log(avctx, AV_LOG_ERROR, "encoder setup failed\n");
186206 goto error;
187207 }
188− if ((ret = vorbis_analysis_init(&context->vd, &context->vi))) {
208+ if ((ret = vorbis_analysis_init(&s->vd, &s->vi))) {
209+ av_log(avctx, AV_LOG_ERROR, "analysis init failed\n");
189210 ret = vorbis_error_to_averror(ret);
190211 goto error;
191212 }
192− if ((ret = vorbis_block_init(&context->vd, &context->vb))) {
213+ s->dsp_initialized = 1;
214+ if ((ret = vorbis_block_init(&s->vd, &s->vb))) {
215+ av_log(avctx, AV_LOG_ERROR, "dsp init failed\n");
193216 ret = vorbis_error_to_averror(ret);
194217 goto error;
195218 }
196219
197− vorbis_comment_init(&context->vc);
198− vorbis_comment_add_tag(&context->vc, "encoder", LIBAVCODEC_IDENT);
220+ vorbis_comment_init(&s->vc);
221+ vorbis_comment_add_tag(&s->vc, "encoder", LIBAVCODEC_IDENT);
199222
200− if ((ret = vorbis_analysis_headerout(&context->vd, &context->vc, &header,
201− &header_comm, &header_code))) {
223+ if ((ret = vorbis_analysis_headerout(&s->vd, &s->vc, &header, &header_comm,
224+ &header_code))) {
202225 ret = vorbis_error_to_averror(ret);
203226 goto error;
204227 }
205228
206− avccontext->extradata_size =
207− 1 + xiph_len(header.bytes) + xiph_len(header_comm.bytes) +
208− header_code.bytes;
209− p = avccontext->extradata =
210− av_malloc(avccontext->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
229+ avctx->extradata_size = 1 + xiph_len(header.bytes) +
230+ xiph_len(header_comm.bytes) +
231+ header_code.bytes;
232+ p = avctx->extradata = av_malloc(avctx->extradata_size +
233+ FF_INPUT_BUFFER_PADDING_SIZE);
211234 if (!p) {
212235 ret = AVERROR(ENOMEM);
213236 goto error;
@@ -222,100 +245,107 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext) · 8 unmodified lines
222245 offset += header_comm.bytes;
223246 memcpy(&p[offset], header_code.packet, header_code.bytes);
224247 offset += header_code.bytes;
225− assert(offset == avccontext->extradata_size);
248+ assert(offset == avctx->extradata_size);
226249
227−#if 0
228− vorbis_block_clear(&context->vb);
229− vorbis_dsp_clear(&context->vd);
230− vorbis_info_clear(&context->vi);
231−#endif
232− vorbis_comment_clear(&context->vc);
250+ vorbis_comment_clear(&s->vc);
233251
234− avccontext->frame_size = OGGVORBIS_FRAME_SIZE;
252+ avctx->frame_size = OGGVORBIS_FRAME_SIZE;
253+
254+ s->pkt_fifo = av_fifo_alloc(BUFFER_SIZE);
255+ if (!s->pkt_fifo) {
256+ ret = AVERROR(ENOMEM);
257+ goto error;
258+ }
235259
236− avccontext->coded_frame = avcodec_alloc_frame();
237− if (!avccontext->coded_frame) {
260+ avctx->coded_frame = avcodec_alloc_frame();
261+ if (!avctx->coded_frame) {
238262 ret = AVERROR(ENOMEM);
239263 goto error;
240264 }
241265
242266 return 0;
243267 error:
244− oggvorbis_encode_close(avccontext);
268+ oggvorbis_encode_close(avctx);
245269 return ret;
246270 }
247271
248−static int oggvorbis_encode_frame(AVCodecContext *avccontext,
249− unsigned char *packets,
272+static int oggvorbis_encode_frame(AVCodecContext *avctx, unsigned char *packets,
250273 int buf_size, void *data)
251274 {
252− OggVorbisContext *context = avccontext->priv_data;
275+ OggVorbisContext *s = avctx->priv_data;
253276 ogg_packet op;
254− signed short *audio = data;
255− int l;
277+ float *audio = data;
278+ int pkt_size, ret;
256279
280+ /* send samples to libvorbis */
257281 if (data) {
258− const int samples = avccontext->frame_size;
282+ const int samples = avctx->frame_size;
259283 float **buffer;
260− int c, channels = context->vi.channels;
284+ int c, channels = s->vi.channels;
261285
262− buffer = vorbis_analysis_buffer(&context->vd, samples);
286+ buffer = vorbis_analysis_buffer(&s->vd, samples);
263287 for (c = 0; c < channels; c++) {
288+ int i;
264289 int co = (channels > 8) ? c :
265290 ff_vorbis_encoding_channel_layout_offsets[channels - 1][c];
266− for (l = 0; l < samples; l++)
267− buffer[c][l] = audio[l * channels + co] / 32768.f;
291+ for (i = 0; i < samples; i++)
292+ buffer[c][i] = audio[i * channels + co];
293+ }
294+ if ((ret = vorbis_analysis_wrote(&s->vd, samples)) < 0) {
295+ av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n");
296+ return vorbis_error_to_averror(ret);
268297 }
269− vorbis_analysis_wrote(&context->vd, samples);
270298 } else {
271− if (!context->eof)
272− vorbis_analysis_wrote(&context->vd, 0);
273− context->eof = 1;
299+ if (!s->eof)
300+ if ((ret = vorbis_analysis_wrote(&s->vd, 0)) < 0) {
301+ av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n");
302+ return vorbis_error_to_averror(ret);
303+ }
304+ s->eof = 1;
274305 }
275306
276− while (vorbis_analysis_blockout(&context->vd, &context->vb) == 1) {
277− vorbis_analysis(&context->vb, NULL);
278− vorbis_bitrate_addblock(&context->vb);
279−
280− while (vorbis_bitrate_flushpacket(&context->vd, &op)) {
281− /* i'd love to say the following line is a hack, but sadly it's
282− * not, apparently the end of stream decision is in libogg. */
283− if (op.bytes == 1 && op.e_o_s)
284− continue;
285− if (context->buffer_index + sizeof(ogg_packet) + op.bytes > BUFFER_SIZE) {
286− av_log(avccontext, AV_LOG_ERROR, "libvorbis: buffer overflow.\n");
287− return AVERROR(EINVAL);
307+ /* retrieve available packets from libvorbis */
308+ while ((ret = vorbis_analysis_blockout(&s->vd, &s->vb)) == 1) {
309+ if ((ret = vorbis_analysis(&s->vb, NULL)) < 0)
310+ break;
311+ if ((ret = vorbis_bitrate_addblock(&s->vb)) < 0)
312+ break;
313+
314+ /* add any available packets to the output packet buffer */
315+ while ((ret = vorbis_bitrate_flushpacket(&s->vd, &op)) == 1) {
316+ if (av_fifo_space(s->pkt_fifo) < sizeof(ogg_packet) + op.bytes) {
317+ av_log(avctx, AV_LOG_ERROR, "packet buffer is too small\n");
318+ return AVERROR_BUG;
288319 }
289− memcpy(context->buffer + context->buffer_index, &op, sizeof(ogg_packet));
290− context->buffer_index += sizeof(ogg_packet);
291− memcpy(context->buffer + context->buffer_index, op.packet, op.bytes);
292− context->buffer_index += op.bytes;
293−// av_log(avccontext, AV_LOG_DEBUG, "e%d / %d\n", context->buffer_index, op.bytes);
320+ av_fifo_generic_write(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);
321+ av_fifo_generic_write(s->pkt_fifo, op.packet, op.bytes, NULL);
322+ }
323+ if (ret < 0) {
324+ av_log(avctx, AV_LOG_ERROR, "error getting available packets\n");
325+ break;
294326 }
295327 }
328+ if (ret < 0) {
329+ av_log(avctx, AV_LOG_ERROR, "error getting available packets\n");
330+ return vorbis_error_to_averror(ret);
331+ }
296332
297− l = 0;
298− if (context->buffer_index) {
299− ogg_packet *op2 = (ogg_packet *)context->buffer;
300− op2->packet = context->buffer + sizeof(ogg_packet);
301−
302− l = op2->bytes;
303− avccontext->coded_frame->pts = ff_samples_to_time_base(avccontext,
304− op2->granulepos);
305− //FIXME we should reorder the user supplied pts and not assume that they are spaced by 1/sample_rate
306−
307− if (l > buf_size) {
308− av_log(avccontext, AV_LOG_ERROR, "libvorbis: buffer overflow.\n");
333+ /* output then next packet from the output buffer, if available */
334+ pkt_size = 0;
335+ if (av_fifo_size(s->pkt_fifo) >= sizeof(ogg_packet)) {
336+ av_fifo_generic_read(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);
337+ pkt_size = op.bytes;
338+ // FIXME: we should use the user-supplied pts and duration
339+ avctx->coded_frame->pts = ff_samples_to_time_base(avctx,
340+ op.granulepos);
341+ if (pkt_size > buf_size) {
342+ av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
309343 return AVERROR(EINVAL);
310344 }
311−
312− memcpy(packets, op2->packet, l);
313− context->buffer_index -= l + sizeof(ogg_packet);
314− memmove(context->buffer, context->buffer + l + sizeof(ogg_packet), context->buffer_index);
315−// av_log(avccontext, AV_LOG_DEBUG, "E%d\n", l);
345+ av_fifo_generic_read(s->pkt_fifo, packets, pkt_size, NULL);
316346 }
317347
318− return l;
348+ return pkt_size;
319349 }
320350
321351 AVCodec ff_libvorbis_encoder = {
@@ -327,7 +357,9 @@ AVCodec ff_libvorbis_encoder = { · 5 unmodified lines
327357 .encode = oggvorbis_encode_frame,
328358 .close = oggvorbis_encode_close,
329359 .capabilities = CODEC_CAP_DELAY,
330− .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE },
360+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
361+ AV_SAMPLE_FMT_NONE },
331362 .long_name = NULL_IF_CONFIG_SMALL("libvorbis Vorbis"),
332363 .priv_class = &class,
364+ .defaults = defaults,
333365 };
libavcodec/mpeg12enc.c+2−0
@@ -939,6 +939,7 @@ static void mpeg1_encode_block(MpegEncContext *s, · 938 unmodified lines
939939
940940 static const AVOption mpeg1_options[] = {
941941 COMMON_OPTS
942+ FF_MPV_COMMON_OPTS
942943 { NULL },
943944 };
944945
@@ -946,6 +947,7 @@ static const AVOption mpeg2_options[] = { · 1 unmodified line
946947 COMMON_OPTS
947948 { "non_linear_quant", "Use nonlinear quantizer.", OFFSET(q_scale_type), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
948949 { "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
950+ FF_MPV_COMMON_OPTS
949951 { NULL },
950952 };
951953
libavcodec/mpeg4videoenc.c+2−1
@@ -430,7 +430,7 @@ static inline int get_b_cbp(MpegEncContext * s, DCTELEM block[6][64], · 429 unmodified lines
430430 {
431431 int cbp = 0, i;
432432
433− if (s->flags & CODEC_FLAG_CBP_RD) {
433+ if (s->mpv_flags & FF_MPV_FLAG_CBP_RD) {
434434 int score = 0;
435435 const int lambda = s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
436436
@@ -1330,6 +1330,7 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext *s) · 893 unmodified lines
13301330 static const AVOption options[] = {
13311331 { "data_partitioning", "Use data partitioning.", OFFSET(data_partitioning), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
13321332 { "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
1333+ FF_MPV_COMMON_OPTS
13331334 { NULL },
13341335 };
13351336
libavcodec/mpegaudiodec.c+7−0
@@ -31,6 +31,7 @@ · 30 unmodified lines
3131 #include "get_bits.h"
3232 #include "mathops.h"
3333 #include "mpegaudiodsp.h"
34+#include "dsputil.h"
3435
3536 /*
3637 * TODO:
@@ -82,6 +83,7 @@ typedef struct MPADecodeContext { · 45 unmodified lines
8283 int err_recognition;
8384 AVCodecContext* avctx;
8485 MPADSPContext mpadsp;
86+ DSPContext dsp;
8587 AVFrame frame;
8688 } MPADecodeContext;
8789
@@ -434,6 +436,7 @@ static av_cold int decode_init(AVCodecContext * avctx) · 346 unmodified lines
434436 s->avctx = avctx;
435437
436438 ff_mpadsp_init(&s->mpadsp);
439+ ff_dsputil_init(&s->dsp, avctx);
437440
438441 avctx->sample_fmt= OUT_FMT;
439442 s->err_recognition = avctx->err_recognition;
@@ -1155,6 +1158,9 @@ found2: · 715 unmodified lines
11551158 /* ms stereo ONLY */
11561159 /* NOTE: the 1/sqrt(2) normalization factor is included in the
11571160 global gain */
1161+#if CONFIG_FLOAT
1162+ s-> dsp.butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576);
1163+#else
11581164 tab0 = g0->sb_hybrid;
11591165 tab1 = g1->sb_hybrid;
11601166 for (i = 0; i < 576; i++) {
@@ -1163,6 +1169,7 @@ found2: · 2 unmodified lines
11631169 tab0[i] = tmp0 + tmp1;
11641170 tab1[i] = tmp0 - tmp1;
11651171 }
1172+#endif
11661173 }
11671174 }
11681175
libavcodec/mpegvideo.h+35−0
@@ -38,6 +38,8 @@ · 37 unmodified lines
3838 #include "rl.h"
3939 #include "libavutil/timecode.h"
4040
41+#include "libavutil/opt.h"
42+
4143 #define FRAME_SKIPPED 100 ///< return value for header parsers if frame is not coded
4244
4345 enum OutputFormat {
@@ -695,6 +697,9 @@ typedef struct MpegEncContext { · 651 unmodified lines
695697 int (*dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
696698 int (*fast_dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
697699 void (*denoise_dct)(struct MpegEncContext *s, DCTELEM *block);
700+
701+ int mpv_flags; ///< flags set by private options
702+ int quantizer_noise_shaping;
698703 } MpegEncContext;
699704
700705 #define REBASE_PICTURE(pic, new_ctx, old_ctx) (pic ? \
@@ -702,6 +707,36 @@ typedef struct MpegEncContext { · 1 unmodified line
702707 &new_ctx->picture[pic - old_ctx->picture] : pic - (Picture*)old_ctx + (Picture*)new_ctx)\
703708 : NULL)
704709
710+/* mpegvideo_enc common options */
711+#define FF_MPV_FLAG_SKIP_RD 0x0001
712+#define FF_MPV_FLAG_STRICT_GOP 0x0002
713+#define FF_MPV_FLAG_QP_RD 0x0004
714+#define FF_MPV_FLAG_CBP_RD 0x0008
715+
716+#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x)
717+#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
718+#define FF_MPV_COMMON_OPTS \
719+{ "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\
720+{ "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
721+{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
722+{ "qp_rd", "Use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_QP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
723+{ "cbp_rd", "use rate distortion optimization for CBP", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_CBP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
724+{ "luma_elim_threshold", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)",\
725+ FF_MPV_OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, { 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\
726+{ "chroma_elim_threshold", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)",\
727+ FF_MPV_OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, { 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\
728+{ "quantizer_noise_shaping", NULL, FF_MPV_OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, { 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },
729+
730+extern const AVOption ff_mpv_generic_options[];
731+
732+#define FF_MPV_GENERIC_CLASS(name) \
733+static const AVClass name ## _class = {\
734+ .class_name = #name " encoder",\
735+ .item_name = av_default_item_name,\
736+ .option = ff_mpv_generic_options,\
737+ .version = LIBAVUTIL_VERSION_INT,\
738+};
739+
705740 void ff_MPV_decode_defaults(MpegEncContext *s);
706741 int ff_MPV_common_init(MpegEncContext *s);
707742 void ff_MPV_common_end(MpegEncContext *s);
libavcodec/mpegvideo_enc.c+56−17
@@ -63,6 +63,11 @@ static int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int · 62 unmodified lines
6363 static uint8_t default_mv_penalty[MAX_FCODE + 1][MAX_MV * 2 + 1];
6464 static uint8_t default_fcode_tab[MAX_MV * 2 + 1];
6565
66+const AVOption ff_mpv_generic_options[] = {
67+ FF_MPV_COMMON_OPTS
68+ { NULL },
69+};
70+
6671 void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64],
6772 uint16_t (*qmat16)[2][64],
6873 const uint16_t *quant_matrix,
@@ -352,8 +357,12 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) · 283 unmodified lines
352357 s->flags2 = avctx->flags2;
353358 s->max_b_frames = avctx->max_b_frames;
354359 s->codec_id = avctx->codec->id;
355− s->luma_elim_threshold = avctx->luma_elim_threshold;
356− s->chroma_elim_threshold = avctx->chroma_elim_threshold;
360+#if FF_API_MPV_GLOBAL_OPTS
361+ if (avctx->luma_elim_threshold)
362+ s->luma_elim_threshold = avctx->luma_elim_threshold;
363+ if (avctx->chroma_elim_threshold)
364+ s->chroma_elim_threshold = avctx->chroma_elim_threshold;
365+#endif
357366 s->strict_std_compliance = avctx->strict_std_compliance;
358367 s->quarter_sample = (avctx->flags & CODEC_FLAG_QPEL) != 0;
359368 s->mpeg_quant = avctx->mpeg_quant;
@@ -373,13 +382,18 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) · 13 unmodified lines
373382 /* Fixed QSCALE */
374383 s->fixed_qscale = !!(avctx->flags & CODEC_FLAG_QSCALE);
375384
385+#if FF_API_MPV_GLOBAL_OPTS
386+ if (s->flags & CODEC_FLAG_QP_RD)
387+ s->mpv_flags |= FF_MPV_FLAG_QP_RD;
388+#endif
389+
376390 s->adaptive_quant = (s->avctx->lumi_masking ||
377391 s->avctx->dark_masking ||
378392 s->avctx->temporal_cplx_masking ||
379393 s->avctx->spatial_cplx_masking ||
380394 s->avctx->p_masking ||
381395 s->avctx->border_masking ||
382− (s->flags & CODEC_FLAG_QP_RD)) &&
396+ (s->mpv_flags & FF_MPV_FLAG_QP_RD)) &&
383397 !s->fixed_qscale;
384398
385399 s->loop_filter = !!(s->flags & CODEC_FLAG_LOOP_FILTER);
@@ -488,12 +502,17 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) · 102 unmodified lines
488502 return -1;
489503 }
490504
491− if ((s->flags & CODEC_FLAG_CBP_RD) && !avctx->trellis) {
505+#if FF_API_MPV_GLOBAL_OPTS
506+ if (s->flags & CODEC_FLAG_CBP_RD)
507+ s->mpv_flags |= FF_MPV_FLAG_CBP_RD;
508+#endif
509+
510+ if ((s->mpv_flags & FF_MPV_FLAG_CBP_RD) && !avctx->trellis) {
492511 av_log(avctx, AV_LOG_ERROR, "CBP RD needs trellis quant\n");
493512 return -1;
494513 }
495514
496− if ((s->flags & CODEC_FLAG_QP_RD) &&
515+ if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) &&
497516 s->avctx->mb_decision != FF_MB_DECISION_RD) {
498517 av_log(avctx, AV_LOG_ERROR, "QP RD needs mbd=2\n");
499518 return -1;
@@ -610,6 +629,15 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) · 110 unmodified lines
610629 }
611630 s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
612631
632+#if FF_API_MPV_GLOBAL_OPTS
633+ if (avctx->flags2 & CODEC_FLAG2_SKIP_RD)
634+ s->mpv_flags |= FF_MPV_FLAG_SKIP_RD;
635+ if (avctx->flags2 & CODEC_FLAG2_STRICT_GOP)
636+ s->mpv_flags |= FF_MPV_FLAG_STRICT_GOP;
637+ if (avctx->quantizer_noise_shaping)
638+ s->quantizer_noise_shaping = avctx->quantizer_noise_shaping;
639+#endif
640+
613641 switch (avctx->codec->id) {
614642 case CODEC_ID_MPEG1VIDEO:
615643 s->out_format = FMT_MPEG1;
@@ -1301,7 +1329,7 @@ static int select_input_picture(MpegEncContext *s) · 685 unmodified lines
13011329 }
13021330
13031331 if (s->picture_in_gop_number + b_frames >= s->gop_size) {
1304− if ((s->flags2 & CODEC_FLAG2_STRICT_GOP) &&
1332+ if ((s->mpv_flags & FF_MPV_FLAG_STRICT_GOP) &&
13051333 s->gop_size > s->picture_in_gop_number) {
13061334 b_frames = s->gop_size - s->picture_in_gop_number - 1;
13071335 } else {
@@ -1726,7 +1754,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, · 418 unmodified lines
17261754 s->lambda = s->lambda_table[mb_xy];
17271755 update_qscale(s);
17281756
1729− if (!(s->flags & CODEC_FLAG_QP_RD)) {
1757+ if (!(s->mpv_flags & FF_MPV_FLAG_QP_RD)) {
17301758 s->qscale = s->current_picture_ptr->f.qscale_table[mb_xy];
17311759 s->dquant = s->qscale - last_qp;
17321760
@@ -1746,7 +1774,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, · 13 unmodified lines
17461774 }
17471775 }
17481776 ff_set_qscale(s, last_qp + s->dquant);
1749− } else if (s->flags & CODEC_FLAG_QP_RD)
1777+ } else if (s->mpv_flags & FF_MPV_FLAG_QP_RD)
17501778 ff_set_qscale(s, s->qscale + s->dquant);
17511779
17521780 wrap_y = s->linesize;
@@ -1934,7 +1962,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, · 181 unmodified lines
19341962 }
19351963 }
19361964
1937− if (s->avctx->quantizer_noise_shaping) {
1965+ if (s->quantizer_noise_shaping) {
19381966 if (!skip_dct[0])
19391967 get_visual_weight(weight[0], ptr_y , wrap_y);
19401968 if (!skip_dct[1])
@@ -1975,7 +2003,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, · 34 unmodified lines
19752003 } else
19762004 s->block_last_index[i] = -1;
19772005 }
1978− if (s->avctx->quantizer_noise_shaping) {
2006+ if (s->quantizer_noise_shaping) {
19792007 for (i = 0; i < mb_block_count; i++) {
19802008 if (!skip_dct[i]) {
19812009 s->block_last_index[i] =
@@ -1992,7 +2020,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, · 10 unmodified lines
19922020 for (i = 4; i < mb_block_count; i++)
19932021 dct_single_coeff_elimination(s, i, s->chroma_elim_threshold);
19942022
1995− if (s->flags & CODEC_FLAG_CBP_RD) {
2023+ if (s->mpv_flags & FF_MPV_FLAG_CBP_RD) {
19962024 for (i = 0; i < mb_block_count; i++) {
19972025 if (s->block_last_index[i] == -1)
19982026 s->coded_score[i] = INT_MAX / 256;
@@ -2513,7 +2541,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 514 unmodified lines
25132541 s->mb_skipped=0;
25142542 s->dquant=0; //only for QP_RD
25152543
2516− if(mb_type & (mb_type-1) || (s->flags & CODEC_FLAG_QP_RD)){ // more than 1 MB type possible or CODEC_FLAG_QP_RD
2544+ if (mb_type & (mb_type-1) || (s->mpv_flags & FF_MPV_FLAG_QP_RD)) { // more than 1 MB type possible or FF_MPV_FLAG_QP_RD
25172545 int next_block=0;
25182546 int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
25192547
@@ -2650,7 +2678,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 130 unmodified lines
26502678 }
26512679 }
26522680
2653− if((s->flags & CODEC_FLAG_QP_RD) && dmin < INT_MAX){
2681+ if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) && dmin < INT_MAX) {
26542682 if(best_s.mv_type==MV_TYPE_16X16){ //FIXME move 4mv after QPRD
26552683 const int last_qp= backup_s.qscale;
26562684 int qpi, qp, dc[6];
@@ -2715,7 +2743,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 58 unmodified lines
27152743 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
27162744 &dmin, &next_block, 0, 0);
27172745 }
2718− if(!best_s.mb_intra && s->flags2&CODEC_FLAG2_SKIP_RD){
2746+ if (!best_s.mb_intra && s->mpv_flags & FF_MPV_FLAG_SKIP_RD) {
27192747 int coded=0;
27202748 for(i=0; i<6; i++)
27212749 coded |= s->block_last_index[i];
@@ -3755,7 +3783,7 @@ STOP_TIMER("init rem[]") · 1033 unmodified lines
37553783 #ifdef REFINE_STATS
37563784 {START_TIMER
37573785 #endif
3758− analyze_gradient = last_non_zero > 2 || s->avctx->quantizer_noise_shaping >= 3;
3786+ analyze_gradient = last_non_zero > 2 || s->quantizer_noise_shaping >= 3;
37593787
37603788 if(analyze_gradient){
37613789 #ifdef REFINE_STATS
@@ -3813,7 +3841,7 @@ STOP_TIMER("dct")} · 51 unmodified lines
38133841 const int level= block[j];
38143842 int change, old_coeff;
38153843
3816− if(s->avctx->quantizer_noise_shaping < 3 && i > last_non_zero + 1)
3844+ if(s->quantizer_noise_shaping < 3 && i > last_non_zero + 1)
38173845 break;
38183846
38193847 if(level){
@@ -3831,7 +3859,7 @@ STOP_TIMER("dct")} · 11 unmodified lines
38313859 int score, new_coeff, unquant_change;
38323860
38333861 score=0;
3834− if(s->avctx->quantizer_noise_shaping < 2 && FFABS(new_level) > FFABS(level))
3862+ if(s->quantizer_noise_shaping < 2 && FFABS(new_level) > FFABS(level))
38353863 continue;
38363864
38373865 if(new_level){
@@ -4089,6 +4117,7 @@ int ff_dct_quantize_c(MpegEncContext *s, · 251 unmodified lines
40894117 static const AVOption h263_options[] = {
40904118 { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
40914119 { "structured_slices","Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE},
4120+ FF_MPV_COMMON_OPTS
40924121 { NULL },
40934122 };
40944123
@@ -4117,6 +4146,7 @@ static const AVOption h263p_options[] = { · 22 unmodified lines
41174146 { "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
41184147 { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
41194148 { "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE},
4149+ FF_MPV_COMMON_OPTS
41204150 { NULL },
41214151 };
41224152 static const AVClass h263p_class = {
@@ -4140,6 +4170,8 @@ AVCodec ff_h263p_encoder = { · 17 unmodified lines
41404170 .priv_class = &h263p_class,
41414171 };
41424172
4173+FF_MPV_GENERIC_CLASS(msmpeg4v2)
4174+
41434175 AVCodec ff_msmpeg4v2_encoder = {
41444176 .name = "msmpeg4v2",
41454177 .type = AVMEDIA_TYPE_VIDEO,
@@ -4150,8 +4182,11 @@ AVCodec ff_msmpeg4v2_encoder = { · 4 unmodified lines
41504182 .close = ff_MPV_encode_end,
41514183 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
41524184 .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
4185+ .priv_class = &msmpeg4v2_class,
41534186 };
41544187
4188+FF_MPV_GENERIC_CLASS(msmpeg4v3)
4189+
41554190 AVCodec ff_msmpeg4v3_encoder = {
41564191 .name = "msmpeg4",
41574192 .type = AVMEDIA_TYPE_VIDEO,
@@ -4162,8 +4197,11 @@ AVCodec ff_msmpeg4v3_encoder = { · 4 unmodified lines
41624197 .close = ff_MPV_encode_end,
41634198 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
41644199 .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
4200+ .priv_class = &msmpeg4v3_class,
41654201 };
41664202
4203+FF_MPV_GENERIC_CLASS(wmv1)
4204+
41674205 AVCodec ff_wmv1_encoder = {
41684206 .name = "wmv1",
41694207 .type = AVMEDIA_TYPE_VIDEO,
@@ -4174,4 +4212,5 @@ AVCodec ff_wmv1_encoder = { · 4 unmodified lines
41744212 .close = ff_MPV_encode_end,
41754213 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
41764214 .long_name= NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
4215+ .priv_class = &wmv1_class,
41774216 };
libavcodec/options.c+21−7
@@ -98,12 +98,16 @@ static const AVOption options[]={ · 97 unmodified lines
9898 {"global_header", "place global headers in extradata instead of every keyframe", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"},
9999 {"bitexact", "use only bitexact stuff (except (i)dct)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_BITEXACT }, INT_MIN, INT_MAX, A|V|S|D|E, "flags"},
100100 {"aic", "h263 advanced intra coding / mpeg4 ac prediction", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_AC_PRED }, INT_MIN, INT_MAX, V|E, "flags"},
101−{"cbp", "use rate distortion optimization for cbp", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CBP_RD }, INT_MIN, INT_MAX, V|E, "flags"},
102−{"qprd", "use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"},
101+#if FF_API_MPV_GLOBAL_OPTS
102+{"cbp", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CBP_RD }, INT_MIN, INT_MAX, V|E, "flags"},
103+{"qprd", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"},
104+#endif
103105 {"ilme", "interlaced motion estimation", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"},
104106 {"cgop", "closed gop", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"},
105107 {"fast", "allow non spec compliant speedup tricks", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"},
106−{"sgop", "strictly enforce gop size", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_STRICT_GOP }, INT_MIN, INT_MAX, V|E, "flags2"},
108+#if FF_API_MPV_GLOBAL_OPTS
109+{"sgop", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_STRICT_GOP }, INT_MIN, INT_MAX, V|E, "flags2"},
110+#endif
107111 {"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"},
108112 {"local_header", "place global headers at every keyframe instead of in extradata", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, INT_MAX, V|E, "flags2"},
109113 {"showall", "Show all frames before the first keyframe", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SHOW_ALL }, INT_MIN, INT_MAX, V|D, "flags2"},
@@ -167,8 +171,10 @@ static const AVOption options[]={ · 57 unmodified lines
167171 {"dc_clip", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_DC_CLIP }, INT_MIN, INT_MAX, V|D, "bug"},
168172 {"ms", "workaround various bugs in microsofts broken decoders", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_MS }, INT_MIN, INT_MAX, V|D, "bug"},
169173 {"trunc", "trancated frames", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_TRUNCATED}, INT_MIN, INT_MAX, V|D, "bug"},
174+#if FF_API_MPV_GLOBAL_OPTS
170175 {"lelim", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)", OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
171176 {"celim", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)", OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
177+#endif
172178 {"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|V|D|E, "strict"},
173179 {"very", "strictly conform to a older more strict version of the spec or reference software", 0, AV_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_VERY_STRICT }, INT_MIN, INT_MAX, V|D|E, "strict"},
174180 {"strict", "strictly conform to all the things in the spec no matter what consequences", 0, AV_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_STRICT }, INT_MIN, INT_MAX, V|D|E, "strict"},
@@ -194,8 +200,8 @@ static const AVOption options[]={ · 19 unmodified lines
194200 {"rc_qmod_freq", "experimental quantizer modulation", OFFSET(rc_qmod_freq), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
195201 {"rc_override_count", NULL, OFFSET(rc_override_count), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
196202 {"rc_eq", "set rate control equation", OFFSET(rc_eq), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, V|E},
197−{"maxrate", "set max video bitrate tolerance (in bits/s)", OFFSET(rc_max_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
198−{"minrate", "set min video bitrate tolerance (in bits/s)", OFFSET(rc_min_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
203+{"maxrate", "set max bitrate tolerance (in bits/s)", OFFSET(rc_max_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
204+{"minrate", "set min bitrate tolerance (in bits/s)", OFFSET(rc_min_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
199205 {"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|V|E},
200206 {"rc_buf_aggressivity", "currently useless", OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, V|E},
201207 {"i_qfactor", "qp factor between P and I frames", OFFSET(i_quant_factor), AV_OPT_TYPE_FLOAT, {.dbl = -0.8 }, -FLT_MAX, FLT_MAX, V|E},
@@ -296,7 +302,9 @@ static const AVOption options[]={ · 94 unmodified lines
296302 {"me_range", "limit motion vectors range (1023 for DivX player)", OFFSET(me_range), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
297303 {"ibias", "intra quant bias", OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.dbl = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E},
298304 {"pbias", "inter quant bias", OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.dbl = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E},
305+#if FF_API_COLOR_TABLE_ID
299306 {"color_table_id", NULL, OFFSET(color_table_id), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
307+#endif
300308 {"global_quality", NULL, OFFSET(global_quality), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
301309 {"coder", NULL, OFFSET(coder_type), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "coder"},
302310 {"vlc", "variable length coder / huffman coder", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, V|E, "coder"},
@@ -317,10 +325,14 @@ static const AVOption options[]={ · 14 unmodified lines
317325 {"lmax", "max lagrange factor (VBR)", OFFSET(lmax), AV_OPT_TYPE_INT, {.dbl = 31*FF_QP2LAMBDA }, 0, INT_MAX, V|E},
318326 {"nr", "noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
319327 {"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
328+#if FF_API_INTER_THRESHOLD
320329 {"inter_threshold", NULL, OFFSET(inter_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
330+#endif
321331 {"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT}, 0, UINT_MAX, V|A|E|D, "flags2"},
322332 {"error", NULL, OFFSET(error_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
323−{"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
333+#if FF_API_MPV_GLOBAL_OPTS
334+{"qns", "deprecated, use mpegvideo private options instead", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
335+#endif
324336 {"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 1 }, 0, INT_MAX, V|E|D, "threads"},
325337 {"auto", "detect a good number of threads", 0, AV_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"},
326338 {"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
@@ -366,7 +378,9 @@ static const AVOption options[]={ · 39 unmodified lines
366378 {"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, INT_MAX, V|E},
367379 {"chromaoffset", "chroma qp offset from luma", OFFSET(chromaoffset), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
368380 {"trellis", "rate-distortion optimal quantization", OFFSET(trellis), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
369−{"skiprd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SKIP_RD }, INT_MIN, INT_MAX, V|E, "flags2"},
381+#if FF_API_MPV_GLOBAL_OPTS
382+{"skiprd", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SKIP_RD }, INT_MIN, INT_MAX, V|E, "flags2"},
383+#endif
370384 {"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), AV_OPT_TYPE_INT, {.dbl = 6 }, 0, INT_MAX, V|E},
371385 {"mv0_threshold", NULL, OFFSET(mv0_threshold), AV_OPT_TYPE_INT, {.dbl = 256 }, 0, INT_MAX, V|E},
372386 {"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.dbl = 40 }, 1, INT_MAX, V|E},
libavcodec/proresdec_lgpl.c+32−13
@@ -165,6 +165,10 @@ static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, · 164 unmodified lines
165165 ctx->picture.top_field_first = ctx->frame_type & 1;
166166 }
167167
168+ avctx->color_primaries = buf[14];
169+ avctx->color_trc = buf[15];
170+ avctx->colorspace = buf[16];
171+
168172 ctx->alpha_info = buf[17] & 0xf;
169173 if (ctx->alpha_info)
170174 av_log_missing_feature(avctx, "alpha channel", 0);
@@ -411,7 +415,7 @@ static void decode_slice_plane(ProresContext *ctx, ProresThreadData *td, · 240 unmodified lines
411415 int data_size, uint16_t *out_ptr,
412416 int linesize, int mbs_per_slice,
413417 int blocks_per_mb, int plane_size_factor,
414− const int16_t *qmat)
418+ const int16_t *qmat, int is_chroma)
415419 {
416420 GetBitContext gb;
417421 DCTELEM *block_ptr;
@@ -431,18 +435,33 @@ static void decode_slice_plane(ProresContext *ctx, ProresThreadData *td, · 13 unmodified lines
431435 /* inverse quantization, inverse transform and output */
432436 block_ptr = td->blocks;
433437
434− for (mb_num = 0; mb_num < mbs_per_slice; mb_num++, out_ptr += blocks_per_mb * 4) {
435− ctx->dsp.idct_put(out_ptr, linesize, block_ptr, qmat);
436− block_ptr += 64;
437− if (blocks_per_mb > 2) {
438− ctx->dsp.idct_put(out_ptr + 8, linesize, block_ptr, qmat);
438+ if (!is_chroma) {
439+ for (mb_num = 0; mb_num < mbs_per_slice; mb_num++, out_ptr += blocks_per_mb * 4) {
440+ ctx->dsp.idct_put(out_ptr, linesize, block_ptr, qmat);
441+ block_ptr += 64;
442+ if (blocks_per_mb > 2) {
443+ ctx->dsp.idct_put(out_ptr + 8, linesize, block_ptr, qmat);
444+ block_ptr += 64;
445+ }
446+ ctx->dsp.idct_put(out_ptr + linesize * 4, linesize, block_ptr, qmat);
439447 block_ptr += 64;
448+ if (blocks_per_mb > 2) {
449+ ctx->dsp.idct_put(out_ptr + linesize * 4 + 8, linesize, block_ptr, qmat);
450+ block_ptr += 64;
451+ }
440452 }
441− ctx->dsp.idct_put(out_ptr + linesize * 4, linesize, block_ptr, qmat);
442− block_ptr += 64;
443− if (blocks_per_mb > 2) {
444− ctx->dsp.idct_put(out_ptr + linesize * 4 + 8, linesize, block_ptr, qmat);
453+ } else {
454+ for (mb_num = 0; mb_num < mbs_per_slice; mb_num++, out_ptr += blocks_per_mb * 4) {
455+ ctx->dsp.idct_put(out_ptr, linesize, block_ptr, qmat);
456+ block_ptr += 64;
457+ ctx->dsp.idct_put(out_ptr + linesize * 4, linesize, block_ptr, qmat);
445458 block_ptr += 64;
459+ if (blocks_per_mb > 2) {
460+ ctx->dsp.idct_put(out_ptr + 8, linesize, block_ptr, qmat);
461+ block_ptr += 64;
462+ ctx->dsp.idct_put(out_ptr + linesize * 4 + 8, linesize, block_ptr, qmat);
463+ block_ptr += 64;
464+ }
446465 }
447466 }
448467 }
@@ -523,7 +542,7 @@ static int decode_slice(AVCodecContext *avctx, void *tdata) · 74 unmodified lines
523542 (uint16_t*) (y_data + (mb_y_pos << 4) * y_linesize +
524543 (mb_x_pos << 5)), y_linesize,
525544 mbs_per_slice, 4, slice_width_factor + 2,
526− td->qmat_luma_scaled);
545+ td->qmat_luma_scaled, 0);
527546
528547 /* decode U chroma plane */
529548 decode_slice_plane(ctx, td, buf + hdr_size + y_data_size, u_data_size,
@@ -531,7 +550,7 @@ static int decode_slice(AVCodecContext *avctx, void *tdata) · 1 unmodified line
531550 (mb_x_pos << ctx->mb_chroma_factor)),
532551 u_linesize, mbs_per_slice, ctx->num_chroma_blocks,
533552 slice_width_factor + ctx->chroma_factor - 1,
534− td->qmat_chroma_scaled);
553+ td->qmat_chroma_scaled, 1);
535554
536555 /* decode V chroma plane */
537556 decode_slice_plane(ctx, td, buf + hdr_size + y_data_size + u_data_size,
@@ -540,7 +559,7 @@ static int decode_slice(AVCodecContext *avctx, void *tdata) · 2 unmodified lines
540559 (mb_x_pos << ctx->mb_chroma_factor)),
541560 v_linesize, mbs_per_slice, ctx->num_chroma_blocks,
542561 slice_width_factor + ctx->chroma_factor - 1,
543− td->qmat_chroma_scaled);
562+ td->qmat_chroma_scaled, 1);
544563
545564 return 0;
546565 }
libavcodec/proresenc_kostya.c+35−22
@@ -171,7 +171,7 @@ typedef struct ProresContext { · 170 unmodified lines
171171 static void get_slice_data(ProresContext *ctx, const uint16_t *src,
172172 int linesize, int x, int y, int w, int h,
173173 DCTELEM *blocks,
174− int mbs_per_slice, int blocks_per_mb)
174+ int mbs_per_slice, int blocks_per_mb, int is_chroma)
175175 {
176176 const uint16_t *esrc;
177177 const int mb_width = 4 * blocks_per_mb;
@@ -189,37 +189,50 @@ static void get_slice_data(ProresContext *ctx, const uint16_t *src, · 11 unmodified lines
189189 elinesize = linesize;
190190 } else {
191191 int bw, bh, pix;
192− const int estride = 16 / sizeof(*ctx->emu_buf);
193192
194193 esrc = ctx->emu_buf;
195− elinesize = 16;
194+ elinesize = 16 * sizeof(*ctx->emu_buf);
196195
197196 bw = FFMIN(w - x, mb_width);
198197 bh = FFMIN(h - y, 16);
199198
200199 for (j = 0; j < bh; j++) {
201− memcpy(ctx->emu_buf + j * estride, src + j * linesize,
200+ memcpy(ctx->emu_buf + j * 16,
201+ (const uint8_t*)src + j * linesize,
202202 bw * sizeof(*src));
203− pix = ctx->emu_buf[j * estride + bw - 1];
203+ pix = ctx->emu_buf[j * 16 + bw - 1];
204204 for (k = bw; k < mb_width; k++)
205− ctx->emu_buf[j * estride + k] = pix;
205+ ctx->emu_buf[j * 16 + k] = pix;
206206 }
207207 for (; j < 16; j++)
208− memcpy(ctx->emu_buf + j * estride,
209− ctx->emu_buf + (bh - 1) * estride,
208+ memcpy(ctx->emu_buf + j * 16,
209+ ctx->emu_buf + (bh - 1) * 16,
210210 mb_width * sizeof(*ctx->emu_buf));
211211 }
212− ctx->dsp.fdct(esrc, elinesize, blocks);
213− blocks += 64;
214− if (blocks_per_mb > 2) {
215− ctx->dsp.fdct(src + 8, linesize, blocks);
212+ if (!is_chroma) {
213+ ctx->dsp.fdct(esrc, elinesize, blocks);
216214 blocks += 64;
217− }
218− ctx->dsp.fdct(src + linesize * 4, linesize, blocks);
219− blocks += 64;
220− if (blocks_per_mb > 2) {
221− ctx->dsp.fdct(src + linesize * 4 + 8, linesize, blocks);
215+ if (blocks_per_mb > 2) {
216+ ctx->dsp.fdct(src + 8, linesize, blocks);
217+ blocks += 64;
218+ }
219+ ctx->dsp.fdct(src + linesize * 4, linesize, blocks);
222220 blocks += 64;
221+ if (blocks_per_mb > 2) {
222+ ctx->dsp.fdct(src + linesize * 4 + 8, linesize, blocks);
223+ blocks += 64;
224+ }
225+ } else {
226+ ctx->dsp.fdct(esrc, elinesize, blocks);
227+ blocks += 64;
228+ ctx->dsp.fdct(src + linesize * 4, linesize, blocks);
229+ blocks += 64;
230+ if (blocks_per_mb > 2) {
231+ ctx->dsp.fdct(src + 8, linesize, blocks);
232+ blocks += 64;
233+ ctx->dsp.fdct(src + linesize * 4 + 8, linesize, blocks);
234+ blocks += 64;
235+ }
223236 }
224237
225238 x += mb_width;
@@ -383,7 +396,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, · 157 unmodified lines
383396
384397 get_slice_data(ctx, src, pic->linesize[i], xp, yp,
385398 pwidth, avctx->height, ctx->blocks[0],
386− mbs_per_slice, num_cblocks);
399+ mbs_per_slice, num_cblocks, is_chroma);
387400 sizes[i] = encode_slice_plane(ctx, pb, src, pic->linesize[i],
388401 mbs_per_slice, ctx->blocks[0],
389402 num_cblocks, plane_factor,
@@ -539,7 +552,7 @@ static int find_slice_quant(AVCodecContext *avctx, const AVFrame *pic, · 149 unmodified lines
539552
540553 get_slice_data(ctx, src, pic->linesize[i], xp, yp,
541554 pwidth, avctx->height, ctx->blocks[i],
542− mbs_per_slice, num_cblocks[i]);
555+ mbs_per_slice, num_cblocks[i], is_chroma[i]);
543556 }
544557
545558 for (q = min_quant; q < max_quant + 2; q++) {
@@ -676,9 +689,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 130 unmodified lines
676689 bytestream_put_be16 (&buf, avctx->height);
677690 bytestream_put_byte (&buf, ctx->chroma_factor << 6); // frame flags
678691 bytestream_put_byte (&buf, 0); // reserved
679− bytestream_put_byte (&buf, 0); // primaries
680− bytestream_put_byte (&buf, 0); // transfer function
681− bytestream_put_byte (&buf, 6); // colour matrix - ITU-R BT.601-4
692+ bytestream_put_byte (&buf, avctx->color_primaries);
693+ bytestream_put_byte (&buf, avctx->color_trc);
694+ bytestream_put_byte (&buf, avctx->colorspace);
682695 bytestream_put_byte (&buf, 0x40); // source format and alpha information
683696 bytestream_put_byte (&buf, 0); // reserved
684697 bytestream_put_byte (&buf, 0x03); // matrix flags - both matrices are present
libavcodec/qtrle.c+1−1
@@ -424,7 +424,7 @@ static av_cold int qtrle_decode_init(AVCodecContext *avctx) · 423 unmodified lines
424424 default:
425425 av_log (avctx, AV_LOG_ERROR, "Unsupported colorspace: %d bits/sample?\n",
426426 avctx->bits_per_coded_sample);
427− break;
427+ return AVERROR_INVALIDDATA;
428428 }
429429
430430 avcodec_get_frame_defaults(&s->frame);
libavcodec/rpza.c+4−0
@@ -183,6 +183,8 @@ static void rpza_decode_stream(RpzaContext *s) · 182 unmodified lines
183183 color4[1] |= ((11 * ta + 21 * tb) >> 5);
184184 color4[2] |= ((21 * ta + 11 * tb) >> 5);
185185
186+ if (s->size - stream_ptr < n_blocks * 4)
187+ return;
186188 while (n_blocks--) {
187189 block_ptr = row_ptr + pixel_ptr;
188190 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
@@ -200,6 +202,8 @@ static void rpza_decode_stream(RpzaContext *s) · 11 unmodified lines
200202
201203 /* Fill block with 16 colors */
202204 case 0x00:
205+ if (s->size - stream_ptr < 16)
206+ return;
203207 block_ptr = row_ptr + pixel_ptr;
204208 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
205209 for (pixel_x = 0; pixel_x < 4; pixel_x++){
libavcodec/rv10enc.c+3−0
@@ -56,6 +56,8 @@ void ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number) · 55 unmodified lines
5656 put_bits(&s->pb, 3, 0); /* ignored */
5757 }
5858
59+FF_MPV_GENERIC_CLASS(rv10)
60+
5961 AVCodec ff_rv10_encoder = {
6062 .name = "rv10",
6163 .type = AVMEDIA_TYPE_VIDEO,
@@ -66,4 +68,5 @@ AVCodec ff_rv10_encoder = { · 4 unmodified lines
6668 .close = ff_MPV_encode_end,
6769 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
6870 .long_name= NULL_IF_CONFIG_SMALL("RealVideo 1.0"),
71+ .priv_class = &rv10_class,
6972 };
libavcodec/rv20enc.c+3−0
@@ -57,6 +57,8 @@ void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number){ · 56 unmodified lines
5757 }
5858 }
5959
60+FF_MPV_GENERIC_CLASS(rv20)
61+
6062 AVCodec ff_rv20_encoder = {
6163 .name = "rv20",
6264 .type = AVMEDIA_TYPE_VIDEO,
@@ -67,4 +69,5 @@ AVCodec ff_rv20_encoder = { · 4 unmodified lines
6769 .close = ff_MPV_encode_end,
6870 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
6971 .long_name= NULL_IF_CONFIG_SMALL("RealVideo 2.0"),
72+ .priv_class = &rv20_class,
7073 };
libavcodec/version.h+9−0
@@ -60,5 +60,14 @@ · 59 unmodified lines
6060 #ifndef FF_API_OLD_ENCODE_VIDEO
6161 #define FF_API_OLD_ENCODE_VIDEO (LIBAVCODEC_VERSION_MAJOR < 55)
6262 #endif
63+#ifndef FF_API_MPV_GLOBAL_OPTS
64+#define FF_API_MPV_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 55)
65+#endif
66+#ifndef FF_API_COLOR_TABLE_ID
67+#define FF_API_COLOR_TABLE_ID (LIBAVCODEC_VERSION_MAJOR < 55)
68+#endif
69+#ifndef FF_API_INTER_THRESHOLD
70+#define FF_API_INTER_THRESHOLD (LIBAVCODEC_VERSION_MAJOR < 55)
71+#endif
6372
6473 #endif /* AVCODEC_VERSION_H */
libavcodec/vmnc.c+1−1
@@ -484,7 +484,7 @@ static av_cold int decode_init(AVCodecContext *avctx) · 483 unmodified lines
484484 break;
485485 default:
486486 av_log(avctx, AV_LOG_ERROR, "Unsupported bitdepth %i\n", c->bpp);
487− return AVERROR_PATCHWELCOME;
487+ return AVERROR_INVALIDDATA;
488488 }
489489
490490 return 0;
libavcodec/vp5.c+5−0
@@ -57,6 +57,11 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, · 56 unmodified lines
5757 }
5858 rows = vp56_rac_gets(c, 8); /* number of stored macroblock rows */
5959 cols = vp56_rac_gets(c, 8); /* number of stored macroblock cols */
60+ if (!rows || !cols) {
61+ av_log(s->avctx, AV_LOG_ERROR, "Invalid size %dx%d\n",
62+ cols << 4, rows << 4);
63+ return 0;
64+ }
6065 vp56_rac_gets(c, 8); /* number of displayed macroblock rows */
6166 vp56_rac_gets(c, 8); /* number of displayed macroblock cols */
6267 vp56_rac_gets(c, 2);
libavcodec/vp6.c+5−1
@@ -77,6 +77,10 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, · 76 unmodified lines
7777 cols = buf[3]; /* number of stored macroblock cols */
7878 /* buf[4] is number of displayed macroblock rows */
7979 /* buf[5] is number of displayed macroblock cols */
80+ if (!rows || !cols) {
81+ av_log(s->avctx, AV_LOG_ERROR, "Invalid size %dx%d\n", cols << 4, rows << 4);
82+ return 0;
83+ }
8084
8185 if (!s->macroblocks || /* first frame */
8286 16*cols != s->avctx->coded_width ||
@@ -97,7 +101,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, · 14 unmodified lines
97101 vrt_shift = 5;
98102 s->sub_version = sub_version;
99103 } else {
100− if (!s->sub_version)
104+ if (!s->sub_version || !s->avctx->coded_width || !s->avctx->coded_height)
101105 return 0;
102106
103107 if (separated_coeff || !s->filter_header) {
libavformat/asfdec.c+5−21
@@ -26,7 +26,6 @@ · 25 unmodified lines
2626 #include "libavutil/avstring.h"
2727 #include "libavutil/dict.h"
2828 #include "libavutil/mathematics.h"
29−#include "libavcodec/mpegaudio.h"
3029 #include "avformat.h"
3130 #include "internal.h"
3231 #include "avio_internal.h"
@@ -199,6 +198,8 @@ static int asf_read_file_properties(AVFormatContext *s, int64_t size) · 166 unmodified lines
199198 asf->hdr.flags = avio_rl32(pb);
200199 asf->hdr.min_pktsize = avio_rl32(pb);
201200 asf->hdr.max_pktsize = avio_rl32(pb);
201+ if (asf->hdr.min_pktsize >= (1U<<29))
202+ return AVERROR_INVALIDDATA;
202203 asf->hdr.max_bitrate = avio_rl32(pb);
203204 s->packet_size = asf->hdr.max_pktsize;
204205
@@ -317,25 +318,6 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) · 112 unmodified lines
317318 || asf_st->ds_packet_size % asf_st->ds_chunk_size)
318319 asf_st->ds_span = 0; // disable descrambling
319320 }
320− switch (st->codec->codec_id) {
321− case CODEC_ID_MP3:
322− st->codec->frame_size = MPA_FRAME_SIZE;
323− break;
324− case CODEC_ID_PCM_S16LE:
325− case CODEC_ID_PCM_S16BE:
326− case CODEC_ID_PCM_U16LE:
327− case CODEC_ID_PCM_U16BE:
328− case CODEC_ID_PCM_S8:
329− case CODEC_ID_PCM_U8:
330− case CODEC_ID_PCM_ALAW:
331− case CODEC_ID_PCM_MULAW:
332− st->codec->frame_size = 1;
333− break;
334− default:
335− /* This is probably wrong, but it prevents a crash later */
336− st->codec->frame_size = 1;
337− break;
338− }
339321 } else if (type == AVMEDIA_TYPE_VIDEO &&
340322 size - (avio_tell(pb) - pos1 + 24) >= 51) {
341323 avio_rl32(pb);
@@ -612,7 +594,9 @@ static int asf_read_header(AVFormatContext *s) · 270 unmodified lines
612594 if (gsize < 24)
613595 return -1;
614596 if (!ff_guidcmp(&g, &ff_asf_file_header)) {
615− asf_read_file_properties(s, gsize);
597+ int ret = asf_read_file_properties(s, gsize);
598+ if (ret < 0)
599+ return ret;
616600 } else if (!ff_guidcmp(&g, &ff_asf_stream_header)) {
617601 asf_read_stream_properties(s, gsize);
618602 } else if (!ff_guidcmp(&g, &ff_asf_comment_header)) {
libavformat/avformat.h+16−0
@@ -541,6 +541,13 @@ typedef struct AVIndexEntry { · 540 unmodified lines
541541 #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 /**< stream for hearing impaired audiences */
542542 #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */
543543 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */
544+/**
545+ * The stream is stored in the file as an attached picture/"cover art" (e.g.
546+ * APIC frame in ID3v2). The single packet associated with it will be returned
547+ * among the first few packets read from the file unless seeking takes place.
548+ * It can also be accessed at any time in AVStream.attached_pic.
549+ */
550+#define AV_DISPOSITION_ATTACHED_PIC 0x0400
544551
545552 /**
546553 * Stream structure.
@@ -615,6 +622,15 @@ typedef struct AVStream { · 68 unmodified lines
615622 */
616623 AVRational avg_frame_rate;
617624
625+ /**
626+ * For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet
627+ * will contain the attached picture.
628+ *
629+ * decoding: set by libavformat, must not be modified by the caller.
630+ * encoding: unused
631+ */
632+ AVPacket attached_pic;
633+
618634 /*****************************************************************
619635 * All fields below this line are not part of the public API. They
620636 * may not be used outside of libavformat and can be changed and
libavformat/dxa.c+2−0
@@ -107,6 +107,8 @@ static int dxa_read_header(AVFormatContext *s) · 106 unmodified lines
107107 ret = ff_get_wav_header(pb, ast->codec, fsize);
108108 if (ret < 0)
109109 return ret;
110+ if (ast->codec->sample_rate > 0)
111+ avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
110112 // find 'data' chunk
111113 while(avio_tell(pb) < c->vidpos && !url_feof(pb)){
112114 tag = avio_rl32(pb);
libavformat/ffmdec.c+0−2
@@ -338,8 +338,6 @@ static int ffm_read_header(AVFormatContext *s) · 337 unmodified lines
338338 codec->dct_algo = avio_rb32(pb);
339339 codec->strict_std_compliance = avio_rb32(pb);
340340 codec->max_b_frames = avio_rb32(pb);
341− codec->luma_elim_threshold = avio_rb32(pb);
342− codec->chroma_elim_threshold = avio_rb32(pb);
343341 codec->mpeg_quant = avio_rb32(pb);
344342 codec->intra_dc_precision = avio_rb32(pb);
345343 codec->me_method = avio_rb32(pb);
libavformat/ffmenc.c+0−2
@@ -144,8 +144,6 @@ static int ffm_write_header(AVFormatContext *s) · 143 unmodified lines
144144 avio_wb32(pb, codec->dct_algo);
145145 avio_wb32(pb, codec->strict_std_compliance);
146146 avio_wb32(pb, codec->max_b_frames);
147− avio_wb32(pb, codec->luma_elim_threshold);
148− avio_wb32(pb, codec->chroma_elim_threshold);
149147 avio_wb32(pb, codec->mpeg_quant);
150148 avio_wb32(pb, codec->intra_dc_precision);
151149 avio_wb32(pb, codec->me_method);
libavformat/id3v2.c+147−6
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838 #include "libavutil/intreadwrite.h"
3939 #include "libavutil/dict.h"
4040 #include "avio_internal.h"
41+#include "internal.h"
4142
4243 const AVMetadataConv ff_id3v2_34_metadata_conv[] = {
4344 { "TALB", "album"},
@@ -99,6 +100,38 @@ const char ff_id3v2_3_tags[][4] = { · 55 unmodified lines
99100 { 0 },
100101 };
101102
103+const char *ff_id3v2_picture_types[21] = {
104+ "Other",
105+ "32x32 pixels 'file icon'",
106+ "Other file icon",
107+ "Cover (front)",
108+ "Cover (back)",
109+ "Leaflet page",
110+ "Media (e.g. label side of CD)",
111+ "Lead artist/lead performer/soloist",
112+ "Artist/performer",
113+ "Conductor",
114+ "Band/Orchestra",
115+ "Composer",
116+ "Lyricist/text writer",
117+ "Recording Location",
118+ "During recording",
119+ "During performance",
120+ "Movie/video screen capture",
121+ "A bright coloured fish",
122+ "Illustration",
123+ "Band/artist logotype",
124+ "Publisher/Studio logotype",
125+};
126+
127+const CodecMime ff_id3v2_mime_tags[] = {
128+ {"image/gif" , CODEC_ID_GIF},
129+ {"image/jpeg", CODEC_ID_MJPEG},
130+ {"image/png" , CODEC_ID_PNG},
131+ {"image/tiff", CODEC_ID_TIFF},
132+ {"", CODEC_ID_NONE},
133+};
134+
102135 int ff_id3v2_match(const uint8_t *buf, const char * magic)
103136 {
104137 return buf[0] == magic[0] &&
@@ -394,6 +427,84 @@ finish: · 289 unmodified lines
394427 av_dict_set(m, "date", date, 0);
395428 }
396429
430+static void free_apic(void *obj)
431+{
432+ ID3v2ExtraMetaAPIC *apic = obj;
433+ av_freep(&apic->data);
434+ av_freep(&apic->description);
435+ av_freep(&apic);
436+}
437+
438+static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, char *tag, ID3v2ExtraMeta **extra_meta)
439+{
440+ int enc, pic_type;
441+ char mimetype[64];
442+ const CodecMime *mime = ff_id3v2_mime_tags;
443+ enum CodecID id = CODEC_ID_NONE;
444+ ID3v2ExtraMetaAPIC *apic = NULL;
445+ ID3v2ExtraMeta *new_extra = NULL;
446+ int64_t end = avio_tell(pb) + taglen;
447+
448+ if (taglen <= 4)
449+ goto fail;
450+
451+ new_extra = av_mallocz(sizeof(*new_extra));
452+ apic = av_mallocz(sizeof(*apic));
453+ if (!new_extra || !apic)
454+ goto fail;
455+
456+ enc = avio_r8(pb);
457+ taglen--;
458+
459+ /* mimetype */
460+ taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype));
461+ while (mime->id != CODEC_ID_NONE) {
462+ if (!strncmp(mime->str, mimetype, sizeof(mimetype))) {
463+ id = mime->id;
464+ break;
465+ }
466+ mime++;
467+ }
468+ if (id == CODEC_ID_NONE) {
469+ av_log(s, AV_LOG_WARNING, "Unknown attached picture mimetype: %s, skipping.\n", mimetype);
470+ goto fail;
471+ }
472+ apic->id = id;
473+
474+ /* picture type */
475+ pic_type = avio_r8(pb);
476+ taglen--;
477+ if (pic_type < 0 || pic_type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types)) {
478+ av_log(s, AV_LOG_WARNING, "Unknown attached picture type %d.\n", pic_type);
479+ pic_type = 0;
480+ }
481+ apic->type = ff_id3v2_picture_types[pic_type];
482+
483+ /* description and picture data */
484+ if (decode_str(s, pb, enc, &apic->description, &taglen) < 0) {
485+ av_log(s, AV_LOG_ERROR, "Error decoding attached picture description.\n");
486+ goto fail;
487+ }
488+
489+ apic->len = taglen;
490+ apic->data = av_malloc(taglen);
491+ if (!apic->data || avio_read(pb, apic->data, taglen) != taglen)
492+ goto fail;
493+
494+ new_extra->tag = "APIC";
495+ new_extra->data = apic;
496+ new_extra->next = *extra_meta;
497+ *extra_meta = new_extra;
498+
499+ return;
500+
501+fail:
502+ if (apic)
503+ free_apic(apic);
504+ av_freep(&new_extra);
505+ avio_seek(pb, end, SEEK_SET);
506+}
507+
397508 typedef struct ID3v2EMFunc {
398509 const char *tag3;
399510 const char *tag4;
@@ -403,6 +514,7 @@ typedef struct ID3v2EMFunc { · 3 unmodified lines
403514
404515 static const ID3v2EMFunc id3v2_extra_meta_funcs[] = {
405516 { "GEO", "GEOB", read_geobtag, free_geobtag },
517+ { "PIC", "APIC", read_apic, free_apic },
406518 { NULL }
407519 };
408520
@@ -620,7 +732,7 @@ seek: · 211 unmodified lines
620732 return;
621733 }
622734
623−void ff_id3v2_read_all(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta)
735+void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta)
624736 {
625737 int len, ret;
626738 uint8_t buf[ID3v2_HEADER_SIZE];
@@ -651,11 +763,6 @@ void ff_id3v2_read_all(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **e · 24 unmodified lines
651763 merge_date(&s->metadata);
652764 }
653765
654−void ff_id3v2_read(AVFormatContext *s, const char *magic)
655−{
656− ff_id3v2_read_all(s, magic, NULL);
657−}
658−
659766 void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
660767 {
661768 ID3v2ExtraMeta *current = *extra_meta, *next;
@@ -669,3 +776,37 @@ void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta) · 7 unmodified lines
669776 current = next;
670777 }
671778 }
779+
780+int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
781+{
782+ ID3v2ExtraMeta *cur;
783+
784+ for (cur = *extra_meta; cur; cur = cur->next) {
785+ ID3v2ExtraMetaAPIC *apic;
786+ AVStream *st;
787+
788+ if (strcmp(cur->tag, "APIC"))
789+ continue;
790+ apic = cur->data;
791+
792+ if (!(st = avformat_new_stream(s, NULL)))
793+ return AVERROR(ENOMEM);
794+
795+ st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
796+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
797+ st->codec->codec_id = apic->id;
798+ av_dict_set(&st->metadata, "title", apic->description, 0);
799+ av_dict_set(&st->metadata, "comment", apic->type, 0);
800+
801+ av_init_packet(&st->attached_pic);
802+ st->attached_pic.data = apic->data;
803+ st->attached_pic.size = apic->len;
804+ st->attached_pic.destruct = av_destruct_packet;
805+ st->attached_pic.stream_index = st->index;
806+
807+ apic->data = NULL;
808+ apic->len = 0;
809+ }
810+
811+ return 0;
812+}
libavformat/id3v2.h+49−8
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424
2525 #include <stdint.h>
2626 #include "avformat.h"
27+#include "internal.h"
2728 #include "metadata.h"
2829
2930 #define ID3v2_HEADER_SIZE 10
@@ -45,6 +46,12 @@ enum ID3v2Encoding { · 15 unmodified lines
4546 ID3v2_ENCODING_UTF8 = 3,
4647 };
4748
49+typedef struct ID3v2EncContext {
50+ int version; ///< ID3v2 minor version, either 3 or 4
51+ int64_t size_pos; ///< offset of the tag total size
52+ int len; ///< size of the tag written so far
53+} ID3v2EncContext;
54+
4855 typedef struct ID3v2ExtraMeta {
4956 const char *tag;
5057 void *data;
@@ -59,6 +66,14 @@ typedef struct ID3v2ExtraMetaGEOB { · 8 unmodified lines
5966 uint8_t *data;
6067 } ID3v2ExtraMetaGEOB;
6168
69+typedef struct ID3v2ExtraMetaAPIC {
70+ uint8_t *data;
71+ int len;
72+ const char *type;
73+ uint8_t *description;
74+ enum CodecID id;
75+} ID3v2ExtraMetaAPIC;
76+
6277 /**
6378 * Detect ID3v2 Header.
6479 * @param buf must be ID3v2_HEADER_SIZE byte long
@@ -75,24 +90,40 @@ int ff_id3v2_match(const uint8_t *buf, const char *magic); · 10 unmodified lines
7590 int ff_id3v2_tag_len(const uint8_t *buf);
7691
7792 /**
78− * Read an ID3v2 tag (text tags only)
93+ * Read an ID3v2 tag, including supported extra metadata
94+ * @param extra_meta If not NULL, extra metadata is parsed into a list of
95+ * ID3v2ExtraMeta structs and *extra_meta points to the head of the list
7996 */
80−void ff_id3v2_read(AVFormatContext *s, const char *magic);
97+void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta);
8198
8299 /**
83− * Read an ID3v2 tag, including supported extra metadata (currently only GEOB)
84− * @param extra_meta If not NULL, extra metadata is parsed into a list of
85− * ID3v2ExtraMeta structs and *extra_meta points to the head of the list
100+ * Initialize an ID3v2 tag.
101+ */
102+void ff_id3v2_start(ID3v2EncContext *id3, AVIOContext *pb, int id3v2_version,
103+ const char *magic);
104+
105+/**
106+ * Convert and write all global metadata from s into an ID3v2 tag.
107+ */
108+int ff_id3v2_write_metadata(AVFormatContext *s, ID3v2EncContext *id3);
109+
110+/**
111+ * Write an attached picture from pkt into an ID3v2 tag.
112+ */
113+int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt);
114+
115+/**
116+ * Finalize an opened ID3v2 tag.
86117 */
87−void ff_id3v2_read_all(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta);
118+void ff_id3v2_finish(ID3v2EncContext *id3, AVIOContext *pb);
88119
89120 /**
90− * Write an ID3v2 tag.
121+ * Write an ID3v2 tag containing all global metadata from s.
91122 * @param id3v2_version Subversion of ID3v2; supported values are 3 and 4
92123 * @param magic magic bytes to identify the header
93124 * If in doubt, use ID3v2_DEFAULT_MAGIC.
94125 */
95−int ff_id3v2_write(struct AVFormatContext *s, int id3v2_version, const char *magic);
126+int ff_id3v2_write_simple(struct AVFormatContext *s, int id3v2_version, const char *magic);
96127
97128 /**
98129 * Free memory allocated parsing special (non-text) metadata.
@@ -100,6 +131,12 @@ int ff_id3v2_write(struct AVFormatContext *s, int id3v2_version, const char *mag · 1 unmodified line
100131 */
101132 void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta);
102133
134+/**
135+ * Create a stream for each APIC (attached picture) extracted from the
136+ * ID3v2 header.
137+ */
138+int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta);
139+
103140 extern const AVMetadataConv ff_id3v2_34_metadata_conv[];
104141 extern const AVMetadataConv ff_id3v2_4_metadata_conv[];
105142
@@ -120,4 +157,8 @@ extern const char ff_id3v2_4_tags[][4]; · 14 unmodified lines
120157 */
121158 extern const char ff_id3v2_3_tags[][4];
122159
160+extern const CodecMime ff_id3v2_mime_tags[];
161+
162+extern const char *ff_id3v2_picture_types[21];
163+
123164 #endif /* AVFORMAT_ID3V2_H */
libavformat/id3v2enc.c+145−47
@@ -19,6 +19,8 @@ · 18 unmodified lines
1919 */
2020
2121 #include <stdint.h>
22+#include <string.h>
23+
2224 #include "libavutil/avstring.h"
2325 #include "libavutil/dict.h"
2426 #include "libavutil/intreadwrite.h"
@@ -26,12 +28,12 @@ · 1 unmodified line
2628 #include "avio.h"
2729 #include "id3v2.h"
2830
29−static void id3v2_put_size(AVFormatContext *s, int size)
31+static void id3v2_put_size(AVIOContext *pb, int size)
3032 {
31− avio_w8(s->pb, size >> 21 & 0x7f);
32− avio_w8(s->pb, size >> 14 & 0x7f);
33− avio_w8(s->pb, size >> 7 & 0x7f);
34− avio_w8(s->pb, size & 0x7f);
33+ avio_w8(pb, size >> 21 & 0x7f);
34+ avio_w8(pb, size >> 14 & 0x7f);
35+ avio_w8(pb, size >> 7 & 0x7f);
36+ avio_w8(pb, size & 0x7f);
3537 }
3638
3739 static int string_is_ascii(const uint8_t *str)
@@ -40,17 +42,30 @@ static int string_is_ascii(const uint8_t *str) · 2 unmodified lines
4042 return !*str;
4143 }
4244
45+static void id3v2_encode_string(AVIOContext *pb, const uint8_t *str,
46+ enum ID3v2Encoding enc)
47+{
48+ int (*put)(AVIOContext*, const char*);
49+
50+ if (enc == ID3v2_ENCODING_UTF16BOM) {
51+ avio_wl16(pb, 0xFEFF); /* BOM */
52+ put = avio_put_str16le;
53+ } else
54+ put = avio_put_str;
55+
56+ put(pb, str);
57+}
58+
4359 /**
4460 * Write a text frame with one (normal frames) or two (TXXX frames) strings
4561 * according to encoding (only UTF-8 or UTF-16+BOM supported).
4662 * @return number of bytes written or a negative error code.
4763 */
48−static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2,
64+static int id3v2_put_ttag(ID3v2EncContext *id3, AVIOContext *avioc, const char *str1, const char *str2,
4965 uint32_t tag, enum ID3v2Encoding enc)
5066 {
5167 int len;
5268 uint8_t *pb;
53− int (*put)(AVIOContext*, const char*);
5469 AVIOContext *dyn_buf;
5570 if (avio_open_dyn_buf(&dyn_buf) < 0)
5671 return AVERROR(ENOMEM);
@@ -62,28 +77,26 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2 · 5 unmodified lines
6277 enc = ID3v2_ENCODING_ISO8859;
6378
6479 avio_w8(dyn_buf, enc);
65− if (enc == ID3v2_ENCODING_UTF16BOM) {
66− avio_wl16(dyn_buf, 0xFEFF); /* BOM */
67− put = avio_put_str16le;
68− } else
69− put = avio_put_str;
70−
71− put(dyn_buf, str1);
80+ id3v2_encode_string(dyn_buf, str1, enc);
7281 if (str2)
73− put(dyn_buf, str2);
82+ id3v2_encode_string(dyn_buf, str2, enc);
7483 len = avio_close_dyn_buf(dyn_buf, &pb);
7584
76− avio_wb32(s->pb, tag);
77− id3v2_put_size(s, len);
78− avio_wb16(s->pb, 0);
79− avio_write(s->pb, pb, len);
85+ avio_wb32(avioc, tag);
86+ /* ID3v2.3 frame size is not synchsafe */
87+ if (id3->version == 3)
88+ avio_wb32(avioc, len);
89+ else
90+ id3v2_put_size(avioc, len);
91+ avio_wb16(avioc, 0);
92+ avio_write(avioc, pb, len);
8093
8194 av_freep(&pb);
8295 return len + ID3v2_HEADER_SIZE;
8396 }
8497
85−static int id3v2_check_write_tag(AVFormatContext *s, AVDictionaryEntry *t, const char table[][4],
86− enum ID3v2Encoding enc)
98+static int id3v2_check_write_tag(ID3v2EncContext *id3, AVIOContext *pb, AVDictionaryEntry *t,
99+ const char table[][4], enum ID3v2Encoding enc)
87100 {
88101 uint32_t tag;
89102 int i;
@@ -93,7 +106,7 @@ static int id3v2_check_write_tag(AVFormatContext *s, AVDictionaryEntry *t, const · 3 unmodified lines
93106 tag = AV_RB32(t->key);
94107 for (i = 0; *table[i]; i++)
95108 if (tag == AV_RB32(table[i]))
96− return id3v2_put_ttag(s, t->value, NULL, tag, enc);
109+ return id3v2_put_ttag(id3, pb, t->value, NULL, tag, enc);
97110 return -1;
98111 }
99112
@@ -135,52 +148,137 @@ static void id3v2_3_metadata_split_date(AVDictionary **pm) · 35 unmodified lines
135148 *pm = dst;
136149 }
137150
138−int ff_id3v2_write(struct AVFormatContext *s, int id3v2_version,
139− const char *magic)
151+void ff_id3v2_start(ID3v2EncContext *id3, AVIOContext *pb, int id3v2_version,
152+ const char *magic)
140153 {
141− int64_t size_pos, cur_pos;
142− AVDictionaryEntry *t = NULL;
154+ id3->version = id3v2_version;
143155
144− int totlen = 0, enc = id3v2_version == 3 ? ID3v2_ENCODING_UTF16BOM :
145− ID3v2_ENCODING_UTF8;
146−
147−
148− avio_wb32(s->pb, MKBETAG(magic[0], magic[1], magic[2], id3v2_version));
149− avio_w8(s->pb, 0);
150− avio_w8(s->pb, 0); /* flags */
156+ avio_wb32(pb, MKBETAG(magic[0], magic[1], magic[2], id3v2_version));
157+ avio_w8(pb, 0);
158+ avio_w8(pb, 0); /* flags */
151159
152160 /* reserve space for size */
153− size_pos = avio_tell(s->pb);
154− avio_wb32(s->pb, 0);
161+ id3->size_pos = avio_tell(pb);
162+ avio_wb32(pb, 0);
163+}
164+
165+int ff_id3v2_write_metadata(AVFormatContext *s, ID3v2EncContext *id3)
166+{
167+ AVDictionaryEntry *t = NULL;
168+ int enc = id3->version == 3 ? ID3v2_ENCODING_UTF16BOM :
169+ ID3v2_ENCODING_UTF8;
155170
156171 ff_metadata_conv(&s->metadata, ff_id3v2_34_metadata_conv, NULL);
157− if (id3v2_version == 3)
172+ if (id3->version == 3)
158173 id3v2_3_metadata_split_date(&s->metadata);
159− else if (id3v2_version == 4)
174+ else if (id3->version == 4)
160175 ff_metadata_conv(&s->metadata, ff_id3v2_4_metadata_conv, NULL);
161176
162177 while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
163178 int ret;
164179
165− if ((ret = id3v2_check_write_tag(s, t, ff_id3v2_tags, enc)) > 0) {
166− totlen += ret;
180+ if ((ret = id3v2_check_write_tag(id3, s->pb, t, ff_id3v2_tags, enc)) > 0) {
181+ id3->len += ret;
167182 continue;
168183 }
169− if ((ret = id3v2_check_write_tag(s, t, id3v2_version == 3 ?
184+ if ((ret = id3v2_check_write_tag(id3, s->pb, t, id3->version == 3 ?
170185 ff_id3v2_3_tags : ff_id3v2_4_tags, enc)) > 0) {
171− totlen += ret;
186+ id3->len += ret;
172187 continue;
173188 }
174189
175190 /* unknown tag, write as TXXX frame */
176− if ((ret = id3v2_put_ttag(s, t->key, t->value, MKBETAG('T', 'X', 'X', 'X'), enc)) < 0)
191+ if ((ret = id3v2_put_ttag(id3, s->pb, t->key, t->value, MKBETAG('T', 'X', 'X', 'X'), enc)) < 0)
177192 return ret;
178− totlen += ret;
193+ id3->len += ret;
179194 }
180195
181− cur_pos = avio_tell(s->pb);
182− avio_seek(s->pb, size_pos, SEEK_SET);
183− id3v2_put_size(s, totlen);
184− avio_seek(s->pb, cur_pos, SEEK_SET);
196+ return 0;
197+}
198+
199+int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
200+{
201+ AVStream *st = s->streams[pkt->stream_index];
202+ AVDictionaryEntry *e;
203+
204+ AVIOContext *dyn_buf;
205+ uint8_t *buf;
206+ const CodecMime *mime = ff_id3v2_mime_tags;
207+ const char *mimetype = NULL, *desc = "";
208+ int enc = id3->version == 3 ? ID3v2_ENCODING_UTF16BOM :
209+ ID3v2_ENCODING_UTF8;
210+ int i, len, type = 0;
211+
212+ /* get the mimetype*/
213+ while (mime->id != CODEC_ID_NONE) {
214+ if (mime->id == st->codec->codec_id) {
215+ mimetype = mime->str;
216+ break;
217+ }
218+ mime++;
219+ }
220+ if (!mimetype) {
221+ av_log(s, AV_LOG_ERROR, "No mimetype is known for stream %d, cannot "
222+ "write an attached picture.\n", st->index);
223+ return AVERROR(EINVAL);
224+ }
225+
226+ /* get the picture type */
227+ e = av_dict_get(st->metadata, "comment", NULL, 0);
228+ for (i = 0; e && i < FF_ARRAY_ELEMS(ff_id3v2_picture_types); i++) {
229+ if (strstr(ff_id3v2_picture_types[i], e->value) == ff_id3v2_picture_types[i]) {
230+ type = i;
231+ break;
232+ }
233+ }
234+
235+ /* get the description */
236+ if ((e = av_dict_get(st->metadata, "title", NULL, 0)))
237+ desc = e->value;
238+
239+ /* start writing */
240+ if (avio_open_dyn_buf(&dyn_buf) < 0)
241+ return AVERROR(ENOMEM);
242+
243+ avio_w8(dyn_buf, enc);
244+ avio_put_str(dyn_buf, mimetype);
245+ avio_w8(dyn_buf, type);
246+ id3v2_encode_string(dyn_buf, desc, enc);
247+ avio_write(dyn_buf, pkt->data, pkt->size);
248+ len = avio_close_dyn_buf(dyn_buf, &buf);
249+
250+ avio_wb32(s->pb, MKBETAG('A', 'P', 'I', 'C'));
251+ if (id3->version == 3)
252+ avio_wb32(s->pb, len);
253+ else
254+ id3v2_put_size(s->pb, len);
255+ avio_wb16(s->pb, 0);
256+ avio_write(s->pb, buf, len);
257+ av_freep(&buf);
258+
259+ id3->len += len + ID3v2_HEADER_SIZE;
260+
261+ return 0;
262+}
263+
264+void ff_id3v2_finish(ID3v2EncContext *id3, AVIOContext *pb)
265+{
266+ int64_t cur_pos = avio_tell(pb);
267+ avio_seek(pb, id3->size_pos, SEEK_SET);
268+ id3v2_put_size(pb, id3->len);
269+ avio_seek(pb, cur_pos, SEEK_SET);
270+}
271+
272+int ff_id3v2_write_simple(struct AVFormatContext *s, int id3v2_version,
273+ const char *magic)
274+{
275+ ID3v2EncContext id3 = { 0 };
276+ int ret;
277+
278+ ff_id3v2_start(&id3, s->pb, id3v2_version, magic);
279+ if ((ret = ff_id3v2_write_metadata(s, &id3)) < 0)
280+ return ret;
281+ ff_id3v2_finish(&id3, s->pb);
282+
185283 return 0;
186284 }
libavformat/internal.h+5−0
@@ -37,6 +37,11 @@ typedef struct AVCodecTag { · 36 unmodified lines
3737 unsigned int tag;
3838 } AVCodecTag;
3939
40+typedef struct CodecMime{
41+ char str[32];
42+ enum CodecID id;
43+} CodecMime;
44+
4045 #ifdef __GNUC__
4146 #define dynarray_add(tab, nb_ptr, elem)\
4247 do {\
libavformat/matroska.h+1−5
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424
2525 #include "libavcodec/avcodec.h"
2626 #include "metadata.h"
27+#include "internal.h"
2728
2829 /* EBML version supported */
2930 #define EBML_VERSION 1
@@ -250,11 +251,6 @@ typedef struct CodecTags{ · 220 unmodified lines
250251 enum CodecID id;
251252 }CodecTags;
252253
253−typedef struct CodecMime{
254− char str[32];
255− enum CodecID id;
256−}CodecMime;
257−
258254 /* max. depth in the EBML tree structure */
259255 #define EBML_MAX_DEPTH 16
260256
libavformat/mov.c+4−3
@@ -1223,6 +1223,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) · 1222 unmodified lines
12231223 if (st->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
12241224 unsigned int color_depth, len;
12251225 int color_greyscale;
1226+ int color_table_id;
12261227
12271228 st->codec->codec_id = id;
12281229 avio_rb16(pb); /* version */
@@ -1250,9 +1251,9 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) · 21 unmodified lines
12501251 st->codec->codec_tag=MKTAG('I', '4', '2', '0');
12511252
12521253 st->codec->bits_per_coded_sample = avio_rb16(pb); /* depth */
1253− st->codec->color_table_id = avio_rb16(pb); /* colortable id */
1254+ color_table_id = avio_rb16(pb); /* colortable id */
12541255 av_dlog(c->fc, "depth %d, ctab id %d\n",
1255− st->codec->bits_per_coded_sample, st->codec->color_table_id);
1256+ st->codec->bits_per_coded_sample, color_table_id);
12561257 /* figure out the palette situation */
12571258 color_depth = st->codec->bits_per_coded_sample & 0x1F;
12581259 color_greyscale = st->codec->bits_per_coded_sample & 0x20;
@@ -1282,7 +1283,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) · 23 unmodified lines
12821283 if (color_index < 0)
12831284 color_index = 0;
12841285 }
1285− } else if (st->codec->color_table_id) {
1286+ } else if (color_table_id) {
12861287 const uint8_t *color_table;
12871288 /* if flag bit 3 is set, use the default palette */
12881289 color_count = 1 << color_depth;
libavformat/mp3enc.c+183−74
@@ -84,6 +84,7 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf) · 83 unmodified lines
8484
8585 typedef struct MP3Context {
8686 const AVClass *class;
87+ ID3v2EncContext id3;
8788 int id3v2_version;
8889 int write_id3v1;
8990 int64_t frames_offset;
@@ -93,60 +94,15 @@ typedef struct MP3Context { · 3 unmodified lines
9394 uint32_t seen;
9495 uint32_t pos;
9596 uint64_t bag[VBR_NUM_BAGS];
96−} MP3Context;
97−
98−static int mp2_write_trailer(struct AVFormatContext *s)
99−{
100− uint8_t buf[ID3v1_TAG_SIZE];
101− MP3Context *mp3 = s->priv_data;
102−
103− /* write the id3v1 tag */
104− if (mp3 && mp3->write_id3v1 && id3v1_create_tag(s, buf) > 0) {
105− avio_write(s->pb, buf, ID3v1_TAG_SIZE);
106− }
10797
108− /* write number of frames */
109− if (mp3 && mp3->frames_offset) {
110− avio_seek(s->pb, mp3->frames_offset, SEEK_SET);
111− avio_wb32(s->pb, s->streams[0]->nb_frames);
112− avio_seek(s->pb, 0, SEEK_END);
113− }
114−
115− avio_flush(s->pb);
116−
117− return 0;
118−}
119−
120−#if CONFIG_MP2_MUXER
121−AVOutputFormat ff_mp2_muxer = {
122− .name = "mp2",
123− .long_name = NULL_IF_CONFIG_SMALL("MPEG audio layer 2"),
124− .mime_type = "audio/x-mpeg",
125− .extensions = "mp2,m2a",
126− .audio_codec = CODEC_ID_MP2,
127− .video_codec = CODEC_ID_NONE,
128− .write_packet = ff_raw_write_packet,
129− .write_trailer = mp2_write_trailer,
130− .flags = AVFMT_NOTIMESTAMPS,
131−};
132−#endif
133−
134−#if CONFIG_MP3_MUXER
135−
136−static const AVOption options[] = {
137− { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.",
138− offsetof(MP3Context, id3v2_version), AV_OPT_TYPE_INT, {.dbl = 4}, 3, 4, AV_OPT_FLAG_ENCODING_PARAM},
139− { "write_id3v1", "Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.",
140− offsetof(MP3Context, write_id3v1), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
141− { NULL },
142−};
98+ /* index of the audio stream */
99+ int audio_stream_idx;
100+ /* number of attached pictures we still need to write */
101+ int pics_to_write;
143102
144−static const AVClass mp3_muxer_class = {
145− .class_name = "MP3 muxer",
146− .item_name = av_default_item_name,
147− .option = options,
148− .version = LIBAVUTIL_VERSION_INT,
149−};
103+ /* audio packets are queued here until we get all the attached pictures */
104+ AVPacketList *queue, *queue_end;
105+} MP3Context;
150106
151107 static const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
152108
@@ -155,8 +111,8 @@ static const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}}; · 2 unmodified lines
155111 */
156112 static int mp3_write_xing(AVFormatContext *s)
157113 {
158− AVCodecContext *codec = s->streams[0]->codec;
159114 MP3Context *mp3 = s->priv_data;
115+ AVCodecContext *codec = s->streams[mp3->audio_stream_idx]->codec;
160116 int bitrate_idx;
161117 int best_bitrate_idx = -1;
162118 int best_bitrate_error= INT_MAX;
@@ -166,6 +122,9 @@ static int mp3_write_xing(AVFormatContext *s) · 3 unmodified lines
166122 int srate_idx, i, channels;
167123 int needed;
168124
125+ if (!s->pb->seekable)
126+ return 0;
127+
169128 for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++)
170129 if (avpriv_mpa_freq_tab[i] == codec->sample_rate) {
171130 srate_idx = i;
@@ -295,26 +254,7 @@ static void mp3_fix_xing(AVFormatContext *s) · 123 unmodified lines
295254 avio_seek(s->pb, 0, SEEK_END);
296255 }
297256
298−/**
299− * Write an ID3v2 header at beginning of stream
300− */
301−
302−static int mp3_write_header(struct AVFormatContext *s)
303−{
304− MP3Context *mp3 = s->priv_data;
305− int ret;
306−
307− ret = ff_id3v2_write(s, mp3->id3v2_version, ID3v2_DEFAULT_MAGIC);
308− if (ret < 0)
309− return ret;
310−
311− if (s->pb->seekable)
312− mp3_write_xing(s);
313−
314− return 0;
315−}
316−
317−static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
257+static int mp3_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
318258 {
319259 if (! pkt || ! pkt->data || pkt->size < 4)
320260 return ff_raw_write_packet(s, pkt);
@@ -350,6 +290,175 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt) · 29 unmodified lines
350290 }
351291 }
352292
293+static int mp3_queue_flush(AVFormatContext *s)
294+{
295+ MP3Context *mp3 = s->priv_data;
296+ AVPacketList *pktl;
297+ int ret = 0, write = 1;
298+
299+ ff_id3v2_finish(&mp3->id3, s->pb);
300+ mp3_write_xing(s);
301+
302+ while ((pktl = mp3->queue)) {
303+ if (write && (ret = mp3_write_packet_internal(s, &pktl->pkt)) < 0)
304+ write = 0;
305+ av_free_packet(&pktl->pkt);
306+ mp3->queue = pktl->next;
307+ av_freep(&pktl);
308+ }
309+ mp3->queue_end = NULL;
310+ return ret;
311+}
312+
313+static int mp2_write_trailer(struct AVFormatContext *s)
314+{
315+ uint8_t buf[ID3v1_TAG_SIZE];
316+ MP3Context *mp3 = s->priv_data;
317+
318+ if (mp3 && mp3->pics_to_write) {
319+ av_log(s, AV_LOG_WARNING, "No packets were sent for some of the "
320+ "attached pictures.\n");
321+ mp3_queue_flush(s);
322+ }
323+
324+ /* write the id3v1 tag */
325+ if (mp3 && mp3->write_id3v1 && id3v1_create_tag(s, buf) > 0) {
326+ avio_write(s->pb, buf, ID3v1_TAG_SIZE);
327+ }
328+
329+ /* write number of frames */
330+ if (mp3 && mp3->frames_offset) {
331+ avio_seek(s->pb, mp3->frames_offset, SEEK_SET);
332+ avio_wb32(s->pb, s->streams[mp3->audio_stream_idx]->nb_frames);
333+ avio_seek(s->pb, 0, SEEK_END);
334+ }
335+
336+ avio_flush(s->pb);
337+
338+ return 0;
339+}
340+
341+#if CONFIG_MP2_MUXER
342+AVOutputFormat ff_mp2_muxer = {
343+ .name = "mp2",
344+ .long_name = NULL_IF_CONFIG_SMALL("MPEG audio layer 2"),
345+ .mime_type = "audio/x-mpeg",
346+ .extensions = "mp2,m2a",
347+ .audio_codec = CODEC_ID_MP2,
348+ .video_codec = CODEC_ID_NONE,
349+ .write_packet = ff_raw_write_packet,
350+ .write_trailer = mp2_write_trailer,
351+ .flags = AVFMT_NOTIMESTAMPS,
352+};
353+#endif
354+
355+#if CONFIG_MP3_MUXER
356+
357+static const AVOption options[] = {
358+ { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.",
359+ offsetof(MP3Context, id3v2_version), AV_OPT_TYPE_INT, {.dbl = 4}, 3, 4, AV_OPT_FLAG_ENCODING_PARAM},
360+ { "write_id3v1", "Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.",
361+ offsetof(MP3Context, write_id3v1), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
362+ { NULL },
363+};
364+
365+static const AVClass mp3_muxer_class = {
366+ .class_name = "MP3 muxer",
367+ .item_name = av_default_item_name,
368+ .option = options,
369+ .version = LIBAVUTIL_VERSION_INT,
370+};
371+
372+static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
373+{
374+ MP3Context *mp3 = s->priv_data;
375+
376+ if (pkt->stream_index == mp3->audio_stream_idx) {
377+ if (mp3->pics_to_write) {
378+ /* buffer audio packets until we get all the pictures */
379+ AVPacketList *pktl = av_mallocz(sizeof(*pktl));
380+ if (!pktl)
381+ return AVERROR(ENOMEM);
382+
383+ pktl->pkt = *pkt;
384+ pkt->destruct = NULL;
385+
386+ if (mp3->queue_end)
387+ mp3->queue_end->next = pktl;
388+ else
389+ mp3->queue = pktl;
390+ mp3->queue_end = pktl;
391+ } else
392+ return mp3_write_packet_internal(s, pkt);
393+ } else {
394+ int ret;
395+
396+ /* warn only once for each stream */
397+ if (s->streams[pkt->stream_index]->nb_frames == 1) {
398+ av_log(s, AV_LOG_WARNING, "Got more than one picture in stream %d,"
399+ " ignoring.\n", pkt->stream_index);
400+ }
401+ if (!mp3->pics_to_write || s->streams[pkt->stream_index]->nb_frames >= 1)
402+ return 0;
403+
404+ if ((ret = ff_id3v2_write_apic(s, &mp3->id3, pkt)) < 0)
405+ return ret;
406+ mp3->pics_to_write--;
407+
408+ /* flush the buffered audio packets */
409+ if (!mp3->pics_to_write &&
410+ (ret = mp3_queue_flush(s)) < 0)
411+ return ret;
412+ }
413+
414+ return 0;
415+}
416+
417+/**
418+ * Write an ID3v2 header at beginning of stream
419+ */
420+
421+static int mp3_write_header(struct AVFormatContext *s)
422+{
423+ MP3Context *mp3 = s->priv_data;
424+ int ret, i;
425+
426+ /* check the streams -- we want exactly one audio and arbitrary number of
427+ * video (attached pictures) */
428+ mp3->audio_stream_idx = -1;
429+ for (i = 0; i < s->nb_streams; i++) {
430+ AVStream *st = s->streams[i];
431+ if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
432+ if (mp3->audio_stream_idx >= 0 || st->codec->codec_id != CODEC_ID_MP3) {
433+ av_log(s, AV_LOG_ERROR, "Invalid audio stream. Exactly one MP3 "
434+ "audio stream is required.\n");
435+ return AVERROR(EINVAL);
436+ }
437+ mp3->audio_stream_idx = i;
438+ } else if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO) {
439+ av_log(s, AV_LOG_ERROR, "Only audio streams and pictures are allowed in MP3.\n");
440+ return AVERROR(EINVAL);
441+ }
442+ }
443+ if (mp3->audio_stream_idx < 0) {
444+ av_log(s, AV_LOG_ERROR, "No audio stream present.\n");
445+ return AVERROR(EINVAL);
446+ }
447+ mp3->pics_to_write = s->nb_streams - 1;
448+
449+ ff_id3v2_start(&mp3->id3, s->pb, mp3->id3v2_version, ID3v2_DEFAULT_MAGIC);
450+ ret = ff_id3v2_write_metadata(s, &mp3->id3);
451+ if (ret < 0)
452+ return ret;
453+
454+ if (!mp3->pics_to_write) {
455+ ff_id3v2_finish(&mp3->id3, s->pb);
456+ mp3_write_xing(s);
457+ }
458+
459+ return 0;
460+}
461+
353462 static int mp3_write_trailer(AVFormatContext *s)
354463 {
355464 MP3Context *mp3 = s->priv_data;
@@ -371,7 +480,7 @@ AVOutputFormat ff_mp3_muxer = { · 15 unmodified lines
371480 .extensions = "mp3",
372481 .priv_data_size = sizeof(MP3Context),
373482 .audio_codec = CODEC_ID_MP3,
374− .video_codec = CODEC_ID_NONE,
483+ .video_codec = CODEC_ID_PNG,
375484 .write_header = mp3_write_header,
376485 .write_packet = mp3_write_packet,
377486 .write_trailer = mp3_write_trailer,
libavformat/omadec.c+1−1
@@ -270,7 +270,7 @@ static int oma_read_header(AVFormatContext *s) · 269 unmodified lines
270270 ID3v2ExtraMeta *extra_meta = NULL;
271271 OMAContext *oc = s->priv_data;
272272
273− ff_id3v2_read_all(s, ID3v2_EA3_MAGIC, &extra_meta);
273+ ff_id3v2_read(s, ID3v2_EA3_MAGIC, &extra_meta);
274274 ret = avio_read(s->pb, buf, EA3_HEADER_SIZE);
275275 if (ret < EA3_HEADER_SIZE)
276276 return -1;
libavformat/omaenc.c+1−1
@@ -49,7 +49,7 @@ static av_cold int oma_write_header(AVFormatContext *s) · 48 unmodified lines
4949 }
5050
5151 /* Metadata; OpenMG does not support ID3v2.4 */
52− ff_id3v2_write(s, 3, ID3v2_EA3_MAGIC);
52+ ff_id3v2_write_simple(s, 3, ID3v2_EA3_MAGIC);
5353
5454 ffio_wfourcc(s->pb, "EA3\0");
5555 avio_w8(s->pb, EA3_HEADER_SIZE >> 7);
libavformat/psxstr.c+1−0
@@ -299,4 +299,5 @@ AVInputFormat ff_str_demuxer = { · 298 unmodified lines
299299 .read_header = str_read_header,
300300 .read_packet = str_read_packet,
301301 .read_close = str_read_close,
302+ .flags = AVFMT_NO_BYTE_SEEK,
302303 };
libavformat/rtpenc.c+1−1
@@ -112,7 +112,7 @@ static int rtp_write_header(AVFormatContext *s1) · 111 unmodified lines
112112
113113 if (s->max_packet_size) {
114114 if (s1->pb->max_packet_size)
115− s->max_packet_size = FFMIN(s->max_payload_size,
115+ s->max_packet_size = FFMIN(s->max_packet_size,
116116 s1->pb->max_packet_size);
117117 } else
118118 s->max_packet_size = s1->pb->max_packet_size;
libavformat/swfdec.c+0−2
@@ -113,7 +113,6 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) · 112 unmodified lines
113113 vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
114114 vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, avio_r8(pb));
115115 avpriv_set_pts_info(vst, 16, 256, swf->frame_rate);
116− vst->codec->time_base = (AVRational){ 256, swf->frame_rate };
117116 len -= 8;
118117 } else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) {
119118 /* streaming found */
@@ -186,7 +185,6 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) · 66 unmodified lines
186185 vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
187186 vst->codec->codec_id = CODEC_ID_MJPEG;
188187 avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);
189− vst->codec->time_base = (AVRational){ 256, swf->frame_rate };
190188 st = vst;
191189 }
192190 avio_rl16(pb); /* BITMAP_ID */
libavformat/utils.c+36−19
@@ -545,11 +545,29 @@ static int init_input(AVFormatContext *s, const char *filename, AVDictionary **o · 544 unmodified lines
545545 return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0);
546546 }
547547
548+static AVPacket *add_to_pktbuf(AVPacketList **packet_buffer, AVPacket *pkt,
549+ AVPacketList **plast_pktl){
550+ AVPacketList *pktl = av_mallocz(sizeof(AVPacketList));
551+ if (!pktl)
552+ return NULL;
553+
554+ if (*packet_buffer)
555+ (*plast_pktl)->next = pktl;
556+ else
557+ *packet_buffer = pktl;
558+
559+ /* add the packet in the buffered packet list */
560+ *plast_pktl = pktl;
561+ pktl->pkt= *pkt;
562+ return &pktl->pkt;
563+}
564+
548565 int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
549566 {
550567 AVFormatContext *s = *ps;
551− int ret = 0;
568+ int i, ret = 0;
552569 AVDictionary *tmp = NULL;
570+ ID3v2ExtraMeta *id3v2_extra_meta = NULL;
553571
554572 if (!s && !(s = avformat_alloc_context()))
555573 return AVERROR(ENOMEM);
@@ -592,12 +610,25 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma · 36 unmodified lines
592610
593611 /* e.g. AVFMT_NOFILE formats will not have a AVIOContext */
594612 if (s->pb)
595− ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC);
613+ ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
596614
597615 if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
598616 if ((ret = s->iformat->read_header(s)) < 0)
599617 goto fail;
600618
619+ if (id3v2_extra_meta &&
620+ (ret = ff_id3v2_parse_apic(s, &id3v2_extra_meta)) < 0)
621+ goto fail;
622+ ff_id3v2_free_extra_meta(&id3v2_extra_meta);
623+
624+ /* queue attached pictures */
625+ for (i = 0; i < s->nb_streams; i++)
626+ if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC) {
627+ AVPacket copy = s->streams[i]->attached_pic;
628+ copy.destruct = NULL;
629+ add_to_pktbuf(&s->raw_packet_buffer, &copy, &s->raw_packet_buffer_end);
630+ }
631+
601632 if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->data_offset)
602633 s->data_offset = avio_tell(s->pb);
603634
@@ -611,6 +642,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma · 7 unmodified lines
611642 return 0;
612643
613644 fail:
645+ ff_id3v2_free_extra_meta(&id3v2_extra_meta);
614646 av_dict_free(&tmp);
615647 if (s->pb && !(s->flags & AVFMT_FLAG_CUSTOM_IO))
616648 avio_close(s->pb);
@@ -621,23 +653,6 @@ fail: · 4 unmodified lines
621653
622654 /*******************************************************/
623655
624−static AVPacket *add_to_pktbuf(AVPacketList **packet_buffer, AVPacket *pkt,
625− AVPacketList **plast_pktl){
626− AVPacketList *pktl = av_mallocz(sizeof(AVPacketList));
627− if (!pktl)
628− return NULL;
629−
630− if (*packet_buffer)
631− (*plast_pktl)->next = pktl;
632− else
633− *packet_buffer = pktl;
634−
635− /* add the packet in the buffered packet list */
636− *plast_pktl = pktl;
637− pktl->pkt= *pkt;
638− return &pktl->pkt;
639−}
640−
641656 int av_read_packet(AVFormatContext *s, AVPacket *pkt)
642657 {
643658 int ret, i;
@@ -2722,6 +2737,8 @@ void avformat_free_context(AVFormatContext *s) · 2078 unmodified lines
27222737 av_parser_close(st->parser);
27232738 av_free_packet(&st->cur_pkt);
27242739 }
2740+ if (st->attached_pic.data)
2741+ av_free_packet(&st->attached_pic);
27252742 av_dict_free(&st->metadata);
27262743 av_freep(&st->index_entries);
27272744 av_freep(&st->codec->extradata);
libavformat/version.h+1−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #include "libavutil/avutil.h"
3131
3232 #define LIBAVFORMAT_VERSION_MAJOR 54
33−#define LIBAVFORMAT_VERSION_MINOR 1
33+#define LIBAVFORMAT_VERSION_MINOR 2
3434 #define LIBAVFORMAT_VERSION_MICRO 100
3535
3636 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
libavformat/vqf.c+3−3
@@ -220,12 +220,12 @@ static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt) · 219 unmodified lines
220220 int ret;
221221 int size = (c->frame_bit_len - c->remaining_bits + 7)>>3;
222222
223− pkt->pos = avio_tell(s->pb);
224− pkt->stream_index = 0;
225−
226223 if (av_new_packet(pkt, size+2) < 0)
227224 return AVERROR(EIO);
228225
226+ pkt->pos = avio_tell(s->pb);
227+ pkt->stream_index = 0;
228+
229229 pkt->data[0] = 8 - c->remaining_bits; // Number of bits to skip
230230 pkt->data[1] = c->last_frame_bits;
231231 ret = avio_read(s->pb, pkt->data+2, size);
libswscale/utils.c+1−1
@@ -1046,7 +1046,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) · 1045 unmodified lines
10461046 c->vLumBufSize= c->vLumFilterSize;
10471047 c->vChrBufSize= c->vChrFilterSize;
10481048 for (i=0; i<dstH; i++) {
1049− int chrI= (int64_t)i*c->chrDstH / dstH;
1049+ int chrI = (int64_t) i * c->chrDstH / dstH;
10501050 int nextSlice= FFMAX(c->vLumFilterPos[i ] + c->vLumFilterSize - 1,
10511051 ((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1)<<c->chrSrcVSubSample));
10521052
tests/codec-regression.sh+3−3
@@ -38,13 +38,13 @@ fi · 37 unmodified lines
3838
3939 if [ -n "$do_mpeg2_ivlc_qprd" ]; then
4040 # mpeg2 encoding intra vlc qprd
41−do_video_encoding mpeg2ivlc-qprd.mpg "-vb 500k -bf 2 -trellis 1 -flags +qprd+mv0 -intra_vlc 1 -cmp 2 -subcmp 2 -mbd rd -vcodec mpeg2video -f mpeg2video"
41+do_video_encoding mpeg2ivlc-qprd.mpg "-vb 500k -bf 2 -trellis 1 -flags +mv0 -mpv_flags +qp_rd -intra_vlc 1 -cmp 2 -subcmp 2 -mbd rd -vcodec mpeg2video -f mpeg2video"
4242 do_video_decoding
4343 fi
4444
4545 if [ -n "$do_mpeg2_422" ]; then
4646 #mpeg2 4:2:2 encoding
47−do_video_encoding mpeg2_422.mpg "-vb 1000k -bf 2 -trellis 1 -flags +qprd+mv0+ildct+ilme -intra_vlc 1 -mbd rd -vcodec mpeg2video -pix_fmt yuv422p -f mpeg2video"
47+do_video_encoding mpeg2_422.mpg "-vb 1000k -bf 2 -trellis 1 -flags +mv0+ildct+ilme -mpv_flags +qp_rd -intra_vlc 1 -mbd rd -vcodec mpeg2video -pix_fmt yuv422p -f mpeg2video"
4848 do_video_decoding
4949 fi
5050
@@ -143,7 +143,7 @@ do_video_decoding · 92 unmodified lines
143143 fi
144144
145145 if [ -n "$do_mpeg4_qprd" ]; then
146−do_video_encoding mpeg4-qprd.avi "-b 450k -bf 2 -trellis 1 -flags +mv4+qprd+mv0 -cmp 2 -subcmp 2 -mbd rd -an -vcodec mpeg4"
146+do_video_encoding mpeg4-qprd.avi "-b 450k -bf 2 -trellis 1 -flags +mv4+mv0 -mpv_flags +qp_rd -cmp 2 -subcmp 2 -mbd rd -an -vcodec mpeg4"
147147 do_video_decoding
148148 fi
149149
tests/fate/cdxl.mak+3−0
@@ -10,5 +10,8 @@ fate-cdxl-pal8: CMD = framecrc -i $(SAMPLES)/cdxl/maku.cdxl -pix_fmt rgb24 -fram · 9 unmodified lines
1010 FATE_CDXL += fate-cdxl-pal8-small
1111 fate-cdxl-pal8-small: CMD = framecrc -i $(SAMPLES)/cdxl/fruit.cdxl -an -pix_fmt rgb24 -frames:v 46
1212
13+FATE_CDXL += fate-cdxl-bitline-ham6
14+fate-cdxl-bitline-ham6: CMD = framecrc -i $(SAMPLES)/cdxl/bitline.cdxl -frames:v 10
15+
1316 FATE_TESTS += $(FATE_CDXL)
1417 fate-cdxl: $(FATE_CDXL)
tests/fate/mp3.mak+5−0
@@ -33,6 +33,11 @@ fate-mp3-float-conf-si_block: CMD = pcm -acodec mp3float -i $(SAMPLES)/mp3-confo · 32 unmodified lines
3333 fate-mp3-float-conf-si_block: CMP = stddev
3434 fate-mp3-float-conf-si_block: REF = $(SAMPLES)/mp3-conformance/si_block.pcm
3535
36+FATE_MP3 += fate-mp3-float-extra_overread
37+fate-mp3-float-extra_overread: CMD = pcm -c:a mp3float -i $(SAMPLES)/mpegaudio/extra_overread.mp3
38+fate-mp3-float-extra_overread: CMP = stddev
39+fate-mp3-float-extra_overread: REF = $(SAMPLES)/mpegaudio/extra_overread.pcm
40+
3641 FATE_TESTS += $(FATE_MP3)
3742 fate-mp3: $(FATE_MP3)
3843 $(FATE_MP3): CMP = stddev
tests/fate/video.mak+1−1
@@ -143,7 +143,7 @@ FATE_VIDEO += fate-mpeg2-field-enc · 142 unmodified lines
143143 fate-mpeg2-field-enc: CMD = framecrc -flags +bitexact -dct fastint -idct simple -i $(SAMPLES)/mpeg2/mpeg2_field_encoding.ts -an
144144
145145 FATE_VIDEO += fate-nuv
146−fate-nuv: CMD = framecrc -idct simple -i $(SAMPLES)/nuv/Today.nuv
146+fate-nuv: CMD = framecrc -idct simple -i $(SAMPLES)/nuv/Today.nuv -an
147147
148148 FATE_VIDEO += fate-qpeg
149149 fate-qpeg: CMD = framecrc -i $(SAMPLES)/qpeg/Clock.avi -an -pix_fmt rgb24
tests/ref/fate/cdxl-bitline-ham6+11−0
@@ -0,0 +1,11 @@
1+#tb 0: 12/601
2+0, 0, 0, 1, 63180, 0xcda82c16
3+0, 1, 1, 1, 63180, 0xa6097bf9
4+0, 2, 2, 1, 63180, 0x4c2fb091
5+0, 3, 3, 1, 63180, 0xc597db00
6+0, 4, 4, 1, 63180, 0xfa581ccd
7+0, 5, 5, 1, 63180, 0x3e51498f
8+0, 6, 6, 1, 63180, 0xe3495396
9+0, 7, 7, 1, 63180, 0x425f5f02
10+0, 8, 8, 1, 63180, 0x6077465f
11+0, 9, 9, 1, 63180, 0x923ba29c
tests/ref/fate/nuv+0−19
@@ -1,29 +1,10 @@
11 #tb 0: 100/2997
2−#tb 1: 1/44100
3−1, 0, 0, 1024, 4096, 0x00000000
4−1, 1024, 1024, 1024, 4096, 0x4dfae7a6
5−1, 2048, 2048, 1024, 4096, 0x3fd9f5c6
6−1, 3072, 3072, 1024, 4096, 0x7b86e310
7−1, 4096, 4096, 1024, 4096, 0x611cece5
8−1, 5120, 5120, 1024, 4096, 0xb7d8e872
92 0, 4, 4, 1, 460800, 0x54aedafe
10−1, 6144, 6144, 1024, 4096, 0x072ef72b
11−1, 7168, 7168, 1024, 4096, 0xb3560144
123 0, 5, 5, 1, 460800, 0xb7aa8b56
13−1, 8192, 8192, 1024, 4096, 0x0a3d119e
144 0, 6, 6, 1, 460800, 0x283ea3b5
15−1, 9216, 9216, 1024, 4096, 0xbe391aa4
16−1, 10240, 10240, 1024, 4096, 0x28f7c6e5
175 0, 7, 7, 1, 460800, 0x283ea3b5
18−1, 11264, 11264, 1024, 4096, 0xca9d9df2
196 0, 8, 8, 1, 460800, 0x10e577de
20−1, 12288, 12288, 1024, 4096, 0x5c6b95a9
217 0, 9, 9, 1, 460800, 0x4e091ee2
22−1, 13312, 13312, 1024, 4096, 0x0bdfc0bf
23−1, 14336, 14336, 1024, 4096, 0xd95a9277
248 0, 10, 10, 1, 460800, 0x2ea88828
25−1, 15360, 15360, 1024, 4096, 0xae2bef2c
269 0, 11, 11, 1, 460800, 0x4b7f4df0
27−1, 16384, 16384, 1024, 4096, 0xbf031e83
28−1, 17408, 17408, 1024, 4096, 0x4c83e2d1
2910 0, 12, 12, 1, 460800, 0xa57f20d0
tests/ref/lavf/ffm+1−1
@@ -1,3 +1,3 @@
1−4ef091d638bb20b8eaef5b3a0d6f97b7 *./tests/data/lavf/lavf.ffm
1+8ce2ea9a73a1187647df7bf3c8e1b8fd *./tests/data/lavf/lavf.ffm
22 376832 ./tests/data/lavf/lavf.ffm
33 ./tests/data/lavf/lavf.ffm CRC=0xf361ed74
tests/ref/vsynth1/prores_kostya+1−1
@@ -1,4 +1,4 @@
1−40e7637e04991dbe9a23fe109f95bfc8 *./tests/data/vsynth1/prores_kostya.mov
1+f8fe98b7f9bb66857c81dbca409a9037 *./tests/data/vsynth1/prores_kostya.mov
22 3858901 ./tests/data/vsynth1/prores_kostya.mov
33 0a4153637d0cc0a88a8bcbf04cfaf8c6 *./tests/data/prores_kostya.vsynth1.out.yuv
44 stddev: 3.17 PSNR: 38.09 MAXDIFF: 39 bytes: 7603200/ 7603200
tests/ref/vsynth2/prores_kostya+1−1
@@ -1,4 +1,4 @@
1−ed8b8a94da049518af8f95c5da736e57 *./tests/data/vsynth2/prores_kostya.mov
1+26adb18726c08dde23bc4bee2eb591e2 *./tests/data/vsynth2/prores_kostya.mov
22 3884586 ./tests/data/vsynth2/prores_kostya.mov
33 ca2f6c1162635dedfa468c90f1fdc0ef *./tests/data/prores_kostya.vsynth2.out.yuv
44 stddev: 0.92 PSNR: 48.77 MAXDIFF: 10 bytes: 7603200/ 7603200

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t