History

Merge remote-tracking branch 'qatar/master'

* qatar/master: bitstream: Properly promote av_reverse values before shifting. libavutil/swscale: YUV444P10/YUV444P9 support. H.264: Fix high bit depth explicit biweight h264: Fix 10-bit H.264 x86 chroma v loopfilter asm. Replace DEBUG_SEEK/DEBUG_SI + av_log combinations by av_dlog. Update copyright year for ac3enc_opts_template.c. adts: Adjust frame size mask to follow the specification. movenc: Add RTP muxer/hinter options movenc: Pass the RTP AVFormatContext to the SDP generation rtspenc: Add RTP muxer options rtspenc: Add an AVClass for setting muxer specific options rtpenc_chain: Pass the rtpflags options through to the chained muxer rtpenc: Declare the rtp flags private AVOptions in rtpenc.h sdp: Reindent after the previous commit rtpenc: MP4A-LATM payload support avoptions: Add an av_opt_flag_is_set function for inspecting flag fields sdp: Allow passing an AVFormatContext to the SDP generation mov: Fix wrong timestamp generation for fragmented movies that have time offset caused by the first edit list entry. mpeg12: more advanced ffmpeg mpeg2 aspect guessing code. swscale: split YUYV output out of yuv2packed[12X]_c(). Conflicts: doc/APIchanges libavcodec/Makefile libavcodec/h264dsp_template.c libavcodec/mpeg12.c libavformat/aacdec.c libavformat/avidec.c libavformat/internal.h libavformat/movenc.c libavformat/rtpenc.c libavformat/rtpenc_latm.c libavformat/sdp.c libavformat/version.h libavutil/avutil.h libavutil/pixfmt.h libswscale/swscale.c

Michael Niedermayer committed 15 years ago

Commit 45fb6472 parents 39dbe9b 19d824e34 files · +375 −165Browse files

Unified · Split

34 files
  1. doc/APIchanges +3 −0
  2. libavcodec/Makefile +1 −1
  3. libavcodec/ac3enc_opts_template.c +1 −1
  4. libavcodec/bitstream.c +4 −4
  5. libavcodec/h264dsp_template.c +4 −3
  6. libavcodec/mpeg12.c +7 −9
  7. libavcodec/x86/h264_deblock_10bit.asm +8 −1
  8. libavformat/aacdec.c +1 −1
  9. libavformat/avidec.c +11 −22
  10. libavformat/ffmdec.c +3 −11
  11. libavformat/internal.h +3 −2
  12. libavformat/mov.c +5 −4
  13. libavformat/movenc.c +3 −1
  14. libavformat/movenc.h +1 −0
  15. libavformat/mpeg.c +3 −9
  16. libavformat/mpegenc.c +0 −1
  17. libavformat/mpegts.c +0 −2
  18. libavformat/nsvdec.c +0 −2
  19. libavformat/rtpenc.c +15 −1
  20. libavformat/rtpenc.h +9 −0
  21. libavformat/rtpenc_chain.c +8 −0
  22. libavformat/rtpenc_latm.c +2 −1
  23. libavformat/rtsp.h +5 −0
  24. libavformat/rtspenc.c +15 −0
  25. libavformat/sdp.c +12 −8
  26. libavformat/utils.c +15 −32
  27. libavformat/version.h +1 −1
  28. libavutil/opt.c +10 −0
  29. libavutil/opt.h +10 −0
  30. libavutil/pixdesc.c +46 −0
  31. libavutil/pixfmt.h +9 −3
  32. libswscale/swscale.c +142 −45
  33. libswscale/swscale_internal.h +12 −0
  34. libswscale/utils.c +6 −0
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2011-06-xx - xxxxxxx - lavu 51.6.0 - opt.h
17+ Add av_opt_flag_is_set().
18+
1619 2011-06-10 - c381960 - lavfi 2.15.0 - avfilter_get_audio_buffer_ref_from_arrays
1720 Add avfilter_get_audio_buffer_ref_from_arrays() to avfilter.h.
1821
libavcodec/Makefile+1−1
@@ -558,7 +558,7 @@ OBJS-$(CONFIG_OGG_DEMUXER) += flacdec.o flacdata.o flac.o \ · 557 unmodified lines
558558 dirac.o mpeg12data.o vorbis_data.o
559559 OBJS-$(CONFIG_OGG_MUXER) += xiph.o flacdec.o flacdata.o flac.o \
560560 vorbis_data.o
561−OBJS-$(CONFIG_RTP_MUXER) += mpegvideo.o xiph.o
561+OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o mpegvideo.o xiph.o
562562 OBJS-$(CONFIG_SPDIF_DEMUXER) += aacadtsdec.o mpeg4audio.o
563563 OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \
564564 flacdec.o flacdata.o flac.o \
libavcodec/ac3enc_opts_template.c+1−1
@@ -1,6 +1,6 @@
11 /*
22 * AC-3 encoder options
3− * Copyright (c) 2010 Justin Ruggles <justin.ruggles@gmail.com>
3+ * Copyright (c) 2011 Justin Ruggles <justin.ruggles@gmail.com>
44 *
55 * This file is part of FFmpeg.
66 *
libavcodec/bitstream.c+4−4
@@ -118,10 +118,10 @@ static int alloc_table(VLC *vlc, int size, int use_static) · 117 unmodified lines
118118 }
119119
120120 static av_always_inline uint32_t bitswap_32(uint32_t x) {
121− return av_reverse[x&0xFF]<<24
122− | av_reverse[(x>>8)&0xFF]<<16
123− | av_reverse[(x>>16)&0xFF]<<8
124− | av_reverse[x>>24];
121+ return (uint32_t)av_reverse[x&0xFF]<<24
122+ | (uint32_t)av_reverse[(x>>8)&0xFF]<<16
123+ | (uint32_t)av_reverse[(x>>16)&0xFF]<<8
124+ | (uint32_t)av_reverse[x>>24];
125125 }
126126
127127 typedef struct {
libavcodec/h264dsp_template.c+4−3
@@ -58,11 +58,12 @@ static void FUNCC(weight_h264_pixels ## W ## x ## H)(uint8_t *p_block, int strid · 57 unmodified lines
5858 op_scale1(15); \
5959 } \
6060 } \
61−static void FUNCC(biweight_h264_pixels ## W ## x ## H)(uint8_t *p_dst, uint8_t *p_src, int stride, int log2_denom, int weightd, int weights, int offset){ \
61+static void FUNCC(biweight_h264_pixels ## W ## x ## H)(uint8_t *_dst, uint8_t *_src, int stride, int log2_denom, int weightd, int weights, int offset){ \
6262 int y; \
63− pixel *dst = (pixel*)p_dst; \
64− pixel *src = (pixel*)p_src; \
63+ pixel *dst = (pixel*)_dst; \
64+ pixel *src = (pixel*)_src; \
6565 stride >>= sizeof(pixel)-1; \
66+ offset <<= (BIT_DEPTH-8); \
6667 offset = ((offset + 1) | 1) << log2_denom; \
6768 for(y=0; y<H; y++, dst += stride, src += stride){ \
6869 op_scale2(0); \
libavcodec/mpeg12.c+7−9
@@ -1331,19 +1331,17 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){ · 1330 unmodified lines
13311331 avctx->ticks_per_frame=2;
13321332 //MPEG-2 aspect
13331333 if(s->aspect_ratio_info > 1){
1334− AVRational dar=
1334+ AVRational dar =
13351335 av_mul_q(
1336− av_div_q(
1337− ff_mpeg2_aspect[s->aspect_ratio_info],
1338− (AVRational){s1->pan_scan.width, s1->pan_scan.height}
1339− ),
1336+ av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
1337+ (AVRational){s1->pan_scan.width, s1->pan_scan.height}),
13401338 (AVRational){s->width, s->height});
13411339
1342− //we ignore the spec here and guess a bit as reality does not match the spec, see for example
1340+ // we ignore the spec here and guess a bit as reality does not match the spec, see for example
13431341 // res_change_ffmpeg_aspect.ts and sequence-display-aspect.mpg
1344− //issue1613, 621, 562
1345− if( (s1->pan_scan.width == 0 )||(s1->pan_scan.height == 0)
1346− || (av_cmp_q(dar,(AVRational){4,3})&&av_cmp_q(dar,(AVRational){16,9}))){
1342+ // issue1613, 621, 562
1343+ if((s1->pan_scan.width == 0 ) || (s1->pan_scan.height == 0) ||
1344+ (av_cmp_q(dar,(AVRational){4,3}) && av_cmp_q(dar,(AVRational){16,9}))) {
13471345 s->avctx->sample_aspect_ratio=
13481346 av_div_q(
13491347 ff_mpeg2_aspect[s->aspect_ratio_info],
libavcodec/x86/h264_deblock_10bit.asm+8−1
@@ -836,6 +836,13 @@ DEBLOCK_LUMA_INTRA avx · 835 unmodified lines
836836 mova [r0+2*r1], m2
837837 %endmacro
838838
839+%macro CHROMA_V_LOAD_TC 2
840+ movd %1, [%2]
841+ punpcklbw %1, %1
842+ punpcklwd %1, %1
843+ psraw %1, 6
844+%endmacro
845+
839846 %macro DEBLOCK_CHROMA 1
840847 ;-----------------------------------------------------------------------------
841848 ; void deblock_v_chroma( uint16_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
@@ -854,7 +861,7 @@ cglobal deblock_v_chroma_10_%1, 5,7-(mmsize/16),8*(mmsize/16) · 12 unmodified lines
854861 LOAD_AB m4, m5, r2d, r3d
855862 LOAD_MASK m0, m1, m2, m3, m4, m5, m7, m6, m4
856863 pxor m4, m4
857− LOAD_TC m6, r4
864+ CHROMA_V_LOAD_TC m6, r4
858865 psubw m6, [pw_3]
859866 pmaxsw m6, m4
860867 pand m7, m6
libavformat/aacdec.c+1−1
@@ -44,7 +44,7 @@ static int adts_aac_probe(AVProbeData *p) · 43 unmodified lines
4444 uint32_t header = AV_RB16(buf2);
4545 if((header&0xFFF6) != 0xFFF0)
4646 break;
47− fsize = (AV_RB32(buf2+3)>>13) & 0x1FFF;
47+ fsize = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF;
4848 if(fsize < 7)
4949 break;
5050 buf2 += fsize;
libavformat/avidec.c+11−22
@@ -19,9 +19,6 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121
22−//#define DEBUG
23−//#define DEBUG_SEEK
24−
2522 #include <strings.h>
2623 #include "libavutil/intreadwrite.h"
2724 #include "libavutil/bswap.h"
@@ -160,10 +157,8 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ · 132 unmodified lines
160157 int64_t last_pos= -1;
161158 int64_t filesize= avio_size(s->pb);
162159
163−#ifdef DEBUG_SEEK
164− av_log(s, AV_LOG_ERROR, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%16"PRIX64"\n",
165− longs_pre_entry,index_type, entries_in_use, chunk_id, base);
166−#endif
160+ av_dlog(s, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%16"PRIX64"\n",
161+ longs_pre_entry,index_type, entries_in_use, chunk_id, base);
167162
168163 if(stream_id >= s->nb_streams || stream_id < 0)
169164 return -1;
@@ -1182,10 +1177,8 @@ static int avi_read_idx1(AVFormatContext *s, int size) · 1012 unmodified lines
11821177 flags = avio_rl32(pb);
11831178 pos = avio_rl32(pb);
11841179 len = avio_rl32(pb);
1185−#if defined(DEBUG_SEEK)
1186− av_log(s, AV_LOG_DEBUG, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",
1187− i, tag, flags, pos, len);
1188−#endif
1180+ av_dlog(s, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",
1181+ i, tag, flags, pos, len);
11891182 if(i==0 && pos > avi->movi_list)
11901183 avi->movi_list= 0; //FIXME better check
11911184 pos += avi->movi_list;
@@ -1254,22 +1247,18 @@ static int avi_load_index(AVFormatContext *s) · 62 unmodified lines
12541247
12551248 if (avio_seek(pb, avi->movi_end, SEEK_SET) < 0)
12561249 goto the_end; // maybe truncated file
1257−#ifdef DEBUG_SEEK
1258− av_log(s, AV_LOG_DEBUG, "movi_end=0x%"PRIx64"\n", avi->movi_end);
1259−#endif
1250+ av_dlog(s, "movi_end=0x%"PRIx64"\n", avi->movi_end);
12601251 for(;;) {
12611252 if (url_feof(pb))
12621253 break;
12631254 tag = avio_rl32(pb);
12641255 size = avio_rl32(pb);
1265−#ifdef DEBUG_SEEK
1266− av_log(s, AV_LOG_DEBUG, "tag=%c%c%c%c size=0x%x\n",
1267− tag & 0xff,
1268− (tag >> 8) & 0xff,
1269− (tag >> 16) & 0xff,
1270− (tag >> 24) & 0xff,
1271− size);
1272−#endif
1256+ av_dlog(s, "tag=%c%c%c%c size=0x%x\n",
1257+ tag & 0xff,
1258+ (tag >> 8) & 0xff,
1259+ (tag >> 16) & 0xff,
1260+ (tag >> 24) & 0xff,
1261+ size);
12731262 switch(tag) {
12741263 case MKTAG('i', 'd', 'x', '1'):
12751264 if (avi_read_idx1(s, size) < 0)
libavformat/ffmdec.c+3−11
@@ -163,8 +163,6 @@ static int ffm_read_data(AVFormatContext *s, · 162 unmodified lines
163163 return size1 - size;
164164 }
165165
166−//#define DEBUG_SEEK
167−
168166 /* ensure that acutal seeking happens between FFM_PACKET_SIZE
169167 and file_size - FFM_PACKET_SIZE */
170168 static void ffm_seek1(AVFormatContext *s, int64_t pos1)
@@ -175,9 +173,7 @@ static void ffm_seek1(AVFormatContext *s, int64_t pos1) · 4 unmodified lines
175173
176174 pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE);
177175 pos = FFMAX(pos, FFM_PACKET_SIZE);
178−#ifdef DEBUG_SEEK
179− av_log(s, AV_LOG_DEBUG, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
180−#endif
176+ av_dlog(s, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
181177 avio_seek(pb, pos, SEEK_SET);
182178 }
183179
@@ -189,9 +185,7 @@ static int64_t get_dts(AVFormatContext *s, int64_t pos) · 5 unmodified lines
189185 ffm_seek1(s, pos);
190186 avio_skip(pb, 4);
191187 dts = avio_rb64(pb);
192−#ifdef DEBUG_SEEK
193− av_log(s, AV_LOG_DEBUG, "dts=%0.6f\n", dts / 1000000.0);
194−#endif
188+ av_dlog(s, "dts=%0.6f\n", dts / 1000000.0);
195189 return dts;
196190 }
197191
@@ -464,9 +458,7 @@ static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, in · 266 unmodified lines
464458 int64_t pts_min, pts_max, pts;
465459 double pos1;
466460
467−#ifdef DEBUG_SEEK
468− av_log(s, AV_LOG_DEBUG, "wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
469−#endif
461+ av_dlog(s, "wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
470462 /* find the position using linear interpolation (better than
471463 dichotomy in typical cases) */
472464 pos_min = FFM_PACKET_SIZE;
libavformat/internal.h+3−2
@@ -122,11 +122,12 @@ int ff_url_join(char *str, int size, const char *proto, · 121 unmodified lines
122122 * @param dest_type the destination address type, may be NULL
123123 * @param port the destination port of the media stream, 0 if unknown
124124 * @param ttl the time to live of the stream, 0 if not multicast
125− * @param flags the AVFormatContext->flags, modifying the generated SDP
125+ * @param fmt the AVFormatContext, which might contain options modifying
126+ * the generated SDP
126127 */
127128 void ff_sdp_write_media(char *buff, int size, AVCodecContext *c,
128129 const char *dest_addr, const char *dest_type,
129− int port, int ttl, int flags);
130+ int port, int ttl, AVFormatContext *fmt);
130131
131132 /**
132133 * Write a packet to another muxer than the one the user originally
libavformat/mov.c+5−4
@@ -1537,8 +1537,9 @@ static void mov_build_index(MOVContext *mov, AVStream *st) · 1536 unmodified lines
15371537
15381538 /* adjust first dts according to edit list */
15391539 if (sc->time_offset && mov->time_scale > 0) {
1540− int rescaled = sc->time_offset < 0 ? av_rescale(sc->time_offset, sc->time_scale, mov->time_scale) : sc->time_offset;
1541− current_dts = -rescaled;
1540+ if (sc->time_offset < 0)
1541+ sc->time_offset = av_rescale(sc->time_offset, sc->time_scale, mov->time_scale);
1542+ current_dts = -sc->time_offset;
15421543 if (sc->ctts_data && sc->stts_data &&
15431544 sc->ctts_data[0].duration / FFMAX(sc->stts_data[0].duration, 1) > 16) {
15441545 /* more than 16 frames delay, dts are likely wrong
@@ -2072,7 +2073,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 527 unmodified lines
20722073
20732074 if (flags & 0x001) data_offset = avio_rb32(pb);
20742075 if (flags & 0x004) first_sample_flags = avio_rb32(pb);
2075− dts = st->duration;
2076+ dts = st->duration - sc->time_offset;
20762077 offset = frag->base_data_offset + data_offset;
20772078 distance = 0;
20782079 av_dlog(c->fc, "first sample flags 0x%x\n", first_sample_flags);
@@ -2101,7 +2102,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 22 unmodified lines
21012102 offset += sample_size;
21022103 }
21032104 frag->moof_offset = offset;
2104− st->duration = dts;
2105+ st->duration = dts + sc->time_offset;
21052106 return 0;
21062107 }
21072108
libavformat/movenc.c+3−1
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include "libavutil/avstring.h"
3535 #include "libavutil/opt.h"
3636 #include "libavutil/dict.h"
37+#include "rtpenc.h"
3738
3839 #undef NDEBUG
3940 #include <assert.h>
@@ -41,6 +42,7 @@ · 1 unmodified line
4142 static const AVOption options[] = {
4243 { "movflags", "MOV muxer flags", offsetof(MOVMuxContext, flags), FF_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
4344 { "rtphint", "Add RTP hint tracks", 0, FF_OPT_TYPE_CONST, {.dbl = FF_MOV_FLAG_RTP_HINT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
45+ FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
4446 { NULL },
4547 };
4648
@@ -1368,7 +1370,7 @@ static int mov_write_udta_sdp(AVIOContext *pb, AVFormatContext *ctx, int index) · 1321 unmodified lines
13681370 char buf[1000] = "";
13691371 int len;
13701372
1371− ff_sdp_write_media(buf, sizeof(buf), ctx->streams[0]->codec, NULL, NULL, 0, 0, ctx->flags);
1373+ ff_sdp_write_media(buf, sizeof(buf), ctx->streams[0]->codec, NULL, NULL, 0, 0, ctx);
13721374 av_strlcatf(buf, sizeof(buf), "a=control:streamid=%d\r\n", index);
13731375 len = strlen(buf);
13741376
libavformat/movenc.h+1−0
@@ -111,6 +111,7 @@ typedef struct MOVMuxContext { · 110 unmodified lines
111111 MOVTrack *tracks;
112112
113113 int flags;
114+ int rtp_flags;
114115 } MOVMuxContext;
115116
116117 #define FF_MOV_FLAG_RTP_HINT 1
libavformat/mpeg.c+3−9
@@ -23,8 +23,6 @@ · 22 unmodified lines
2323 #include "internal.h"
2424 #include "mpeg.h"
2525
26−//#define DEBUG_SEEK
27−
2826 #undef NDEBUG
2927 #include <assert.h>
3028
@@ -592,9 +590,7 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, · 561 unmodified lines
592590 for(;;) {
593591 len = mpegps_read_pes_header(s, &pos, &startcode, &pts, &dts);
594592 if (len < 0) {
595−#ifdef DEBUG_SEEK
596− av_log(s, AV_LOG_DEBUG, "none (ret=%d)\n", len);
597−#endif
593+ av_dlog(s, "none (ret=%d)\n", len);
598594 return AV_NOPTS_VALUE;
599595 }
600596 if (startcode == s->streams[stream_index]->id &&
@@ -603,10 +599,8 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, · 2 unmodified lines
603599 }
604600 avio_skip(s->pb, len);
605601 }
606−#ifdef DEBUG_SEEK
607− av_log(s, AV_LOG_DEBUG, "pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n",
608− pos, dts, dts / 90000.0);
609−#endif
602+ av_dlog(s, "pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n",
603+ pos, dts, dts / 90000.0);
610604 *ppos = pos;
611605 return dts;
612606 }
libavformat/mpegenc.c+0−1
@@ -25,7 +25,6 @@ · 24 unmodified lines
2525 #include "mpeg.h"
2626
2727 #define MAX_PAYLOAD_SIZE 4096
28−//#define DEBUG_SEEK
2928
3029 #undef NDEBUG
3130 #include <assert.h>
libavformat/mpegts.c+0−2
@@ -19,8 +19,6 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121
22−//#define DEBUG
23−//#define DEBUG_SEEK
2422 //#define USE_SYNCPOINT_SEARCH
2523
2624 #include "libavutil/crc.h"
libavformat/nsvdec.c+0−2
@@ -22,9 +22,7 @@ · 21 unmodified lines
2222 #include "riff.h"
2323 #include "libavutil/dict.h"
2424
25−//#define DEBUG
2625 //#define DEBUG_DUMP_INDEX // XXX dumbdriving-271.nsv breaks with it commented!!
27−//#define DEBUG_SEEK
2826 #define CHECK_SUBSEQUENT_NSVS
2927 //#define DISABLE_AUDIO
3028
libavformat/rtpenc.c+15−1
@@ -23,11 +23,24 @@ · 22 unmodified lines
2323 #include "mpegts.h"
2424 #include "internal.h"
2525 #include "libavutil/random_seed.h"
26+#include "libavutil/opt.h"
2627
2728 #include "rtpenc.h"
2829
2930 //#define DEBUG
3031
32+static const AVOption options[] = {
33+ FF_RTP_FLAG_OPTS(RTPMuxContext, flags),
34+ { NULL },
35+};
36+
37+static const AVClass rtp_muxer_class = {
38+ .class_name = "RTP muxer",
39+ .item_name = av_default_item_name,
40+ .option = options,
41+ .version = LIBAVUTIL_VERSION_INT,
42+};
43+
3144 #define RTCP_SR_SIZE 28
3245
3346 static int is_supported(enum CodecID id)
@@ -404,7 +417,7 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) · 370 unmodified lines
404417 ff_rtp_send_mpegvideo(s1, pkt->data, size);
405418 break;
406419 case CODEC_ID_AAC:
407− if (s1->flags & AVFMT_FLAG_MP4A_LATM)
420+ if (s->flags & FF_RTP_FLAG_MP4A_LATM)
408421 ff_rtp_send_latm(s1, pkt->data, size);
409422 else
410423 ff_rtp_send_aac(s1, pkt->data, size);
@@ -458,4 +471,5 @@ AVOutputFormat ff_rtp_muxer = { · 47 unmodified lines
458471 rtp_write_header,
459472 rtp_write_packet,
460473 rtp_write_trailer,
474+ .priv_class = &rtp_muxer_class,
461475 };
libavformat/rtpenc.h+9−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include "rtp.h"
2626
2727 struct RTPMuxContext {
28+ const AVClass *av_class;
2829 AVFormatContext *ic;
2930 AVStream *st;
3031 int payload_type;
@@ -56,10 +57,18 @@ struct RTPMuxContext { · 25 unmodified lines
5657 * (1, 2 or 4)
5758 */
5859 int nal_length_size;
60+
61+ int flags;
5962 };
6063
6164 typedef struct RTPMuxContext RTPMuxContext;
6265
66+#define FF_RTP_FLAG_MP4A_LATM 1
67+
68+#define FF_RTP_FLAG_OPTS(ctx, fieldname) \
69+ { "rtpflags", "RTP muxer flags", offsetof(ctx, fieldname), FF_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \
70+ { "latm", "Use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC", 0, FF_OPT_TYPE_CONST, {.dbl = FF_RTP_FLAG_MP4A_LATM}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" } \
71+
6372 void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m);
6473
6574 void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size);
libavformat/rtpenc_chain.c+8−0
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include "avio_internal.h"
2424 #include "rtpenc_chain.h"
2525 #include "avio_internal.h"
26+#include "libavutil/opt.h"
2627
2728 AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
2829 URLContext *handle, int packet_size)
@@ -50,6 +51,13 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, · 21 unmodified lines
5051 rtpctx->streams[0]->sample_aspect_ratio = st->sample_aspect_ratio;
5152 rtpctx->flags |= s->flags & AVFMT_FLAG_MP4A_LATM;
5253
54+ av_set_parameters(rtpctx, NULL);
55+ /* Copy the rtpflags values straight through */
56+ if (s->oformat->priv_class &&
57+ av_find_opt(s->priv_data, "rtpflags", NULL, 0, 0))
58+ av_set_int(rtpctx->priv_data, "rtpflags",
59+ av_get_int(s->priv_data, "rtpflags", NULL));
60+
5361 /* Set the synchronized start time. */
5462 rtpctx->start_time_realtime = s->start_time_realtime;
5563
libavformat/rtpenc_latm.c+2−1
@@ -22,7 +22,8 @@ · 21 unmodified lines
2222 #include "avformat.h"
2323 #include "rtpenc.h"
2424
25−void ff_rtp_send_latm(AVFormatContext *s1, const uint8_t *buff, int size) {
25+void ff_rtp_send_latm(AVFormatContext *s1, const uint8_t *buff, int size)
26+{
2627 /* MP4A-LATM
2728 * The RTP payload format specification is described in RFC 3016
2829 * The encoding specifications are provided in ISO/IEC 14496-3 */
libavformat/rtsp.h+5−0
@@ -344,6 +344,11 @@ typedef struct RTSPState { · 343 unmodified lines
344344 * Do not begin to play the stream immediately.
345345 */
346346 int initial_pause;
347+
348+ /**
349+ * Option flags for the chained RTP muxer.
350+ */
351+ int rtp_muxer_flags;
347352 } RTSPState;
348353
349354 /**
libavformat/rtspenc.c+15−0
@@ -33,9 +33,23 @@ · 32 unmodified lines
3333 #include "libavutil/intreadwrite.h"
3434 #include "libavutil/avstring.h"
3535 #include "url.h"
36+#include "libavutil/opt.h"
37+#include "rtpenc.h"
3638
3739 #define SDP_MAX_SIZE 16384
3840
41+static const AVOption options[] = {
42+ FF_RTP_FLAG_OPTS(RTSPState, rtp_muxer_flags),
43+ { NULL },
44+};
45+
46+static const AVClass rtsp_muxer_class = {
47+ .class_name = "RTSP muxer",
48+ .item_name = av_default_item_name,
49+ .option = options,
50+ .version = LIBAVUTIL_VERSION_INT,
51+};
52+
3953 int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr)
4054 {
4155 RTSPState *rt = s->priv_data;
@@ -238,5 +252,6 @@ AVOutputFormat ff_rtsp_muxer = { · 196 unmodified lines
238252 rtsp_write_packet,
239253 rtsp_write_close,
240254 .flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER,
255+ .priv_class = &rtsp_muxer_class,
241256 };
242257
libavformat/sdp.c+12−8
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include "libavutil/base64.h"
2424 #include "libavutil/dict.h"
2525 #include "libavutil/parseutils.h"
26+#include "libavutil/opt.h"
2627 #include "libavcodec/xiph.h"
2728 #include "libavcodec/mpeg4audio.h"
2829 #include "avformat.h"
@@ -301,7 +302,8 @@ xiph_fail: · 272 unmodified lines
301302 return NULL;
302303 }
303304
304−static int latm_context2profilelevel(AVCodecContext *c) {
305+static int latm_context2profilelevel(AVCodecContext *c)
306+{
305307 /* MP4A-LATM
306308 * The RTP payload format specification is described in RFC 3016
307309 * The encoding specifications are provided in ISO/IEC 14496-3 */
@@ -329,7 +331,8 @@ static int latm_context2profilelevel(AVCodecContext *c) { · 21 unmodified lines
329331 return profile_level;
330332 }
331333
332−static char *latm_context2config(AVCodecContext *c) {
334+static char *latm_context2config(AVCodecContext *c)
335+{
333336 /* MP4A-LATM
334337 * The RTP payload format specification is described in RFC 3016
335338 * The encoding specifications are provided in ISO/IEC 14496-3 */
@@ -364,7 +367,7 @@ static char *latm_context2config(AVCodecContext *c) { · 28 unmodified lines
364367 return config;
365368 }
366369
367−static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, int payload_type, int flags)
370+static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, int payload_type, AVFormatContext *fmt)
368371 {
369372 char *config = NULL;
370373
@@ -399,7 +402,8 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, · 28 unmodified lines
399402 payload_type, config ? config : "");
400403 break;
401404 case CODEC_ID_AAC:
402− if (flags & AVFMT_FLAG_MP4A_LATM) {
405+ if (fmt && fmt->oformat->priv_class &&
406+ av_opt_flag_is_set(fmt->priv_data, "rtpflags", "latm")) {
403407 config = latm_context2config(c);
404408 if (!config)
405409 return NULL;
@@ -523,7 +527,7 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, · 117 unmodified lines
523527 return buff;
524528 }
525529
526−void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *dest_addr, const char *dest_type, int port, int ttl, int flags)
530+void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *dest_addr, const char *dest_type, int port, int ttl, AVFormatContext *fmt)
527531 {
528532 const char *type;
529533 int payload_type;
@@ -546,7 +550,7 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des · 16 unmodified lines
546550 av_strlcatf(buff, size, "b=AS:%d\r\n", c->bit_rate / 1000);
547551 }
548552
549− sdp_write_media_attributes(buff, size, c, payload_type, flags);
553+ sdp_write_media_attributes(buff, size, c, payload_type, fmt);
550554 }
551555
552556 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
@@ -596,7 +600,7 @@ int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size) · 43 unmodified lines
596600 ff_sdp_write_media(buf, size,
597601 ac[i]->streams[j]->codec, dst[0] ? dst : NULL,
598602 dst_type, (port > 0) ? port + j * 2 : 0, ttl,
599− ac[i]->flags);
603+ ac[i]);
600604 if (port <= 0) {
601605 av_strlcatf(buf, size,
602606 "a=control:streamid=%d\r\n", i + j);
@@ -612,7 +616,7 @@ int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size) · 9 unmodified lines
612616 return AVERROR(ENOSYS);
613617 }
614618
615−void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *dest_addr, const char *dest_type, int port, int ttl, int flags)
619+void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *dest_addr, const char *dest_type, int port, int ttl, AVFormatContext *fmt)
616620 {
617621 }
618622 #endif
libavformat/utils.c+15−32
@@ -1449,8 +1449,6 @@ int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, · 1448 unmodified lines
14491449 wanted_timestamp, flags);
14501450 }
14511451
1452−#define DEBUG_SEEK
1453−
14541452 int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){
14551453 AVInputFormat *avif= s->iformat;
14561454 int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;
@@ -1462,9 +1460,7 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts · 5 unmodified lines
14621460 if (stream_index < 0)
14631461 return -1;
14641462
1465−#ifdef DEBUG_SEEK
1466− av_log(s, AV_LOG_DEBUG, "read_seek: %d %"PRId64"\n", stream_index, target_ts);
1467−#endif
1463+ av_dlog(s, "read_seek: %d %"PRId64"\n", stream_index, target_ts);
14681464
14691465 ts_max=
14701466 ts_min= AV_NOPTS_VALUE;
@@ -1481,10 +1477,8 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts · 10 unmodified lines
14811477 if(e->timestamp <= target_ts || e->pos == e->min_distance){
14821478 pos_min= e->pos;
14831479 ts_min= e->timestamp;
1484−#ifdef DEBUG_SEEK
1485− av_log(s, AV_LOG_DEBUG, "using cached pos_min=0x%"PRIx64" dts_min=%"PRId64"\n",
1486− pos_min,ts_min);
1487−#endif
1480+ av_dlog(s, "using cached pos_min=0x%"PRIx64" dts_min=%"PRId64"\n",
1481+ pos_min,ts_min);
14881482 }else{
14891483 assert(index==0);
14901484 }
@@ -1497,10 +1491,8 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts · 6 unmodified lines
14971491 pos_max= e->pos;
14981492 ts_max= e->timestamp;
14991493 pos_limit= pos_max - e->min_distance;
1500−#ifdef DEBUG_SEEK
1501− av_log(s, AV_LOG_DEBUG, "using cached pos_max=0x%"PRIx64" pos_limit=0x%"PRIx64" dts_max=%"PRId64"\n",
1502− pos_max,pos_limit, ts_max);
1503−#endif
1494+ av_dlog(s, "using cached pos_max=0x%"PRIx64" pos_limit=0x%"PRIx64" dts_max=%"PRId64"\n",
1495+ pos_max,pos_limit, ts_max);
15041496 }
15051497 }
15061498
@@ -1522,9 +1514,7 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i · 15 unmodified lines
15221514 int64_t start_pos, filesize;
15231515 int no_change;
15241516
1525−#ifdef DEBUG_SEEK
1526− av_log(s, AV_LOG_DEBUG, "gen_seek: %d %"PRId64"\n", stream_index, target_ts);
1527−#endif
1517+ av_dlog(s, "gen_seek: %d %"PRId64"\n", stream_index, target_ts);
15281518
15291519 if(ts_min == AV_NOPTS_VALUE){
15301520 pos_min = s->data_offset;
@@ -1566,11 +1556,8 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i · 35 unmodified lines
15661556
15671557 no_change=0;
15681558 while (pos_min < pos_limit) {
1569−#ifdef DEBUG_SEEK
1570− av_log(s, AV_LOG_DEBUG, "pos_min=0x%"PRIx64" pos_max=0x%"PRIx64" dts_min=%"PRId64" dts_max=%"PRId64"\n",
1571− pos_min, pos_max,
1572− ts_min, ts_max);
1573−#endif
1559+ av_dlog(s, "pos_min=0x%"PRIx64" pos_max=0x%"PRIx64" dts_min=%"PRId64" dts_max=%"PRId64"\n",
1560+ pos_min, pos_max, ts_min, ts_max);
15741561 assert(pos_limit <= pos_max);
15751562
15761563 if(no_change==0){
@@ -1597,11 +1584,9 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i · 20 unmodified lines
15971584 no_change++;
15981585 else
15991586 no_change=0;
1600−#ifdef DEBUG_SEEK
1601− av_log(s, AV_LOG_DEBUG, "%"PRId64" %"PRId64" %"PRId64" / %"PRId64" %"PRId64" %"PRId64" target:%"PRId64" limit:%"PRId64" start:%"PRId64" noc:%d\n",
1602− pos_min, pos, pos_max, ts_min, ts, ts_max, target_ts, pos_limit,
1603− start_pos, no_change);
1604−#endif
1587+ av_dlog(s, "%"PRId64" %"PRId64" %"PRId64" / %"PRId64" %"PRId64" %"PRId64" target:%"PRId64" limit:%"PRId64" start:%"PRId64" noc:%d\n",
1588+ pos_min, pos, pos_max, ts_min, ts, ts_max, target_ts,
1589+ pos_limit, start_pos, no_change);
16051590 if(ts == AV_NOPTS_VALUE){
16061591 av_log(s, AV_LOG_ERROR, "read_timestamp() failed in the middle\n");
16071592 return -1;
@@ -1620,13 +1605,13 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i · 12 unmodified lines
16201605
16211606 pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
16221607 ts = (flags & AVSEEK_FLAG_BACKWARD) ? ts_min : ts_max;
1623−#ifdef DEBUG_SEEK
1608+#if 1
16241609 pos_min = pos;
16251610 ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX);
16261611 pos_min++;
16271612 ts_max = read_timestamp(s, stream_index, &pos_min, INT64_MAX);
1628− av_log(s, AV_LOG_DEBUG, "pos=0x%"PRIx64" %"PRId64"<=%"PRId64"<=%"PRId64"\n",
1629− pos, ts_min, target_ts, ts_max);
1613+ av_dlog(s, "pos=0x%"PRIx64" %"PRId64"<=%"PRId64"<=%"PRId64"\n",
1614+ pos, ts_min, target_ts, ts_max);
16301615 #endif
16311616 *ts_ret= ts;
16321617 return pos;
@@ -2694,9 +2679,7 @@ AVProgram *av_new_program(AVFormatContext *ac, int id) · 1061 unmodified lines
26942679 AVProgram *program=NULL;
26952680 int i;
26962681
2697−#ifdef DEBUG_SI
2698− av_log(ac, AV_LOG_DEBUG, "new_program: id=0x%04x\n", id);
2699−#endif
2682+ av_dlog(ac, "new_program: id=0x%04x\n", id);
27002683
27012684 for(i=0; i<ac->nb_programs; i++)
27022685 if(ac->programs[i]->id == id)
libavformat/version.h+1−1
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525
2626 #define LIBAVFORMAT_VERSION_MAJOR 53
2727 #define LIBAVFORMAT_VERSION_MINOR 3
28−#define LIBAVFORMAT_VERSION_MICRO 0
28+#define LIBAVFORMAT_VERSION_MICRO 1
2929
3030 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3131 LIBAVFORMAT_VERSION_MINOR, \
libavutil/opt.c+10−0
@@ -320,6 +320,16 @@ int64_t av_get_int(void *obj, const char *name, const AVOption **o_out) · 319 unmodified lines
320320 return num*intnum/den;
321321 }
322322
323+int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
324+{
325+ const AVOption *field = av_find_opt(obj, field_name, NULL, 0, 0);
326+ const AVOption *flag = av_find_opt(obj, flag_name, NULL, 0, 0);
327+
328+ if (!field || !flag || flag->type != FF_OPT_TYPE_CONST)
329+ return 0;
330+ return av_get_int(obj, field_name, NULL) & (int) flag->default_val.dbl;
331+}
332+
323333 static void opt_list(void *obj, void *av_log_obj, const char *unit,
324334 int req_flags, int rej_flags)
325335 {
libavutil/opt.h+10−0
@@ -181,4 +181,14 @@ int av_set_options_string(void *ctx, const char *opts, · 180 unmodified lines
181181 */
182182 void av_opt_free(void *obj);
183183
184+/**
185+ * Check whether a particular flag is set in a flags field.
186+ *
187+ * @param field_name the name of the flag field option
188+ * @param flag_name the name of the flag to check
189+ * @return non-zero if the flag is set, zero if the flag isn't set,
190+ * isn't of the right type, or the flags field doesn't exist.
191+ */
192+int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
193+
184194 #endif /* AVUTIL_OPT_H */
libavutil/pixdesc.c+46−0
@@ -878,6 +878,52 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { · 877 unmodified lines
878878 },
879879 .flags = PIX_FMT_BE,
880880 },
881+ [PIX_FMT_YUV444P10LE] = {
882+ .name = "yuv444p10le",
883+ .nb_components= 3,
884+ .log2_chroma_w= 0,
885+ .log2_chroma_h= 0,
886+ .comp = {
887+ {0,1,1,0,9}, /* Y */
888+ {1,1,1,0,9}, /* U */
889+ {2,1,1,0,9}, /* V */
890+ },
891+ },
892+ [PIX_FMT_YUV444P10BE] = {
893+ .name = "yuv444p10be",
894+ .nb_components= 3,
895+ .log2_chroma_w= 0,
896+ .log2_chroma_h= 0,
897+ .comp = {
898+ {0,1,1,0,9}, /* Y */
899+ {1,1,1,0,9}, /* U */
900+ {2,1,1,0,9}, /* V */
901+ },
902+ .flags = PIX_FMT_BE,
903+ },
904+ [PIX_FMT_YUV444P9LE] = {
905+ .name = "yuv444p9le",
906+ .nb_components= 3,
907+ .log2_chroma_w= 0,
908+ .log2_chroma_h= 0,
909+ .comp = {
910+ {0,1,1,0,8}, /* Y */
911+ {1,1,1,0,8}, /* U */
912+ {2,1,1,0,8}, /* V */
913+ },
914+ },
915+ [PIX_FMT_YUV444P9BE] = {
916+ .name = "yuv444p9be",
917+ .nb_components= 3,
918+ .log2_chroma_w= 0,
919+ .log2_chroma_h= 0,
920+ .comp = {
921+ {0,1,1,0,9}, /* Y */
922+ {1,1,1,0,9}, /* U */
923+ {2,1,1,0,9}, /* V */
924+ },
925+ .flags = PIX_FMT_BE,
926+ },
881927 [PIX_FMT_DXVA2_VLD] = {
882928 .name = "dxva2_vld",
883929 .log2_chroma_w = 1,
libavutil/pixfmt.h+9−3
@@ -136,15 +136,19 @@ enum PixelFormat { · 135 unmodified lines
136136 PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
137137 PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
138138
139− //the following 6 formats have the disadvantage of needing 1 format for each bit depth, thus
139+ //the following 10 formats have the disadvantage of needing 1 format for each bit depth, thus
140140 //If you want to support multiple bit depths, then using PIX_FMT_YUV420P16* with the bpp stored seperately
141141 //is better
142142 PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
143143 PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
144144 PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
145145 PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
146− PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
147− PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
146+ PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
147+ PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
148+ PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
149+ PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
150+ PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
151+ PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
148152
149153 PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
150154 };
@@ -173,8 +177,10 @@ enum PixelFormat { · 22 unmodified lines
173177 #define PIX_FMT_BGR444 PIX_FMT_NE(BGR444BE, BGR444LE)
174178
175179 #define PIX_FMT_YUV420P9 PIX_FMT_NE(YUV420P9BE , YUV420P9LE)
180+#define PIX_FMT_YUV444P9 PIX_FMT_NE(YUV444P9BE , YUV444P9LE)
176181 #define PIX_FMT_YUV420P10 PIX_FMT_NE(YUV420P10BE, YUV420P10LE)
177182 #define PIX_FMT_YUV422P10 PIX_FMT_NE(YUV422P10BE, YUV422P10LE)
183+#define PIX_FMT_YUV444P10 PIX_FMT_NE(YUV444P10BE, YUV444P10LE)
178184 #define PIX_FMT_YUV420P16 PIX_FMT_NE(YUV420P16BE, YUV420P16LE)
179185 #define PIX_FMT_YUV422P16 PIX_FMT_NE(YUV422P16BE, YUV422P16LE)
180186 #define PIX_FMT_YUV444P16 PIX_FMT_NE(YUV444P16BE, YUV444P16LE)
libswscale/swscale.c+142−45
@@ -724,7 +724,117 @@ yuv2mono_1_c_template(SwsContext *c, const uint16_t *buf0, · 723 unmodified lines
724724 YUV2PACKEDWRAPPER(yuv2mono, white, PIX_FMT_MONOWHITE);
725725 YUV2PACKEDWRAPPER(yuv2mono, black, PIX_FMT_MONOBLACK);
726726
727−#define YSCALE_YUV_2_PACKEDX_C(type,alpha) \
727+static av_always_inline void
728+yuv2422_X_c_template(SwsContext *c, const int16_t *lumFilter,
729+ const int16_t **lumSrc, int lumFilterSize,
730+ const int16_t *chrFilter, const int16_t **chrUSrc,
731+ const int16_t **chrVSrc, int chrFilterSize,
732+ const int16_t **alpSrc, uint8_t *dest, int dstW,
733+ int y, enum PixelFormat target)
734+{
735+ int i;
736+
737+#define output_pixels(pos, Y1, U, Y2, V) \
738+ if (target == PIX_FMT_YUYV422) { \
739+ dest[pos + 0] = Y1; \
740+ dest[pos + 1] = U; \
741+ dest[pos + 2] = Y2; \
742+ dest[pos + 3] = V; \
743+ } else { \
744+ dest[pos + 0] = U; \
745+ dest[pos + 1] = Y1; \
746+ dest[pos + 2] = V; \
747+ dest[pos + 3] = Y2; \
748+ }
749+
750+ for (i = 0; i < (dstW >> 1); i++) {
751+ int j;
752+ int Y1 = 1 << 18;
753+ int Y2 = 1 << 18;
754+ int U = 1 << 18;
755+ int V = 1 << 18;
756+
757+ for (j = 0; j < lumFilterSize; j++) {
758+ Y1 += lumSrc[j][i * 2] * lumFilter[j];
759+ Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
760+ }
761+ for (j = 0; j < chrFilterSize; j++) {
762+ U += chrUSrc[j][i] * chrFilter[j];
763+ V += chrVSrc[j][i] * chrFilter[j];
764+ }
765+ Y1 >>= 19;
766+ Y2 >>= 19;
767+ U >>= 19;
768+ V >>= 19;
769+ if ((Y1 | Y2 | U | V) & 0x100) {
770+ Y1 = av_clip_uint8(Y1);
771+ Y2 = av_clip_uint8(Y2);
772+ U = av_clip_uint8(U);
773+ V = av_clip_uint8(V);
774+ }
775+ output_pixels(4*i, Y1, U, Y2, V);
776+ }
777+}
778+
779+static av_always_inline void
780+yuv2422_2_c_template(SwsContext *c, const uint16_t *buf0,
781+ const uint16_t *buf1, const uint16_t *ubuf0,
782+ const uint16_t *ubuf1, const uint16_t *vbuf0,
783+ const uint16_t *vbuf1, const uint16_t *abuf0,
784+ const uint16_t *abuf1, uint8_t *dest, int dstW,
785+ int yalpha, int uvalpha, int y,
786+ enum PixelFormat target)
787+{
788+ int yalpha1 = 4095 - yalpha;
789+ int uvalpha1 = 4095 - uvalpha;
790+ int i;
791+
792+ for (i = 0; i < (dstW >> 1); i++) {
793+ int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
794+ int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
795+ int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
796+ int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
797+
798+ output_pixels(i * 4, Y1, U, Y2, V);
799+ }
800+}
801+
802+static av_always_inline void
803+yuv2422_1_c_template(SwsContext *c, const uint16_t *buf0,
804+ const uint16_t *ubuf0, const uint16_t *ubuf1,
805+ const uint16_t *vbuf0, const uint16_t *vbuf1,
806+ const uint16_t *abuf0, uint8_t *dest, int dstW,
807+ int uvalpha, enum PixelFormat dstFormat,
808+ int flags, int y, enum PixelFormat target)
809+{
810+ int i;
811+
812+ if (uvalpha < 2048) {
813+ for (i = 0; i < (dstW >> 1); i++) {
814+ int Y1 = buf0[i * 2] >> 7;
815+ int Y2 = buf0[i * 2 + 1] >> 7;
816+ int U = ubuf1[i] >> 7;
817+ int V = vbuf1[i] >> 7;
818+
819+ output_pixels(i * 4, Y1, U, Y2, V);
820+ }
821+ } else {
822+ for (i = 0; i < (dstW >> 1); i++) {
823+ int Y1 = buf0[i * 2] >> 7;
824+ int Y2 = buf0[i * 2 + 1] >> 7;
825+ int U = (ubuf0[i] + ubuf1[i]) >> 8;
826+ int V = (vbuf0[i] + vbuf1[i]) >> 8;
827+
828+ output_pixels(i * 4, Y1, U, Y2, V);
829+ }
830+ }
831+#undef output_pixels
832+}
833+
834+YUV2PACKEDWRAPPER(yuv2422, yuyv, PIX_FMT_YUYV422);
835+YUV2PACKEDWRAPPER(yuv2422, uyvy, PIX_FMT_UYVY422);
836+
837+#define YSCALE_YUV_2_RGBX_C(type,alpha) \
728838 for (i=0; i<(dstW>>1); i++) {\
729839 int j;\
730840 int Y1 = 1<<18;\
@@ -766,7 +876,11 @@ YUV2PACKEDWRAPPER(yuv2mono, black, PIX_FMT_MONOBLACK); · 35 unmodified lines
766876 A1 = av_clip_uint8(A1); \
767877 A2 = av_clip_uint8(A2); \
768878 }\
769− }
879+ }\
880+ /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/\
881+ r = (type *)c->table_rV[V]; \
882+ g = (type *)(c->table_gU[U] + c->table_gV[V]); \
883+ b = (type *)c->table_bU[U];
770884
771885 #define YSCALE_YUV_2_RGBX_FULL_C(rnd,alpha) \
772886 for (i=0; i<dstW; i++) {\
@@ -807,13 +921,7 @@ YUV2PACKEDWRAPPER(yuv2mono, black, PIX_FMT_MONOBLACK); · 34 unmodified lines
807921 B = av_clip_uintp2(B, 30); \
808922 }
809923
810−#define YSCALE_YUV_2_RGBX_C(type,alpha) \
811− YSCALE_YUV_2_PACKEDX_C(type,alpha) /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/\
812− r = (type *)c->table_rV[V]; \
813− g = (type *)(c->table_gU[U] + c->table_gV[V]); \
814− b = (type *)c->table_bU[U];
815−
816−#define YSCALE_YUV_2_PACKED2_C(type,alpha) \
924+#define YSCALE_YUV_2_RGB2_C(type,alpha) \
817925 for (i=0; i<(dstW>>1); i++) { \
818926 const int i2= 2*i; \
819927 int Y1= (buf0[i2 ]*yalpha1+buf1[i2 ]*yalpha)>>19; \
@@ -825,15 +933,12 @@ YUV2PACKEDWRAPPER(yuv2mono, black, PIX_FMT_MONOBLACK); · 5 unmodified lines
825933 if (alpha) {\
826934 A1= (abuf0[i2 ]*yalpha1+abuf1[i2 ]*yalpha)>>19; \
827935 A2= (abuf0[i2+1]*yalpha1+abuf1[i2+1]*yalpha)>>19; \
828− }
829−
830−#define YSCALE_YUV_2_RGB2_C(type,alpha) \
831− YSCALE_YUV_2_PACKED2_C(type,alpha)\
936+ }\
832937 r = (type *)c->table_rV[V];\
833938 g = (type *)(c->table_gU[U] + c->table_gV[V]);\
834939 b = (type *)c->table_bU[U];
835940
836−#define YSCALE_YUV_2_PACKED1_C(type,alpha) \
941+#define YSCALE_YUV_2_RGB1_C(type,alpha) \
837942 for (i=0; i<(dstW>>1); i++) {\
838943 const int i2= 2*i;\
839944 int Y1= buf0[i2 ]>>7;\
@@ -845,15 +950,12 @@ YUV2PACKEDWRAPPER(yuv2mono, black, PIX_FMT_MONOBLACK); · 5 unmodified lines
845950 if (alpha) {\
846951 A1= abuf0[i2 ]>>7;\
847952 A2= abuf0[i2+1]>>7;\
848− }
849−
850−#define YSCALE_YUV_2_RGB1_C(type,alpha) \
851− YSCALE_YUV_2_PACKED1_C(type,alpha)\
953+ }\
852954 r = (type *)c->table_rV[V];\
853955 g = (type *)(c->table_gU[U] + c->table_gV[V]);\
854956 b = (type *)c->table_bU[U];
855957
856−#define YSCALE_YUV_2_PACKED1B_C(type,alpha) \
958+#define YSCALE_YUV_2_RGB1B_C(type,alpha) \
857959 for (i=0; i<(dstW>>1); i++) {\
858960 const int i2= 2*i;\
859961 int Y1= buf0[i2 ]>>7;\
@@ -865,15 +967,12 @@ YUV2PACKEDWRAPPER(yuv2mono, black, PIX_FMT_MONOBLACK); · 5 unmodified lines
865967 if (alpha) {\
866968 A1= abuf0[i2 ]>>7;\
867969 A2= abuf0[i2+1]>>7;\
868− }
869−
870−#define YSCALE_YUV_2_RGB1B_C(type,alpha) \
871− YSCALE_YUV_2_PACKED1B_C(type,alpha)\
970+ }\
872971 r = (type *)c->table_rV[V];\
873972 g = (type *)(c->table_gU[U] + c->table_gV[V]);\
874973 b = (type *)c->table_bU[U];
875974
876−#define YSCALE_YUV_2_ANYRGB_C(func, func2)\
975+#define YSCALE_YUV_2_ANYRGB_C(func)\
877976 switch(c->dstFormat) {\
878977 case PIX_FMT_RGB48BE:\
879978 case PIX_FMT_RGB48LE:\
@@ -1049,22 +1148,6 @@ YUV2PACKEDWRAPPER(yuv2mono, black, PIX_FMT_MONOBLACK); · 169 unmodified lines
10491148 }\
10501149 }\
10511150 break;\
1052− case PIX_FMT_YUYV422:\
1053− func2\
1054− ((uint8_t*)dest)[2*i2+0]= Y1;\
1055− ((uint8_t*)dest)[2*i2+1]= U;\
1056− ((uint8_t*)dest)[2*i2+2]= Y2;\
1057− ((uint8_t*)dest)[2*i2+3]= V;\
1058− } \
1059− break;\
1060− case PIX_FMT_UYVY422:\
1061− func2\
1062− ((uint8_t*)dest)[2*i2+0]= U;\
1063− ((uint8_t*)dest)[2*i2+1]= Y1;\
1064− ((uint8_t*)dest)[2*i2+2]= V;\
1065− ((uint8_t*)dest)[2*i2+3]= Y2;\
1066− } \
1067− break;\
10681151 }
10691152
10701153 static void yuv2packedX_c(SwsContext *c, const int16_t *lumFilter,
@@ -1074,7 +1157,7 @@ static void yuv2packedX_c(SwsContext *c, const int16_t *lumFilter, · 3 unmodified lines
10741157 const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
10751158 {
10761159 int i;
1077− YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGBX_C, YSCALE_YUV_2_PACKEDX_C(void,0))
1160+ YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGBX_C)
10781161 }
10791162
10801163 static void yuv2rgbX_c_full(SwsContext *c, const int16_t *lumFilter,
@@ -1177,7 +1260,7 @@ static void yuv2packed2_c(SwsContext *c, const uint16_t *buf0, · 96 unmodified lines
11771260 int uvalpha1=4095-uvalpha;
11781261 int i;
11791262
1180− YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C(void,0))
1263+ YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C)
11811264 }
11821265
11831266 /**
@@ -1193,9 +1276,9 @@ static void yuv2packed1_c(SwsContext *c, const uint16_t *buf0, · 9 unmodified lines
11931276 int i;
11941277
11951278 if (uvalpha < 2048) {
1196− YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C(void,0))
1279+ YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C)
11971280 } else {
1198− YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C(void,0))
1281+ YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C)
11991282 }
12001283 }
12011284
@@ -1886,7 +1969,7 @@ find_c_packed_planar_out_funcs(SwsContext *c, · 684 unmodified lines
18861969 } else if (is16BPS(dstFormat)) {
18871970 *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX16BE_c : yuv2yuvX16LE_c;
18881971 } else if (is9_OR_10BPS(dstFormat)) {
1889− if (dstFormat == PIX_FMT_YUV420P9BE || dstFormat == PIX_FMT_YUV420P9LE) {
1972+ if (av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1 == 8) {
18901973 *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX9BE_c : yuv2yuvX9LE_c;
18911974 } else {
18921975 *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX10BE_c : yuv2yuvX10LE_c;
@@ -1919,6 +2002,16 @@ find_c_packed_planar_out_funcs(SwsContext *c, · 26 unmodified lines
19192002 *yuv2packed2 = yuv2monoblack_2_c;
19202003 *yuv2packedX = yuv2monoblack_X_c;
19212004 break;
2005+ case PIX_FMT_YUYV422:
2006+ *yuv2packed1 = yuv2422yuyv_1_c;
2007+ *yuv2packed2 = yuv2422yuyv_2_c;
2008+ *yuv2packedX = yuv2422yuyv_X_c;
2009+ break;
2010+ case PIX_FMT_UYVY422:
2011+ *yuv2packed1 = yuv2422uyvy_1_c;
2012+ *yuv2packed2 = yuv2422uyvy_2_c;
2013+ *yuv2packedX = yuv2422uyvy_X_c;
2014+ break;
19222015 default:
19232016 *yuv2packed1 = yuv2packed1_c;
19242017 *yuv2packed2 = yuv2packed2_c;
@@ -2221,16 +2314,20 @@ static av_cold void sws_init_swScale_c(SwsContext *c) · 296 unmodified lines
22212314 case PIX_FMT_BGR4_BYTE:
22222315 case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break;
22232316 case PIX_FMT_GRAY16BE :
2317+ case PIX_FMT_YUV444P9BE:
22242318 case PIX_FMT_YUV420P9BE:
2319+ case PIX_FMT_YUV444P10BE:
22252320 case PIX_FMT_YUV422P10BE:
22262321 case PIX_FMT_YUV420P10BE:
22272322 case PIX_FMT_YUV420P16BE:
22282323 case PIX_FMT_YUV422P16BE:
22292324 case PIX_FMT_YUV444P16BE: c->hScale16= HAVE_BIGENDIAN ? hScale16_c : hScale16X_c; break;
22302325 case PIX_FMT_GRAY16LE :
2326+ case PIX_FMT_YUV444P9LE:
22312327 case PIX_FMT_YUV420P9LE:
22322328 case PIX_FMT_YUV422P10LE:
22332329 case PIX_FMT_YUV420P10LE:
2330+ case PIX_FMT_YUV444P10LE:
22342331 case PIX_FMT_YUV420P16LE:
22352332 case PIX_FMT_YUV422P16LE:
22362333 case PIX_FMT_YUV444P16LE: c->hScale16= HAVE_BIGENDIAN ? hScale16X_c : hScale16_c; break;
libswscale/swscale_internal.h+12−0
@@ -371,6 +371,12 @@ const char *sws_format_name(enum PixelFormat format); · 370 unmodified lines
371371 #define isNBPS(x) ( \
372372 (x)==PIX_FMT_YUV420P9LE \
373373 || (x)==PIX_FMT_YUV420P9BE \
374+ || (x)==PIX_FMT_YUV444P9BE \
375+ || (x)==PIX_FMT_YUV444P9LE \
376+ || (x)==PIX_FMT_YUV422P10BE \
377+ || (x)==PIX_FMT_YUV422P10LE \
378+ || (x)==PIX_FMT_YUV444P10BE \
379+ || (x)==PIX_FMT_YUV444P10LE \
374380 || (x)==PIX_FMT_YUV420P10LE \
375381 || (x)==PIX_FMT_YUV420P10BE \
376382 || (x)==PIX_FMT_YUV422P10LE \
@@ -392,13 +398,19 @@ const char *sws_format_name(enum PixelFormat format); · 15 unmodified lines
392398 #define isPlanarYUV(x) ( \
393399 isPlanar8YUV(x) \
394400 || (x)==PIX_FMT_YUV420P9LE \
401+ || (x)==PIX_FMT_YUV444P9LE \
395402 || (x)==PIX_FMT_YUV420P10LE \
403+ || (x)==PIX_FMT_YUV422P10LE \
404+ || (x)==PIX_FMT_YUV444P10LE \
396405 || (x)==PIX_FMT_YUV420P16LE \
397406 || (x)==PIX_FMT_YUV422P10LE \
398407 || (x)==PIX_FMT_YUV422P16LE \
399408 || (x)==PIX_FMT_YUV444P16LE \
400409 || (x)==PIX_FMT_YUV420P9BE \
410+ || (x)==PIX_FMT_YUV444P9BE \
401411 || (x)==PIX_FMT_YUV420P10BE \
412+ || (x)==PIX_FMT_YUV422P10BE \
413+ || (x)==PIX_FMT_YUV444P10BE \
402414 || (x)==PIX_FMT_YUV420P16BE \
403415 || (x)==PIX_FMT_YUV422P10BE \
404416 || (x)==PIX_FMT_YUV422P16BE \
libswscale/utils.c+6−0
@@ -112,12 +112,18 @@ const char *swscale_license(void) · 111 unmodified lines
112112 || (x)==PIX_FMT_MONOWHITE \
113113 || (x)==PIX_FMT_MONOBLACK \
114114 || (x)==PIX_FMT_YUV420P9LE \
115+ || (x)==PIX_FMT_YUV444P9LE \
115116 || (x)==PIX_FMT_YUV420P10LE \
117+ || (x)==PIX_FMT_YUV422P10LE \
118+ || (x)==PIX_FMT_YUV444P10LE \
116119 || (x)==PIX_FMT_YUV420P16LE \
117120 || (x)==PIX_FMT_YUV422P16LE \
118121 || (x)==PIX_FMT_YUV444P16LE \
119122 || (x)==PIX_FMT_YUV420P9BE \
123+ || (x)==PIX_FMT_YUV444P9BE \
120124 || (x)==PIX_FMT_YUV420P10BE \
125+ || (x)==PIX_FMT_YUV444P10BE \
126+ || (x)==PIX_FMT_YUV422P10BE \
121127 || (x)==PIX_FMT_YUV420P16BE \
122128 || (x)==PIX_FMT_YUV422P16BE \
123129 || (x)==PIX_FMT_YUV444P16BE \

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