* qatar/master:
dxva2: don't check for DXVA_PictureParameters->wDecodedPictureIndex
img2: split muxer and demuxer into separate files
rm: prevent infinite loops for index parsing.
aac: fix infinite loop on end-of-frame with sequence of 1-bits.
mov: Add more HDV and XDCAM FourCCs.
lavf: don't set AVCodecContext.has_b_frames in compute_pkt_fields().
rmdec: when using INT4 deinterleaving, error out if sub_packet_h <= 1.
cdxl: correctly synchronize video timestamps to audio
mlpdec_parser: fix a few channel layouts.
Add channel names to channel_names[] array for channels added in b2890f5
movenc: Buffer the mdat for the initial moov fragment, too
flvdec: Ignore the index if the ignidx flag is set
flvdec: Fix indentation
movdec: Don't parse all fragments if ignidx is set
movdec: Restart parsing root-level atoms at the right spot
prores: use natural integer type for the codebook index
mov: Add support for MPEG2 HDV 720p24 (hdv4)
swscale: K&R formatting cosmetics (part I)
swscale: variable declaration and placement cosmetics
Conflicts:
configure
libavcodec/aacdec.c
libavcodec/mlp_parser.c
libavformat/flvdec.c
libavformat/img2.c
libavformat/isom.h
libavformat/mov.c
libavformat/movenc.c
libswscale/rgb2rgb.c
libswscale/rgb2rgb_template.c
libswscale/yuv2rgb.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
tags/n0.11
| @@ -994,19 +994,20 @@ static int decode_band_types(AACContext *ac, enum BandType band_type[120], | |||||
| av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n"); | av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n"); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| while ((sect_len_incr = get_bits(gb, bits)) == (1 << bits) - 1 && get_bits_left(gb) >= bits) | |||||
| do { | |||||
| sect_len_incr = get_bits(gb, bits); | |||||
| sect_end += sect_len_incr; | sect_end += sect_len_incr; | ||||
| sect_end += sect_len_incr; | |||||
| if (get_bits_left(gb) < 0 || sect_len_incr == (1 << bits) - 1) { | |||||
| av_log(ac->avctx, AV_LOG_ERROR, overread_err); | |||||
| return -1; | |||||
| } | |||||
| if (sect_end > ics->max_sfb) { | |||||
| av_log(ac->avctx, AV_LOG_ERROR, | |||||
| "Number of bands (%d) exceeds limit (%d).\n", | |||||
| sect_end, ics->max_sfb); | |||||
| return -1; | |||||
| } | |||||
| if (get_bits_left(gb) < 0) { | |||||
| av_log(ac->avctx, AV_LOG_ERROR, overread_err); | |||||
| return -1; | |||||
| } | |||||
| if (sect_end > ics->max_sfb) { | |||||
| av_log(ac->avctx, AV_LOG_ERROR, | |||||
| "Number of bands (%d) exceeds limit (%d).\n", | |||||
| sect_end, ics->max_sfb); | |||||
| return -1; | |||||
| } | |||||
| } while (sect_len_incr == (1 << bits) - 1); | |||||
| for (; k < sect_end; k++) { | for (; k < sect_end; k++) { | ||||
| band_type [idx] = sect_band_type; | band_type [idx] = sect_band_type; | ||||
| band_type_run_end[idx++] = sect_end; | band_type_run_end[idx++] = sect_end; | ||||
| @@ -84,7 +84,7 @@ static const uint64_t thd_layout[13] = { | |||||
| AV_CH_BACK_CENTER, // Cs | AV_CH_BACK_CENTER, // Cs | ||||
| AV_CH_TOP_CENTER, // Ts | AV_CH_TOP_CENTER, // Ts | ||||
| AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, // LRsd - TODO: Surround Direct | AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, // LRsd - TODO: Surround Direct | ||||
| AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, // LRw - TODO: Wide | |||||
| AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT, // LRw | |||||
| AV_CH_TOP_FRONT_CENTER, // Cvh | AV_CH_TOP_FRONT_CENTER, // Cvh | ||||
| AV_CH_LOW_FREQUENCY // LFE2 | AV_CH_LOW_FREQUENCY // LFE2 | ||||
| }; | }; | ||||
| @@ -109,7 +109,8 @@ static int truehd_channels(int chanmap) | |||||
| uint64_t ff_truehd_layout(int chanmap) | uint64_t ff_truehd_layout(int chanmap) | ||||
| { | { | ||||
| int layout = 0, i; | |||||
| int i; | |||||
| uint64_t layout = 0; | |||||
| for (i = 0; i < 13; i++) | for (i = 0; i < 13; i++) | ||||
| layout |= thd_layout[i] * ((chanmap >> i) & 1); | layout |= thd_layout[i] * ((chanmap >> i) & 1); | ||||
| @@ -289,7 +289,7 @@ static int decode_picture_header(ProresContext *ctx, const uint8_t *buf, | |||||
| /** | /** | ||||
| * Read an unsigned rice/exp golomb codeword. | * Read an unsigned rice/exp golomb codeword. | ||||
| */ | */ | ||||
| static inline int decode_vlc_codeword(GetBitContext *gb, uint8_t codebook) | |||||
| static inline int decode_vlc_codeword(GetBitContext *gb, unsigned codebook) | |||||
| { | { | ||||
| unsigned int rice_order, exp_order, switch_bits; | unsigned int rice_order, exp_order, switch_bits; | ||||
| unsigned int buf, code; | unsigned int buf, code; | ||||
| @@ -229,7 +229,7 @@ static void get_slice_data(ProresContext *ctx, const uint16_t *src, | |||||
| /** | /** | ||||
| * Write an unsigned rice/exp golomb codeword. | * Write an unsigned rice/exp golomb codeword. | ||||
| */ | */ | ||||
| static inline void encode_vlc_codeword(PutBitContext *pb, uint8_t codebook, int val) | |||||
| static inline void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val) | |||||
| { | { | ||||
| unsigned int rice_order, exp_order, switch_bits, switch_val; | unsigned int rice_order, exp_order, switch_bits, switch_val; | ||||
| int exponent; | int exponent; | ||||
| @@ -393,7 +393,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, | |||||
| return total_size; | return total_size; | ||||
| } | } | ||||
| static inline int estimate_vlc(uint8_t codebook, int val) | |||||
| static inline int estimate_vlc(unsigned codebook, int val) | |||||
| { | { | ||||
| unsigned int rice_order, exp_order, switch_bits, switch_val; | unsigned int rice_order, exp_order, switch_bits, switch_val; | ||||
| int exponent; | int exponent; | ||||
| @@ -119,10 +119,10 @@ OBJS-$(CONFIG_ICO_DEMUXER) += icodec.o | |||||
| OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o | OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o | ||||
| OBJS-$(CONFIG_IDF_DEMUXER) += bintext.o | OBJS-$(CONFIG_IDF_DEMUXER) += bintext.o | ||||
| OBJS-$(CONFIG_IFF_DEMUXER) += iff.o | OBJS-$(CONFIG_IFF_DEMUXER) += iff.o | ||||
| OBJS-$(CONFIG_IMAGE2_DEMUXER) += img2.o | |||||
| OBJS-$(CONFIG_IMAGE2_MUXER) += img2.o | |||||
| OBJS-$(CONFIG_IMAGE2PIPE_DEMUXER) += img2.o | |||||
| OBJS-$(CONFIG_IMAGE2PIPE_MUXER) += img2.o | |||||
| OBJS-$(CONFIG_IMAGE2_DEMUXER) += img2dec.o img2.o | |||||
| OBJS-$(CONFIG_IMAGE2_MUXER) += img2enc.o img2.o | |||||
| OBJS-$(CONFIG_IMAGE2PIPE_DEMUXER) += img2dec.o img2.o | |||||
| OBJS-$(CONFIG_IMAGE2PIPE_MUXER) += img2enc.o img2.o | |||||
| OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o | OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o | ||||
| OBJS-$(CONFIG_IPMOVIE_DEMUXER) += ipmovie.o | OBJS-$(CONFIG_IPMOVIE_DEMUXER) += ipmovie.o | ||||
| OBJS-$(CONFIG_ISS_DEMUXER) += iss.o | OBJS-$(CONFIG_ISS_DEMUXER) += iss.o | ||||
| @@ -43,7 +43,7 @@ static int cdxl_read_header(AVFormatContext *s) | |||||
| CDXLDemuxContext *cdxl = s->priv_data; | CDXLDemuxContext *cdxl = s->priv_data; | ||||
| int ret; | int ret; | ||||
| if ((ret = av_parse_video_rate(&cdxl->fps, cdxl->framerate)) < 0) { | |||||
| if (cdxl->framerate && (ret = av_parse_video_rate(&cdxl->fps, cdxl->framerate)) < 0) { | |||||
| av_log(s, AV_LOG_ERROR, | av_log(s, AV_LOG_ERROR, | ||||
| "Could not parse framerate: %s.\n", cdxl->framerate); | "Could not parse framerate: %s.\n", cdxl->framerate); | ||||
| return ret; | return ret; | ||||
| @@ -103,8 +103,9 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt) | |||||
| st->codec->codec_id = CODEC_ID_PCM_S8; | st->codec->codec_id = CODEC_ID_PCM_S8; | ||||
| st->codec->channels = cdxl->header[1] & 0x10 ? 2 : 1; | st->codec->channels = cdxl->header[1] & 0x10 ? 2 : 1; | ||||
| st->codec->sample_rate = cdxl->sample_rate; | st->codec->sample_rate = cdxl->sample_rate; | ||||
| st->start_time = 0; | |||||
| cdxl->audio_stream_index = st->index; | cdxl->audio_stream_index = st->index; | ||||
| avpriv_set_pts_info(st, 32, 1, cdxl->sample_rate); | |||||
| avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate); | |||||
| } | } | ||||
| ret = av_get_packet(pb, pkt, audio_size); | ret = av_get_packet(pb, pkt, audio_size); | ||||
| @@ -125,8 +126,12 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt) | |||||
| st->codec->codec_id = CODEC_ID_CDXL; | st->codec->codec_id = CODEC_ID_CDXL; | ||||
| st->codec->width = width; | st->codec->width = width; | ||||
| st->codec->height = height; | st->codec->height = height; | ||||
| st->start_time = 0; | |||||
| cdxl->video_stream_index = st->index; | cdxl->video_stream_index = st->index; | ||||
| avpriv_set_pts_info(st, 63, cdxl->fps.den, cdxl->fps.num); | |||||
| if (cdxl->framerate) | |||||
| avpriv_set_pts_info(st, 64, cdxl->fps.den, cdxl->fps.num); | |||||
| else | |||||
| avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate); | |||||
| } | } | ||||
| if (av_new_packet(pkt, video_size + CDXL_HEADER_SIZE) < 0) | if (av_new_packet(pkt, video_size + CDXL_HEADER_SIZE) < 0) | ||||
| @@ -140,6 +145,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt) | |||||
| pkt->stream_index = cdxl->video_stream_index; | pkt->stream_index = cdxl->video_stream_index; | ||||
| pkt->flags |= AV_PKT_FLAG_KEY; | pkt->flags |= AV_PKT_FLAG_KEY; | ||||
| pkt->pos = pos; | pkt->pos = pos; | ||||
| pkt->duration = cdxl->framerate ? 1 : audio_size ? audio_size : 220; | |||||
| cdxl->read_chunk = audio_size; | cdxl->read_chunk = audio_size; | ||||
| } | } | ||||
| @@ -151,7 +157,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt) | |||||
| #define OFFSET(x) offsetof(CDXLDemuxContext, x) | #define OFFSET(x) offsetof(CDXLDemuxContext, x) | ||||
| static const AVOption cdxl_options[] = { | static const AVOption cdxl_options[] = { | ||||
| { "sample_rate", "", OFFSET(sample_rate), AV_OPT_TYPE_INT, { .dbl = 11025 }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, | { "sample_rate", "", OFFSET(sample_rate), AV_OPT_TYPE_INT, { .dbl = 11025 }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, | ||||
| { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, { .str = "10" }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, | |||||
| { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, | |||||
| { NULL }, | { NULL }, | ||||
| }; | }; | ||||
| @@ -149,6 +149,9 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| if (s->flags & AVFMT_FLAG_IGNIDX) | |||||
| return 0; | |||||
| while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { | while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { | ||||
| int64_t** current_array; | int64_t** current_array; | ||||
| unsigned int arraylen; | unsigned int arraylen; | ||||
| @@ -198,8 +201,9 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream | |||||
| dts |= avio_r8(ioc) << 24; | dts |= avio_r8(ioc) << 24; | ||||
| if (size0 > filepositions[1] || FFABS(dts - times[1]*1000)>5000/*arbitraray threshold to detect invalid index*/) | if (size0 > filepositions[1] || FFABS(dts - times[1]*1000)>5000/*arbitraray threshold to detect invalid index*/) | ||||
| goto invalid; | goto invalid; | ||||
| for(i = 0; i < timeslen; i++) | |||||
| av_add_index_entry(vstream, filepositions[i], times[i]*1000, 0, 0, AVINDEX_KEYFRAME); | |||||
| for(i = 0; i < timeslen; i++) | |||||
| av_add_index_entry(vstream, filepositions[i], times[i]*1000, | |||||
| 0, 0, AVINDEX_KEYFRAME); | |||||
| } else { | } else { | ||||
| invalid: | invalid: | ||||
| av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n"); | av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n"); | ||||
| @@ -20,32 +20,9 @@ | |||||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
| */ | */ | ||||
| #include "libavutil/intreadwrite.h" | |||||
| #include "libavutil/avstring.h" | #include "libavutil/avstring.h" | ||||
| #include "libavutil/log.h" | |||||
| #include "libavutil/opt.h" | |||||
| #include "libavutil/pixdesc.h" | |||||
| #include "libavutil/parseutils.h" | |||||
| #include "avformat.h" | |||||
| #include "avio_internal.h" | |||||
| #include "internal.h" | #include "internal.h" | ||||
| typedef struct { | |||||
| const AVClass *class; /**< Class for private options. */ | |||||
| int img_first; | |||||
| int img_last; | |||||
| int img_number; | |||||
| int img_count; | |||||
| int is_pipe; | |||||
| int split_planes; /**< use independent file for each Y, U, V plane */ | |||||
| char path[1024]; | |||||
| char *pixel_format; /**< Set by a private option. */ | |||||
| char *video_size; /**< Set by a private option. */ | |||||
| char *framerate; /**< Set by a private option. */ | |||||
| int loop; | |||||
| int updatefirst; | |||||
| } VideoData; | |||||
| typedef struct { | typedef struct { | ||||
| enum CodecID id; | enum CodecID id; | ||||
| const char *str; | const char *str; | ||||
| @@ -98,31 +75,6 @@ static const IdStrMap img_tags[] = { | |||||
| { CODEC_ID_NONE , NULL} | { CODEC_ID_NONE , NULL} | ||||
| }; | }; | ||||
| static const int sizes[][2] = { | |||||
| { 640, 480 }, | |||||
| { 720, 480 }, | |||||
| { 720, 576 }, | |||||
| { 352, 288 }, | |||||
| { 352, 240 }, | |||||
| { 160, 128 }, | |||||
| { 512, 384 }, | |||||
| { 640, 352 }, | |||||
| { 640, 240 }, | |||||
| }; | |||||
| static int infer_size(int *width_ptr, int *height_ptr, int size) | |||||
| { | |||||
| int i; | |||||
| for(i=0;i<FF_ARRAY_ELEMS(sizes);i++) { | |||||
| if ((sizes[i][0] * sizes[i][1]) == size) { | |||||
| *width_ptr = sizes[i][0]; | |||||
| *height_ptr = sizes[i][1]; | |||||
| return 0; | |||||
| } | |||||
| } | |||||
| return -1; | |||||
| } | |||||
| static enum CodecID av_str2id(const IdStrMap *tags, const char *str) | static enum CodecID av_str2id(const IdStrMap *tags, const char *str) | ||||
| { | { | ||||
| str= strrchr(str, '.'); | str= strrchr(str, '.'); | ||||
| @@ -142,403 +94,3 @@ enum CodecID ff_guess_image2_codec(const char *filename) | |||||
| { | { | ||||
| return av_str2id(img_tags, filename); | return av_str2id(img_tags, filename); | ||||
| } | } | ||||
| /* return -1 if no image found */ | |||||
| static int find_image_range(int *pfirst_index, int *plast_index, | |||||
| const char *path) | |||||
| { | |||||
| char buf[1024]; | |||||
| int range, last_index, range1, first_index; | |||||
| /* find the first image */ | |||||
| for(first_index = 0; first_index < 5; first_index++) { | |||||
| if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){ | |||||
| *pfirst_index = | |||||
| *plast_index = 1; | |||||
| if (avio_check(buf, AVIO_FLAG_READ) > 0) | |||||
| return 0; | |||||
| return -1; | |||||
| } | |||||
| if (avio_check(buf, AVIO_FLAG_READ) > 0) | |||||
| break; | |||||
| } | |||||
| if (first_index == 5) | |||||
| goto fail; | |||||
| /* find the last image */ | |||||
| last_index = first_index; | |||||
| for(;;) { | |||||
| range = 0; | |||||
| for(;;) { | |||||
| if (!range) | |||||
| range1 = 1; | |||||
| else | |||||
| range1 = 2 * range; | |||||
| if (av_get_frame_filename(buf, sizeof(buf), path, | |||||
| last_index + range1) < 0) | |||||
| goto fail; | |||||
| if (avio_check(buf, AVIO_FLAG_READ) <= 0) | |||||
| break; | |||||
| range = range1; | |||||
| /* just in case... */ | |||||
| if (range >= (1 << 30)) | |||||
| goto fail; | |||||
| } | |||||
| /* we are sure than image last_index + range exists */ | |||||
| if (!range) | |||||
| break; | |||||
| last_index += range; | |||||
| } | |||||
| *pfirst_index = first_index; | |||||
| *plast_index = last_index; | |||||
| return 0; | |||||
| fail: | |||||
| return -1; | |||||
| } | |||||
| static int read_probe(AVProbeData *p) | |||||
| { | |||||
| if (p->filename && ff_guess_image2_codec(p->filename)) { | |||||
| if (av_filename_number_test(p->filename)) | |||||
| return AVPROBE_SCORE_MAX; | |||||
| else | |||||
| return AVPROBE_SCORE_MAX/2; | |||||
| } | |||||
| return 0; | |||||
| } | |||||
| static int read_header(AVFormatContext *s1) | |||||
| { | |||||
| VideoData *s = s1->priv_data; | |||||
| int first_index, last_index, ret = 0; | |||||
| int width = 0, height = 0; | |||||
| AVStream *st; | |||||
| enum PixelFormat pix_fmt = PIX_FMT_NONE; | |||||
| AVRational framerate; | |||||
| s1->ctx_flags |= AVFMTCTX_NOHEADER; | |||||
| st = avformat_new_stream(s1, NULL); | |||||
| if (!st) { | |||||
| return AVERROR(ENOMEM); | |||||
| } | |||||
| if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) { | |||||
| av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format); | |||||
| return AVERROR(EINVAL); | |||||
| } | |||||
| if (s->video_size && (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) { | |||||
| av_log(s, AV_LOG_ERROR, "Could not parse video size: %s.\n", s->video_size); | |||||
| return ret; | |||||
| } | |||||
| if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) { | |||||
| av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate); | |||||
| return ret; | |||||
| } | |||||
| av_strlcpy(s->path, s1->filename, sizeof(s->path)); | |||||
| s->img_number = 0; | |||||
| s->img_count = 0; | |||||
| /* find format */ | |||||
| if (s1->iformat->flags & AVFMT_NOFILE) | |||||
| s->is_pipe = 0; | |||||
| else{ | |||||
| s->is_pipe = 1; | |||||
| st->need_parsing = AVSTREAM_PARSE_FULL; | |||||
| } | |||||
| avpriv_set_pts_info(st, 60, framerate.den, framerate.num); | |||||
| if (width && height) { | |||||
| st->codec->width = width; | |||||
| st->codec->height = height; | |||||
| } | |||||
| if (!s->is_pipe) { | |||||
| if (find_image_range(&first_index, &last_index, s->path) < 0) | |||||
| return AVERROR(ENOENT); | |||||
| s->img_first = first_index; | |||||
| s->img_last = last_index; | |||||
| s->img_number = first_index; | |||||
| /* compute duration */ | |||||
| st->start_time = 0; | |||||
| st->duration = last_index - first_index + 1; | |||||
| } | |||||
| if(s1->video_codec_id){ | |||||
| st->codec->codec_type = AVMEDIA_TYPE_VIDEO; | |||||
| st->codec->codec_id = s1->video_codec_id; | |||||
| }else if(s1->audio_codec_id){ | |||||
| st->codec->codec_type = AVMEDIA_TYPE_AUDIO; | |||||
| st->codec->codec_id = s1->audio_codec_id; | |||||
| }else{ | |||||
| const char *str= strrchr(s->path, '.'); | |||||
| s->split_planes = str && !av_strcasecmp(str + 1, "y"); | |||||
| st->codec->codec_type = AVMEDIA_TYPE_VIDEO; | |||||
| st->codec->codec_id = ff_guess_image2_codec(s->path); | |||||
| if (st->codec->codec_id == CODEC_ID_LJPEG) | |||||
| st->codec->codec_id = CODEC_ID_MJPEG; | |||||
| } | |||||
| if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != PIX_FMT_NONE) | |||||
| st->codec->pix_fmt = pix_fmt; | |||||
| return 0; | |||||
| } | |||||
| static int read_packet(AVFormatContext *s1, AVPacket *pkt) | |||||
| { | |||||
| VideoData *s = s1->priv_data; | |||||
| char filename[1024]; | |||||
| int i; | |||||
| int size[3]={0}, ret[3]={0}; | |||||
| AVIOContext *f[3]; | |||||
| AVCodecContext *codec= s1->streams[0]->codec; | |||||
| if (!s->is_pipe) { | |||||
| /* loop over input */ | |||||
| if (s->loop && s->img_number > s->img_last) { | |||||
| s->img_number = s->img_first; | |||||
| } | |||||
| if (s->img_number > s->img_last) | |||||
| return AVERROR_EOF; | |||||
| if (av_get_frame_filename(filename, sizeof(filename), | |||||
| s->path, s->img_number)<0 && s->img_number > 1) | |||||
| return AVERROR(EIO); | |||||
| for(i=0; i<3; i++){ | |||||
| if (avio_open2(&f[i], filename, AVIO_FLAG_READ, | |||||
| &s1->interrupt_callback, NULL) < 0) { | |||||
| if(i==1) | |||||
| break; | |||||
| av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename); | |||||
| return AVERROR(EIO); | |||||
| } | |||||
| size[i]= avio_size(f[i]); | |||||
| if(!s->split_planes) | |||||
| break; | |||||
| filename[ strlen(filename) - 1 ]= 'U' + i; | |||||
| } | |||||
| if(codec->codec_id == CODEC_ID_RAWVIDEO && !codec->width) | |||||
| infer_size(&codec->width, &codec->height, size[0]); | |||||
| } else { | |||||
| f[0] = s1->pb; | |||||
| if (url_feof(f[0])) | |||||
| return AVERROR(EIO); | |||||
| size[0]= 4096; | |||||
| } | |||||
| av_new_packet(pkt, size[0] + size[1] + size[2]); | |||||
| pkt->stream_index = 0; | |||||
| pkt->flags |= AV_PKT_FLAG_KEY; | |||||
| pkt->size= 0; | |||||
| for(i=0; i<3; i++){ | |||||
| if(size[i]){ | |||||
| ret[i]= avio_read(f[i], pkt->data + pkt->size, size[i]); | |||||
| if (!s->is_pipe) | |||||
| avio_close(f[i]); | |||||
| if(ret[i]>0) | |||||
| pkt->size += ret[i]; | |||||
| } | |||||
| } | |||||
| if (ret[0] <= 0 || ret[1]<0 || ret[2]<0) { | |||||
| av_free_packet(pkt); | |||||
| return AVERROR(EIO); /* signal EOF */ | |||||
| } else { | |||||
| s->img_count++; | |||||
| s->img_number++; | |||||
| return 0; | |||||
| } | |||||
| } | |||||
| #if CONFIG_IMAGE2_MUXER || CONFIG_IMAGE2PIPE_MUXER | |||||
| /******************************************************/ | |||||
| /* image output */ | |||||
| static int write_header(AVFormatContext *s) | |||||
| { | |||||
| VideoData *img = s->priv_data; | |||||
| const char *str; | |||||
| img->img_number = 1; | |||||
| av_strlcpy(img->path, s->filename, sizeof(img->path)); | |||||
| /* find format */ | |||||
| if (s->oformat->flags & AVFMT_NOFILE) | |||||
| img->is_pipe = 0; | |||||
| else | |||||
| img->is_pipe = 1; | |||||
| str = strrchr(img->path, '.'); | |||||
| img->split_planes = str && !av_strcasecmp(str + 1, "y"); | |||||
| return 0; | |||||
| } | |||||
| static int write_packet(AVFormatContext *s, AVPacket *pkt) | |||||
| { | |||||
| VideoData *img = s->priv_data; | |||||
| AVIOContext *pb[3]; | |||||
| char filename[1024]; | |||||
| AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec; | |||||
| int i; | |||||
| if (!img->is_pipe) { | |||||
| if (av_get_frame_filename(filename, sizeof(filename), | |||||
| img->path, img->img_number) < 0 && img->img_number>1 && !img->updatefirst) { | |||||
| av_log(s, AV_LOG_ERROR, | |||||
| "Could not get frame filename number %d from pattern '%s'\n", | |||||
| img->img_number, img->path); | |||||
| return AVERROR(EINVAL); | |||||
| } | |||||
| for(i=0; i<3; i++){ | |||||
| if (avio_open2(&pb[i], filename, AVIO_FLAG_WRITE, | |||||
| &s->interrupt_callback, NULL) < 0) { | |||||
| av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename); | |||||
| return AVERROR(EIO); | |||||
| } | |||||
| if(!img->split_planes) | |||||
| break; | |||||
| filename[ strlen(filename) - 1 ]= 'U' + i; | |||||
| } | |||||
| } else { | |||||
| pb[0] = s->pb; | |||||
| } | |||||
| if(img->split_planes){ | |||||
| int ysize = codec->width * codec->height; | |||||
| avio_write(pb[0], pkt->data , ysize); | |||||
| avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize)/2); | |||||
| avio_write(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2); | |||||
| avio_flush(pb[1]); | |||||
| avio_flush(pb[2]); | |||||
| avio_close(pb[1]); | |||||
| avio_close(pb[2]); | |||||
| }else{ | |||||
| if (ff_guess_image2_codec(s->filename) == CODEC_ID_JPEG2000) { | |||||
| AVStream *st = s->streams[0]; | |||||
| if(st->codec->extradata_size > 8 && | |||||
| AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){ | |||||
| if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c')) | |||||
| goto error; | |||||
| avio_wb32(pb[0], 12); | |||||
| ffio_wfourcc(pb[0], "jP "); | |||||
| avio_wb32(pb[0], 0x0D0A870A); // signature | |||||
| avio_wb32(pb[0], 20); | |||||
| ffio_wfourcc(pb[0], "ftyp"); | |||||
| ffio_wfourcc(pb[0], "jp2 "); | |||||
| avio_wb32(pb[0], 0); | |||||
| ffio_wfourcc(pb[0], "jp2 "); | |||||
| avio_write(pb[0], st->codec->extradata, st->codec->extradata_size); | |||||
| }else if(pkt->size >= 8 && AV_RB32(pkt->data) == 0xFF4FFF51){ | |||||
| //jpeg2000 codestream | |||||
| }else if(pkt->size < 8 || | |||||
| (!st->codec->extradata_size && | |||||
| AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature | |||||
| error: | |||||
| av_log(s, AV_LOG_ERROR, "malformed JPEG 2000 codestream %X\n", AV_RB32(pkt->data)); | |||||
| return -1; | |||||
| } | |||||
| } | |||||
| avio_write(pb[0], pkt->data, pkt->size); | |||||
| } | |||||
| avio_flush(pb[0]); | |||||
| if (!img->is_pipe) { | |||||
| avio_close(pb[0]); | |||||
| } | |||||
| img->img_number++; | |||||
| return 0; | |||||
| } | |||||
| #endif /* CONFIG_IMAGE2_MUXER || CONFIG_IMAGE2PIPE_MUXER */ | |||||
| #define OFFSET(x) offsetof(VideoData, x) | |||||
| #define DEC AV_OPT_FLAG_DECODING_PARAM | |||||
| #define ENC AV_OPT_FLAG_ENCODING_PARAM | |||||
| static const AVOption options[] = { | |||||
| { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, | |||||
| { "video_size", "", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, | |||||
| { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, | |||||
| { "loop", "", OFFSET(loop), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, DEC }, | |||||
| { NULL }, | |||||
| }; | |||||
| static const AVOption muxoptions[] = { | |||||
| { "updatefirst", "", OFFSET(updatefirst), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, ENC }, | |||||
| { NULL }, | |||||
| }; | |||||
| /* input */ | |||||
| #if CONFIG_IMAGE2_DEMUXER | |||||
| static const AVClass img2_class = { | |||||
| .class_name = "image2 demuxer", | |||||
| .item_name = av_default_item_name, | |||||
| .option = options, | |||||
| .version = LIBAVUTIL_VERSION_INT, | |||||
| }; | |||||
| AVInputFormat ff_image2_demuxer = { | |||||
| .name = "image2", | |||||
| .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), | |||||
| .priv_data_size = sizeof(VideoData), | |||||
| .read_probe = read_probe, | |||||
| .read_header = read_header, | |||||
| .read_packet = read_packet, | |||||
| .flags = AVFMT_NOFILE, | |||||
| .priv_class = &img2_class, | |||||
| }; | |||||
| #endif | |||||
| #if CONFIG_IMAGE2PIPE_DEMUXER | |||||
| static const AVClass img2pipe_class = { | |||||
| .class_name = "image2pipe demuxer", | |||||
| .item_name = av_default_item_name, | |||||
| .option = options, | |||||
| .version = LIBAVUTIL_VERSION_INT, | |||||
| }; | |||||
| AVInputFormat ff_image2pipe_demuxer = { | |||||
| .name = "image2pipe", | |||||
| .long_name = NULL_IF_CONFIG_SMALL("piped image2 sequence"), | |||||
| .priv_data_size = sizeof(VideoData), | |||||
| .read_header = read_header, | |||||
| .read_packet = read_packet, | |||||
| .priv_class = &img2pipe_class, | |||||
| }; | |||||
| #endif | |||||
| /* output */ | |||||
| #if CONFIG_IMAGE2_MUXER | |||||
| static const AVClass img2mux_class = { | |||||
| .class_name = "image2 muxer", | |||||
| .item_name = av_default_item_name, | |||||
| .option = muxoptions, | |||||
| .version = LIBAVUTIL_VERSION_INT, | |||||
| }; | |||||
| AVOutputFormat ff_image2_muxer = { | |||||
| .name = "image2", | |||||
| .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), | |||||
| .extensions = "bmp,dpx,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png," | |||||
| "ppm,sgi,tga,tif,tiff,jp2,j2c,xwd,sun,ras,rs,im1,im8,im24," | |||||
| "sunras", | |||||
| .priv_data_size = sizeof(VideoData), | |||||
| .video_codec = CODEC_ID_MJPEG, | |||||
| .write_header = write_header, | |||||
| .write_packet = write_packet, | |||||
| .flags = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | AVFMT_NOFILE, | |||||
| .priv_class = &img2mux_class, | |||||
| }; | |||||
| #endif | |||||
| #if CONFIG_IMAGE2PIPE_MUXER | |||||
| AVOutputFormat ff_image2pipe_muxer = { | |||||
| .name = "image2pipe", | |||||
| .long_name = NULL_IF_CONFIG_SMALL("piped image2 sequence"), | |||||
| .priv_data_size = sizeof(VideoData), | |||||
| .video_codec = CODEC_ID_MJPEG, | |||||
| .write_header = write_header, | |||||
| .write_packet = write_packet, | |||||
| .flags = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | |||||
| }; | |||||
| #endif | |||||
| @@ -0,0 +1,327 @@ | |||||
| /* | |||||
| * Image format | |||||
| * Copyright (c) 2000, 2001, 2002 Fabrice Bellard | |||||
| * Copyright (c) 2004 Michael Niedermayer | |||||
| * | |||||
| * This file is part of FFmpeg. | |||||
| * | |||||
| * FFmpeg is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU Lesser General Public | |||||
| * License as published by the Free Software Foundation; either | |||||
| * version 2.1 of the License, or (at your option) any later version. | |||||
| * | |||||
| * FFmpeg is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
| * Lesser General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU Lesser General Public | |||||
| * License along with FFmpeg; if not, write to the Free Software | |||||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||||
| */ | |||||
| #include "libavutil/avstring.h" | |||||
| #include "libavutil/log.h" | |||||
| #include "libavutil/opt.h" | |||||
| #include "libavutil/pixdesc.h" | |||||
| #include "libavutil/parseutils.h" | |||||
| #include "avformat.h" | |||||
| #include "internal.h" | |||||
| typedef struct { | |||||
| const AVClass *class; /**< Class for private options. */ | |||||
| int img_first; | |||||
| int img_last; | |||||
| int img_number; | |||||
| int img_count; | |||||
| int is_pipe; | |||||
| int split_planes; /**< use independent file for each Y, U, V plane */ | |||||
| char path[1024]; | |||||
| char *pixel_format; /**< Set by a private option. */ | |||||
| char *video_size; /**< Set by a private option. */ | |||||
| char *framerate; /**< Set by a private option. */ | |||||
| int loop; | |||||
| } VideoDemuxData; | |||||
| static const int sizes[][2] = { | |||||
| { 640, 480 }, | |||||
| { 720, 480 }, | |||||
| { 720, 576 }, | |||||
| { 352, 288 }, | |||||
| { 352, 240 }, | |||||
| { 160, 128 }, | |||||
| { 512, 384 }, | |||||
| { 640, 352 }, | |||||
| { 640, 240 }, | |||||
| }; | |||||
| static int infer_size(int *width_ptr, int *height_ptr, int size) | |||||
| { | |||||
| int i; | |||||
| for(i=0;i<FF_ARRAY_ELEMS(sizes);i++) { | |||||
| if ((sizes[i][0] * sizes[i][1]) == size) { | |||||
| *width_ptr = sizes[i][0]; | |||||
| *height_ptr = sizes[i][1]; | |||||
| return 0; | |||||
| } | |||||
| } | |||||
| return -1; | |||||
| } | |||||
| /* return -1 if no image found */ | |||||
| static int find_image_range(int *pfirst_index, int *plast_index, | |||||
| const char *path) | |||||
| { | |||||
| char buf[1024]; | |||||
| int range, last_index, range1, first_index; | |||||
| /* find the first image */ | |||||
| for(first_index = 0; first_index < 5; first_index++) { | |||||
| if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){ | |||||
| *pfirst_index = | |||||
| *plast_index = 1; | |||||
| if (avio_check(buf, AVIO_FLAG_READ) > 0) | |||||
| return 0; | |||||
| return -1; | |||||
| } | |||||
| if (avio_check(buf, AVIO_FLAG_READ) > 0) | |||||
| break; | |||||
| } | |||||
| if (first_index == 5) | |||||
| goto fail; | |||||
| /* find the last image */ | |||||
| last_index = first_index; | |||||
| for(;;) { | |||||
| range = 0; | |||||
| for(;;) { | |||||
| if (!range) | |||||
| range1 = 1; | |||||
| else | |||||
| range1 = 2 * range; | |||||
| if (av_get_frame_filename(buf, sizeof(buf), path, | |||||
| last_index + range1) < 0) | |||||
| goto fail; | |||||
| if (avio_check(buf, AVIO_FLAG_READ) <= 0) | |||||
| break; | |||||
| range = range1; | |||||
| /* just in case... */ | |||||
| if (range >= (1 << 30)) | |||||
| goto fail; | |||||
| } | |||||
| /* we are sure than image last_index + range exists */ | |||||
| if (!range) | |||||
| break; | |||||
| last_index += range; | |||||
| } | |||||
| *pfirst_index = first_index; | |||||
| *plast_index = last_index; | |||||
| return 0; | |||||
| fail: | |||||
| return -1; | |||||
| } | |||||
| static int read_probe(AVProbeData *p) | |||||
| { | |||||
| if (p->filename && ff_guess_image2_codec(p->filename)) { | |||||
| if (av_filename_number_test(p->filename)) | |||||
| return AVPROBE_SCORE_MAX; | |||||
| else | |||||
| return AVPROBE_SCORE_MAX/2; | |||||
| } | |||||
| return 0; | |||||
| } | |||||
| static int read_header(AVFormatContext *s1) | |||||
| { | |||||
| VideoDemuxData *s = s1->priv_data; | |||||
| int first_index, last_index, ret = 0; | |||||
| int width = 0, height = 0; | |||||
| AVStream *st; | |||||
| enum PixelFormat pix_fmt = PIX_FMT_NONE; | |||||
| AVRational framerate; | |||||
| s1->ctx_flags |= AVFMTCTX_NOHEADER; | |||||
| st = avformat_new_stream(s1, NULL); | |||||
| if (!st) { | |||||
| return AVERROR(ENOMEM); | |||||
| } | |||||
| if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) { | |||||
| av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format); | |||||
| return AVERROR(EINVAL); | |||||
| } | |||||
| if (s->video_size && (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) { | |||||
| av_log(s, AV_LOG_ERROR, "Could not parse video size: %s.\n", s->video_size); | |||||
| return ret; | |||||
| } | |||||
| if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) { | |||||
| av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate); | |||||
| return ret; | |||||
| } | |||||
| av_strlcpy(s->path, s1->filename, sizeof(s->path)); | |||||
| s->img_number = 0; | |||||
| s->img_count = 0; | |||||
| /* find format */ | |||||
| if (s1->iformat->flags & AVFMT_NOFILE) | |||||
| s->is_pipe = 0; | |||||
| else{ | |||||
| s->is_pipe = 1; | |||||
| st->need_parsing = AVSTREAM_PARSE_FULL; | |||||
| } | |||||
| avpriv_set_pts_info(st, 60, framerate.den, framerate.num); | |||||
| if (width && height) { | |||||
| st->codec->width = width; | |||||
| st->codec->height = height; | |||||
| } | |||||
| if (!s->is_pipe) { | |||||
| if (find_image_range(&first_index, &last_index, s->path) < 0) | |||||
| return AVERROR(ENOENT); | |||||
| s->img_first = first_index; | |||||
| s->img_last = last_index; | |||||
| s->img_number = first_index; | |||||
| /* compute duration */ | |||||
| st->start_time = 0; | |||||
| st->duration = last_index - first_index + 1; | |||||
| } | |||||
| if(s1->video_codec_id){ | |||||
| st->codec->codec_type = AVMEDIA_TYPE_VIDEO; | |||||
| st->codec->codec_id = s1->video_codec_id; | |||||
| }else if(s1->audio_codec_id){ | |||||
| st->codec->codec_type = AVMEDIA_TYPE_AUDIO; | |||||
| st->codec->codec_id = s1->audio_codec_id; | |||||
| }else{ | |||||
| const char *str= strrchr(s->path, '.'); | |||||
| s->split_planes = str && !av_strcasecmp(str + 1, "y"); | |||||
| st->codec->codec_type = AVMEDIA_TYPE_VIDEO; | |||||
| st->codec->codec_id = ff_guess_image2_codec(s->path); | |||||
| if (st->codec->codec_id == CODEC_ID_LJPEG) | |||||
| st->codec->codec_id = CODEC_ID_MJPEG; | |||||
| } | |||||
| if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != PIX_FMT_NONE) | |||||
| st->codec->pix_fmt = pix_fmt; | |||||
| return 0; | |||||
| } | |||||
| static int read_packet(AVFormatContext *s1, AVPacket *pkt) | |||||
| { | |||||
| VideoDemuxData *s = s1->priv_data; | |||||
| char filename[1024]; | |||||
| int i; | |||||
| int size[3]={0}, ret[3]={0}; | |||||
| AVIOContext *f[3]; | |||||
| AVCodecContext *codec= s1->streams[0]->codec; | |||||
| if (!s->is_pipe) { | |||||
| /* loop over input */ | |||||
| if (s->loop && s->img_number > s->img_last) { | |||||
| s->img_number = s->img_first; | |||||
| } | |||||
| if (s->img_number > s->img_last) | |||||
| return AVERROR_EOF; | |||||
| if (av_get_frame_filename(filename, sizeof(filename), | |||||
| s->path, s->img_number)<0 && s->img_number > 1) | |||||
| return AVERROR(EIO); | |||||
| for(i=0; i<3; i++){ | |||||
| if (avio_open2(&f[i], filename, AVIO_FLAG_READ, | |||||
| &s1->interrupt_callback, NULL) < 0) { | |||||
| if(i==1) | |||||
| break; | |||||
| av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename); | |||||
| return AVERROR(EIO); | |||||
| } | |||||
| size[i]= avio_size(f[i]); | |||||
| if(!s->split_planes) | |||||
| break; | |||||
| filename[ strlen(filename) - 1 ]= 'U' + i; | |||||
| } | |||||
| if(codec->codec_id == CODEC_ID_RAWVIDEO && !codec->width) | |||||
| infer_size(&codec->width, &codec->height, size[0]); | |||||
| } else { | |||||
| f[0] = s1->pb; | |||||
| if (url_feof(f[0])) | |||||
| return AVERROR(EIO); | |||||
| size[0]= 4096; | |||||
| } | |||||
| av_new_packet(pkt, size[0] + size[1] + size[2]); | |||||
| pkt->stream_index = 0; | |||||
| pkt->flags |= AV_PKT_FLAG_KEY; | |||||
| pkt->size= 0; | |||||
| for(i=0; i<3; i++){ | |||||
| if(size[i]){ | |||||
| ret[i]= avio_read(f[i], pkt->data + pkt->size, size[i]); | |||||
| if (!s->is_pipe) | |||||
| avio_close(f[i]); | |||||
| if(ret[i]>0) | |||||
| pkt->size += ret[i]; | |||||
| } | |||||
| } | |||||
| if (ret[0] <= 0 || ret[1]<0 || ret[2]<0) { | |||||
| av_free_packet(pkt); | |||||
| return AVERROR(EIO); /* signal EOF */ | |||||
| } else { | |||||
| s->img_count++; | |||||
| s->img_number++; | |||||
| return 0; | |||||
| } | |||||
| } | |||||
| #define OFFSET(x) offsetof(VideoDemuxData, x) | |||||
| #define DEC AV_OPT_FLAG_DECODING_PARAM | |||||
| static const AVOption options[] = { | |||||
| { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, | |||||
| { "video_size", "", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, | |||||
| { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, | |||||
| { "loop", "", OFFSET(loop), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, DEC }, | |||||
| { NULL }, | |||||
| }; | |||||
| #if CONFIG_IMAGE2_DEMUXER | |||||
| static const AVClass img2_class = { | |||||
| .class_name = "image2 demuxer", | |||||
| .item_name = av_default_item_name, | |||||
| .option = options, | |||||
| .version = LIBAVUTIL_VERSION_INT, | |||||
| }; | |||||
| AVInputFormat ff_image2_demuxer = { | |||||
| .name = "image2", | |||||
| .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), | |||||
| .priv_data_size = sizeof(VideoDemuxData), | |||||
| .read_probe = read_probe, | |||||
| .read_header = read_header, | |||||
| .read_packet = read_packet, | |||||
| .flags = AVFMT_NOFILE, | |||||
| .priv_class = &img2_class, | |||||
| }; | |||||
| #endif | |||||
| #if CONFIG_IMAGE2PIPE_DEMUXER | |||||
| static const AVClass img2pipe_class = { | |||||
| .class_name = "image2pipe demuxer", | |||||
| .item_name = av_default_item_name, | |||||
| .option = options, | |||||
| .version = LIBAVUTIL_VERSION_INT, | |||||
| }; | |||||
| AVInputFormat ff_image2pipe_demuxer = { | |||||
| .name = "image2pipe", | |||||
| .long_name = NULL_IF_CONFIG_SMALL("piped image2 sequence"), | |||||
| .priv_data_size = sizeof(VideoDemuxData), | |||||
| .read_header = read_header, | |||||
| .read_packet = read_packet, | |||||
| .priv_class = &img2pipe_class, | |||||
| }; | |||||
| #endif | |||||
| @@ -0,0 +1,175 @@ | |||||
| /* | |||||
| * Image format | |||||
| * Copyright (c) 2000, 2001, 2002 Fabrice Bellard | |||||
| * Copyright (c) 2004 Michael Niedermayer | |||||
| * | |||||
| * This file is part of FFmpeg. | |||||
| * | |||||
| * FFmpeg is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU Lesser General Public | |||||
| * License as published by the Free Software Foundation; either | |||||
| * version 2.1 of the License, or (at your option) any later version. | |||||
| * | |||||
| * FFmpeg is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
| * Lesser General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU Lesser General Public | |||||
| * License along with FFmpeg; if not, write to the Free Software | |||||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||||
| */ | |||||
| #include "libavutil/intreadwrite.h" | |||||
| #include "libavutil/avstring.h" | |||||
| #include "libavutil/log.h" | |||||
| #include "libavutil/opt.h" | |||||
| #include "avformat.h" | |||||
| #include "avio_internal.h" | |||||
| #include "internal.h" | |||||
| typedef struct { | |||||
| const AVClass *class; /**< Class for private options. */ | |||||
| int img_number; | |||||
| int is_pipe; | |||||
| int split_planes; /**< use independent file for each Y, U, V plane */ | |||||
| char path[1024]; | |||||
| int updatefirst; | |||||
| } VideoMuxData; | |||||
| static int write_header(AVFormatContext *s) | |||||
| { | |||||
| VideoMuxData *img = s->priv_data; | |||||
| const char *str; | |||||
| img->img_number = 1; | |||||
| av_strlcpy(img->path, s->filename, sizeof(img->path)); | |||||
| /* find format */ | |||||
| if (s->oformat->flags & AVFMT_NOFILE) | |||||
| img->is_pipe = 0; | |||||
| else | |||||
| img->is_pipe = 1; | |||||
| str = strrchr(img->path, '.'); | |||||
| img->split_planes = str && !av_strcasecmp(str + 1, "y"); | |||||
| return 0; | |||||
| } | |||||
| static int write_packet(AVFormatContext *s, AVPacket *pkt) | |||||
| { | |||||
| VideoMuxData *img = s->priv_data; | |||||
| AVIOContext *pb[3]; | |||||
| char filename[1024]; | |||||
| AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec; | |||||
| int i; | |||||
| if (!img->is_pipe) { | |||||
| if (av_get_frame_filename(filename, sizeof(filename), | |||||
| img->path, img->img_number) < 0 && img->img_number>1 && !img->updatefirst) { | |||||
| av_log(s, AV_LOG_ERROR, | |||||
| "Could not get frame filename number %d from pattern '%s'\n", | |||||
| img->img_number, img->path); | |||||
| return AVERROR(EINVAL); | |||||
| } | |||||
| for(i=0; i<3; i++){ | |||||
| if (avio_open2(&pb[i], filename, AVIO_FLAG_WRITE, | |||||
| &s->interrupt_callback, NULL) < 0) { | |||||
| av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename); | |||||
| return AVERROR(EIO); | |||||
| } | |||||
| if(!img->split_planes) | |||||
| break; | |||||
| filename[ strlen(filename) - 1 ]= 'U' + i; | |||||
| } | |||||
| } else { | |||||
| pb[0] = s->pb; | |||||
| } | |||||
| if(img->split_planes){ | |||||
| int ysize = codec->width * codec->height; | |||||
| avio_write(pb[0], pkt->data , ysize); | |||||
| avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize)/2); | |||||
| avio_write(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2); | |||||
| avio_flush(pb[1]); | |||||
| avio_flush(pb[2]); | |||||
| avio_close(pb[1]); | |||||
| avio_close(pb[2]); | |||||
| }else{ | |||||
| if(ff_guess_image2_codec(s->filename) == CODEC_ID_JPEG2000){ | |||||
| AVStream *st = s->streams[0]; | |||||
| if(st->codec->extradata_size > 8 && | |||||
| AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){ | |||||
| if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c')) | |||||
| goto error; | |||||
| avio_wb32(pb[0], 12); | |||||
| ffio_wfourcc(pb[0], "jP "); | |||||
| avio_wb32(pb[0], 0x0D0A870A); // signature | |||||
| avio_wb32(pb[0], 20); | |||||
| ffio_wfourcc(pb[0], "ftyp"); | |||||
| ffio_wfourcc(pb[0], "jp2 "); | |||||
| avio_wb32(pb[0], 0); | |||||
| ffio_wfourcc(pb[0], "jp2 "); | |||||
| avio_write(pb[0], st->codec->extradata, st->codec->extradata_size); | |||||
| }else if(pkt->size >= 8 && AV_RB32(pkt->data) == 0xFF4FFF51){ | |||||
| //jpeg2000 codestream | |||||
| }else if(pkt->size < 8 || | |||||
| (!st->codec->extradata_size && | |||||
| AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature | |||||
| error: | |||||
| av_log(s, AV_LOG_ERROR, "malformed JPEG 2000 codestream %X\n", AV_RB32(pkt->data)); | |||||
| return -1; | |||||
| } | |||||
| } | |||||
| avio_write(pb[0], pkt->data, pkt->size); | |||||
| } | |||||
| avio_flush(pb[0]); | |||||
| if (!img->is_pipe) { | |||||
| avio_close(pb[0]); | |||||
| } | |||||
| img->img_number++; | |||||
| return 0; | |||||
| } | |||||
| #define OFFSET(x) offsetof(VideoMuxData, x) | |||||
| #define ENC AV_OPT_FLAG_ENCODING_PARAM | |||||
| static const AVOption muxoptions[] = { | |||||
| { "updatefirst", "", OFFSET(updatefirst), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, ENC }, | |||||
| { NULL }, | |||||
| }; | |||||
| #if CONFIG_IMAGE2_MUXER | |||||
| static const AVClass img2mux_class = { | |||||
| .class_name = "image2 muxer", | |||||
| .item_name = av_default_item_name, | |||||
| .option = muxoptions, | |||||
| .version = LIBAVUTIL_VERSION_INT, | |||||
| }; | |||||
| AVOutputFormat ff_image2_muxer = { | |||||
| .name = "image2", | |||||
| .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), | |||||
| .extensions = "bmp,dpx,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png," | |||||
| "ppm,sgi,tga,tif,tiff,jp2,j2c,xwd,sun,ras,rs,im1,im8,im24," | |||||
| "sunras", | |||||
| .priv_data_size = sizeof(VideoMuxData), | |||||
| .video_codec = CODEC_ID_MJPEG, | |||||
| .write_header = write_header, | |||||
| .write_packet = write_packet, | |||||
| .flags = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | AVFMT_NOFILE, | |||||
| .priv_class = &img2mux_class, | |||||
| }; | |||||
| #endif | |||||
| #if CONFIG_IMAGE2PIPE_MUXER | |||||
| AVOutputFormat ff_image2pipe_muxer = { | |||||
| .name = "image2pipe", | |||||
| .long_name = NULL_IF_CONFIG_SMALL("piped image2 sequence"), | |||||
| .priv_data_size = sizeof(VideoMuxData), | |||||
| .video_codec = CODEC_ID_MJPEG, | |||||
| .write_header = write_header, | |||||
| .write_packet = write_packet, | |||||
| .flags = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | |||||
| }; | |||||
| #endif | |||||
| @@ -166,10 +166,13 @@ const AVCodecTag ff_codec_movvideo_tags[] = { | |||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '1') }, /* MPEG2 HDV 720p30 */ | { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '1') }, /* MPEG2 HDV 720p30 */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '2') }, /* MPEG2 HDV 1080i60 */ | { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '2') }, /* MPEG2 HDV 1080i60 */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '3') }, /* MPEG2 HDV 1080i50 */ | { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '3') }, /* MPEG2 HDV 1080i50 */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '4') }, /* MPEG2 HDV 720p24 */ | |||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '5') }, /* MPEG2 HDV 720p25 */ | { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '5') }, /* MPEG2 HDV 720p25 */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '6') }, /* MPEG2 HDV 1080p24 */ | { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '6') }, /* MPEG2 HDV 1080p24 */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '7') }, /* MPEG2 HDV 1080p25 */ | { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '7') }, /* MPEG2 HDV 1080p25 */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '8') }, /* MPEG2 HDV 1080p30 */ | { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '8') }, /* MPEG2 HDV 1080p30 */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '9') }, /* MPEG2 HDV 720p60 JVC */ | |||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', 'a') }, /* MPEG2 HDV 720p50 */ | |||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'n') }, /* MPEG2 IMX NTSC 525/60 50mb/s produced by FCP */ | { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'n') }, /* MPEG2 IMX NTSC 525/60 50mb/s produced by FCP */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'p') }, /* MPEG2 IMX PAL 625/50 50mb/s produced by FCP */ | { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'p') }, /* MPEG2 IMX PAL 625/50 50mb/s produced by FCP */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '4', 'n') }, /* MPEG2 IMX NTSC 525/60 40mb/s produced by FCP */ | { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '4', 'n') }, /* MPEG2 IMX NTSC 525/60 40mb/s produced by FCP */ | ||||
| @@ -200,6 +203,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = { | |||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'd') }, /* XDCAM EX 1080p24 VBR */ | { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'd') }, /* XDCAM EX 1080p24 VBR */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'e') }, /* XDCAM EX 1080p25 VBR */ | { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'e') }, /* XDCAM EX 1080p25 VBR */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'f') }, /* XDCAM EX 1080p30 VBR */ | { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'v', 'f') }, /* XDCAM EX 1080p30 VBR */ | ||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'h', 'd') }, /* XDCAM HD 540p */ | |||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'h', '2') }, /* XDCAM HD422 540p */ | |||||
| { CODEC_ID_MPEG2VIDEO, MKTAG('A', 'V', 'm', 'p') }, /* AVID IMX PAL */ | { CODEC_ID_MPEG2VIDEO, MKTAG('A', 'V', 'm', 'p') }, /* AVID IMX PAL */ | ||||
| { CODEC_ID_JPEG2000, MKTAG('m', 'j', 'p', '2') }, /* JPEG 2000 produced by FCP */ | { CODEC_ID_JPEG2000, MKTAG('m', 'j', 'p', '2') }, /* JPEG 2000 produced by FCP */ | ||||
| @@ -148,6 +148,7 @@ typedef struct MOVContext { | |||||
| int itunes_metadata; ///< metadata are itunes style | int itunes_metadata; ///< metadata are itunes style | ||||
| int chapter_track; | int chapter_track; | ||||
| int use_absolute_path; | int use_absolute_path; | ||||
| int64_t next_root_atom; ///< offset of the next root atom | |||||
| } MOVContext; | } MOVContext; | ||||
| int ff_mp4_read_descr_len(AVIOContext *pb); | int ff_mp4_read_descr_len(AVIOContext *pb); | ||||
| @@ -353,8 +353,12 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) | |||||
| if (err < 0) | if (err < 0) | ||||
| return err; | return err; | ||||
| if (c->found_moov && c->found_mdat && | if (c->found_moov && c->found_mdat && | ||||
| (!pb->seekable || start_pos + a.size == avio_size(pb))) | |||||
| ((!pb->seekable || c->fc->flags & AVFMT_FLAG_IGNIDX) || | |||||
| start_pos + a.size == avio_size(pb))) { | |||||
| if (!pb->seekable || c->fc->flags & AVFMT_FLAG_IGNIDX) | |||||
| c->next_root_atom = start_pos + a.size; | |||||
| return 0; | return 0; | ||||
| } | |||||
| left = a.size - avio_tell(pb) + start_pos; | left = a.size - avio_tell(pb) + start_pos; | ||||
| if (left > 0) /* skip garbage at atom end */ | if (left > 0) /* skip garbage at atom end */ | ||||
| avio_skip(pb, left); | avio_skip(pb, left); | ||||
| @@ -2821,8 +2825,11 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) | |||||
| sample = mov_find_next_sample(s, &st); | sample = mov_find_next_sample(s, &st); | ||||
| if (!sample) { | if (!sample) { | ||||
| mov->found_mdat = 0; | mov->found_mdat = 0; | ||||
| if (s->pb->seekable|| | |||||
| mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || | |||||
| if (!mov->next_root_atom) | |||||
| return AVERROR_EOF; | |||||
| avio_seek(s->pb, mov->next_root_atom, SEEK_SET); | |||||
| mov->next_root_atom = 0; | |||||
| if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || | |||||
| url_feof(s->pb)) | url_feof(s->pb)) | ||||
| return AVERROR_EOF; | return AVERROR_EOF; | ||||
| av_dlog(s, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); | av_dlog(s, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); | ||||
| @@ -99,9 +99,9 @@ static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track) | |||||
| if(!track->cluster[i].chunkNum) | if(!track->cluster[i].chunkNum) | ||||
| continue; | continue; | ||||
| if(mode64 == 1) | if(mode64 == 1) | ||||
| avio_wb64(pb, track->cluster[i].pos); | |||||
| avio_wb64(pb, track->cluster[i].pos + track->data_offset); | |||||
| else | else | ||||
| avio_wb32(pb, track->cluster[i].pos); | |||||
| avio_wb32(pb, track->cluster[i].pos + track->data_offset); | |||||
| } | } | ||||
| return update_size(pb, pos); | return update_size(pb, pos); | ||||
| } | } | ||||
| @@ -2036,6 +2036,8 @@ static void build_chunks(MOVTrack *trk) | |||||
| MOVIentry *chunk= &trk->cluster[0]; | MOVIentry *chunk= &trk->cluster[0]; | ||||
| uint64_t chunkSize = chunk->size; | uint64_t chunkSize = chunk->size; | ||||
| chunk->chunkNum= 1; | chunk->chunkNum= 1; | ||||
| if (trk->chunkCount) | |||||
| return; | |||||
| trk->chunkCount= 1; | trk->chunkCount= 1; | ||||
| for(i=1; i<trk->entry; i++){ | for(i=1; i<trk->entry; i++){ | ||||
| if(chunk->pos + chunkSize == trk->cluster[i].pos && | if(chunk->pos + chunkSize == trk->cluster[i].pos && | ||||
| @@ -2739,6 +2741,10 @@ static int mov_flush_fragment(AVFormatContext *s) | |||||
| if (!(mov->flags & FF_MOV_FLAG_EMPTY_MOOV) && mov->fragments == 0) { | if (!(mov->flags & FF_MOV_FLAG_EMPTY_MOOV) && mov->fragments == 0) { | ||||
| int64_t pos = avio_tell(s->pb); | int64_t pos = avio_tell(s->pb); | ||||
| int ret; | |||||
| AVIOContext *moov_buf; | |||||
| uint8_t *buf; | |||||
| int buf_size; | |||||
| for (i = 0; i < mov->nb_streams; i++) | for (i = 0; i < mov->nb_streams; i++) | ||||
| if (!mov->tracks[i].entry) | if (!mov->tracks[i].entry) | ||||
| @@ -2746,10 +2752,24 @@ static int mov_flush_fragment(AVFormatContext *s) | |||||
| /* Don't write the initial moov unless all tracks have data */ | /* Don't write the initial moov unless all tracks have data */ | ||||
| if (i < mov->nb_streams) | if (i < mov->nb_streams) | ||||
| return 0; | return 0; | ||||
| avio_seek(s->pb, mov->mdat_pos, SEEK_SET); | |||||
| avio_wb32(s->pb, mov->mdat_size + 8); | |||||
| avio_seek(s->pb, pos, SEEK_SET); | |||||
| if ((ret = avio_open_dyn_buf(&moov_buf)) < 0) | |||||
| return ret; | |||||
| mov_write_moov_tag(moov_buf, mov, s); | |||||
| buf_size = avio_close_dyn_buf(moov_buf, &buf); | |||||
| av_free(buf); | |||||
| for (i = 0; i < mov->nb_streams; i++) | |||||
| mov->tracks[i].data_offset = pos + buf_size + 8; | |||||
| mov_write_moov_tag(s->pb, mov, s); | mov_write_moov_tag(s->pb, mov, s); | ||||
| buf_size = avio_close_dyn_buf(mov->mdat_buf, &buf); | |||||
| mov->mdat_buf = NULL; | |||||
| avio_wb32(s->pb, buf_size + 8); | |||||
| ffio_wfourcc(s->pb, "mdat"); | |||||
| avio_write(s->pb, buf, buf_size); | |||||
| av_free(buf); | |||||
| mov->fragments++; | mov->fragments++; | ||||
| mov->mdat_size = 0; | mov->mdat_size = 0; | ||||
| for (i = 0; i < mov->nb_streams; i++) { | for (i = 0; i < mov->nb_streams; i++) { | ||||
| @@ -2862,13 +2882,21 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt) | |||||
| mov_flush_fragment(s); | mov_flush_fragment(s); | ||||
| } | } | ||||
| if (mov->flags & FF_MOV_FLAG_FRAGMENT && mov->fragments > 0) { | |||||
| if (!trk->mdat_buf) { | |||||
| int ret; | |||||
| if ((ret = avio_open_dyn_buf(&trk->mdat_buf)) < 0) | |||||
| return ret; | |||||
| if (mov->flags & FF_MOV_FLAG_FRAGMENT) { | |||||
| int ret; | |||||
| if (mov->fragments > 0) { | |||||
| if (!trk->mdat_buf) { | |||||
| if ((ret = avio_open_dyn_buf(&trk->mdat_buf)) < 0) | |||||
| return ret; | |||||
| } | |||||
| pb = trk->mdat_buf; | |||||
| } else { | |||||
| if (!mov->mdat_buf) { | |||||
| if ((ret = avio_open_dyn_buf(&mov->mdat_buf)) < 0) | |||||
| return ret; | |||||
| } | |||||
| pb = mov->mdat_buf; | |||||
| } | } | ||||
| pb = trk->mdat_buf; | |||||
| } | } | ||||
| if (enc->codec_id == CODEC_ID_AMR_NB) { | if (enc->codec_id == CODEC_ID_AMR_NB) { | ||||
| @@ -3038,11 +3066,18 @@ static int mov_write_header(AVFormatContext *s) | |||||
| AVDictionaryEntry *t; | AVDictionaryEntry *t; | ||||
| int i, hint_track = 0; | int i, hint_track = 0; | ||||
| /* Non-seekable output is ok if EMPTY_MOOV is set, or if using the ismv | |||||
| * format (which sets EMPTY_MOOV later in this function). If ism_lookahead | |||||
| /* Set the FRAGMENT flag if any of the fragmentation methods are | |||||
| * enabled. */ | |||||
| if (mov->max_fragment_duration || mov->max_fragment_size || | |||||
| mov->flags & (FF_MOV_FLAG_EMPTY_MOOV | | |||||
| FF_MOV_FLAG_FRAG_KEYFRAME | | |||||
| FF_MOV_FLAG_FRAG_CUSTOM)) | |||||
| mov->flags |= FF_MOV_FLAG_FRAGMENT; | |||||
| /* Non-seekable output is ok if using fragmentation. If ism_lookahead | |||||
| * is enabled, we don't support non-seekable output at all. */ | * is enabled, we don't support non-seekable output at all. */ | ||||
| if (!s->pb->seekable && | if (!s->pb->seekable && | ||||
| ((!(mov->flags & FF_MOV_FLAG_EMPTY_MOOV) && | |||||
| ((!(mov->flags & FF_MOV_FLAG_FRAGMENT) && | |||||
| !(s->oformat && !strcmp(s->oformat->name, "ismv"))) | !(s->oformat && !strcmp(s->oformat->name, "ismv"))) | ||||
| || mov->ism_lookahead)) { | || mov->ism_lookahead)) { | ||||
| av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); | av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); | ||||
| @@ -3181,7 +3216,8 @@ static int mov_write_header(AVFormatContext *s) | |||||
| FF_MOV_FLAG_FRAG_CUSTOM)) && | FF_MOV_FLAG_FRAG_CUSTOM)) && | ||||
| !mov->max_fragment_duration && !mov->max_fragment_size) | !mov->max_fragment_duration && !mov->max_fragment_size) | ||||
| mov->max_fragment_duration = 5000000; | mov->max_fragment_duration = 5000000; | ||||
| mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF; | |||||
| mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF | | |||||
| FF_MOV_FLAG_FRAGMENT; | |||||
| } | } | ||||
| if(mov->reserved_moov_size){ | if(mov->reserved_moov_size){ | ||||
| @@ -3189,15 +3225,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| avio_skip(pb, mov->reserved_moov_size); | avio_skip(pb, mov->reserved_moov_size); | ||||
| } | } | ||||
| /* Set the FRAGMENT flag if any of the fragmentation methods are | |||||
| * enabled. */ | |||||
| if (mov->max_fragment_duration || mov->max_fragment_size || | |||||
| mov->flags & (FF_MOV_FLAG_EMPTY_MOOV | | |||||
| FF_MOV_FLAG_FRAG_KEYFRAME | | |||||
| FF_MOV_FLAG_FRAG_CUSTOM)) | |||||
| mov->flags |= FF_MOV_FLAG_FRAGMENT; | |||||
| if (!(mov->flags & FF_MOV_FLAG_EMPTY_MOOV)) | |||||
| if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) | |||||
| mov_write_mdat_tag(pb, mov); | mov_write_mdat_tag(pb, mov); | ||||
| if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) | if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) | ||||
| @@ -156,6 +156,7 @@ typedef struct MOVMuxContext { | |||||
| int max_fragment_duration; | int max_fragment_duration; | ||||
| int max_fragment_size; | int max_fragment_size; | ||||
| int ism_lookahead; | int ism_lookahead; | ||||
| AVIOContext *mdat_buf; | |||||
| } MOVMuxContext; | } MOVMuxContext; | ||||
| #define FF_MOV_FLAG_RTP_HINT 1 | #define FF_MOV_FLAG_RTP_HINT 1 | ||||
| @@ -266,6 +266,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, | |||||
| switch (ast->deint_id) { | switch (ast->deint_id) { | ||||
| case DEINT_ID_INT4: | case DEINT_ID_INT4: | ||||
| if (ast->coded_framesize > ast->audio_framesize || | if (ast->coded_framesize > ast->audio_framesize || | ||||
| sub_packet_h <= 1 || | |||||
| ast->coded_framesize * sub_packet_h > (2 + (sub_packet_h & 1)) * ast->audio_framesize) | ast->coded_framesize * sub_packet_h > (2 + (sub_packet_h & 1)) * ast->audio_framesize) | ||||
| return AVERROR_INVALIDDATA; | return AVERROR_INVALIDDATA; | ||||
| break; | break; | ||||
| @@ -370,8 +371,19 @@ static int rm_read_index(AVFormatContext *s) | |||||
| st = s->streams[n]; | st = s->streams[n]; | ||||
| break; | break; | ||||
| } | } | ||||
| if (n == s->nb_streams) | |||||
| if (n == s->nb_streams) { | |||||
| av_log(s, AV_LOG_ERROR, | |||||
| "Invalid stream index %d for index at pos %"PRId64"\n", | |||||
| str_id, avio_tell(pb)); | |||||
| goto skip; | goto skip; | ||||
| } else if ((avio_size(pb) - avio_tell(pb)) / 14 < n_pkts) { | |||||
| av_log(s, AV_LOG_ERROR, | |||||
| "Nr. of packets in packet index for stream index %d " | |||||
| "exceeds filesize (%"PRId64" at %"PRId64" = %d)\n", | |||||
| str_id, avio_size(pb), avio_tell(pb), | |||||
| (avio_size(pb) - avio_tell(pb)) / 14); | |||||
| goto skip; | |||||
| } | |||||
| for (n = 0; n < n_pkts; n++) { | for (n = 0; n < n_pkts; n++) { | ||||
| avio_skip(pb, 2); | avio_skip(pb, 2); | ||||
| @@ -383,9 +395,12 @@ static int rm_read_index(AVFormatContext *s) | |||||
| } | } | ||||
| skip: | skip: | ||||
| if (next_off && avio_tell(pb) != next_off && | |||||
| avio_seek(pb, next_off, SEEK_SET) < 0) | |||||
| if (next_off && avio_tell(pb) < next_off && | |||||
| avio_seek(pb, next_off, SEEK_SET) < 0) { | |||||
| av_log(s, AV_LOG_ERROR, | |||||
| "Non-linear index detected, not supported\n"); | |||||
| return -1; | return -1; | ||||
| } | |||||
| } while (next_off); | } while (next_off); | ||||
| return 0; | return 0; | ||||
| @@ -48,6 +48,10 @@ static const char * const channel_names[] = { | |||||
| [17] = "TBR", /* top back right */ | [17] = "TBR", /* top back right */ | ||||
| [29] = "DL", /* downmix left */ | [29] = "DL", /* downmix left */ | ||||
| [30] = "DR", /* downmix right */ | [30] = "DR", /* downmix right */ | ||||
| [31] = "WL", /* wide left */ | |||||
| [32] = "WR", /* wide right */ | |||||
| [33] = "SDL", /* surround direct left */ | |||||
| [34] = "SDR", /* surround direct right */ | |||||
| }; | }; | ||||
| static const char *get_channel_name(int channel_id) | static const char *get_channel_name(int channel_id) | ||||
| @@ -19,12 +19,12 @@ | |||||
| */ | */ | ||||
| #include "libavutil/avutil.h" | #include "libavutil/avutil.h" | ||||
| #include "libavutil/pixfmt.h" | |||||
| #include "libavutil/opt.h" | #include "libavutil/opt.h" | ||||
| #include "libavutil/pixfmt.h" | |||||
| #include "swscale.h" | #include "swscale.h" | ||||
| #include "swscale_internal.h" | #include "swscale_internal.h" | ||||
| static const char * sws_context_to_name(void * ptr) | |||||
| static const char *sws_context_to_name(void *ptr) | |||||
| { | { | ||||
| return "swscaler"; | return "swscaler"; | ||||
| } | } | ||||
| @@ -34,34 +34,34 @@ static const char * sws_context_to_name(void * ptr) | |||||
| #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM | #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM | ||||
| static const AVOption options[] = { | static const AVOption options[] = { | ||||
| { "sws_flags", "scaler/cpu flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, VE, "sws_flags" }, | |||||
| { "fast_bilinear", "fast bilinear", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_FAST_BILINEAR }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "bilinear", "bilinear", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_BILINEAR }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "bicubic", "bicubic", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_BICUBIC }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "experimental", "experimental", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_X }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "neighbor", "nearest neighbor", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_POINT }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "area", "averaging area", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_AREA }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "bicublin", "luma bicubic, chroma bilinear", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_BICUBLIN }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "gauss", "gaussian", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_GAUSS }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "sinc", "sinc", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_SINC }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "lanczos", "lanczos", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_LANCZOS }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "spline", "natural bicubic spline", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_SPLINE }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "print_info", "print info", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_PRINT_INFO }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "accurate_rnd", "accurate rounding", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_ACCURATE_RND }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "full_chroma_int", "full chroma interpolation", 0 , AV_OPT_TYPE_CONST, {.dbl = SWS_FULL_CHR_H_INT }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "full_chroma_inp", "full chroma input", 0 , AV_OPT_TYPE_CONST, {.dbl = SWS_FULL_CHR_H_INP }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "bitexact", "", 0 , AV_OPT_TYPE_CONST, {.dbl = SWS_BITEXACT }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "sws_flags", "scaler/cpu flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .dbl = DEFAULT }, 0, UINT_MAX, VE, "sws_flags" }, | |||||
| { "fast_bilinear", "fast bilinear", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_FAST_BILINEAR }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "bilinear", "bilinear", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_BILINEAR }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "bicubic", "bicubic", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_BICUBIC }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "experimental", "experimental", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_X }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "neighbor", "nearest neighbor", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_POINT }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "area", "averaging area", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_AREA }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "bicublin", "luma bicubic, chroma bilinear", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_BICUBLIN }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "gauss", "gaussian", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_GAUSS }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "sinc", "sinc", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_SINC }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "lanczos", "lanczos", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_LANCZOS }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "spline", "natural bicubic spline", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_SPLINE }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "print_info", "print info", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_PRINT_INFO }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "accurate_rnd", "accurate rounding", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_ACCURATE_RND }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "full_chroma_int", "full chroma interpolation", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_FULL_CHR_H_INT }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "full_chroma_inp", "full chroma input", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_FULL_CHR_H_INP }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "bitexact", "", 0, AV_OPT_TYPE_CONST, { .dbl = SWS_BITEXACT }, INT_MIN, INT_MAX, VE, "sws_flags" }, | |||||
| { "srcw", "source width" , OFFSET(srcW), AV_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, | |||||
| { "srch", "source height" , OFFSET(srcH), AV_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, | |||||
| { "dstw", "destination width" , OFFSET(dstW), AV_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, | |||||
| { "dsth", "destination height", OFFSET(dstH), AV_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, | |||||
| { "src_format", "source format" , OFFSET(srcFormat), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, PIX_FMT_NB-1, VE }, | |||||
| { "dst_format", "destination format", OFFSET(dstFormat), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, PIX_FMT_NB-1, VE }, | |||||
| { "src_range" , "source range" , OFFSET(srcRange) , AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 1, VE }, | |||||
| { "dst_range" , "destination range" , OFFSET(dstRange) , AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 1, VE }, | |||||
| { "param0" , "scaler param 0" , OFFSET(param[0]) , AV_OPT_TYPE_DOUBLE, {.dbl = SWS_PARAM_DEFAULT}, INT_MIN, INT_MAX, VE }, | |||||
| { "param1" , "scaler param 1" , OFFSET(param[1]) , AV_OPT_TYPE_DOUBLE, {.dbl = SWS_PARAM_DEFAULT}, INT_MIN, INT_MAX, VE }, | |||||
| { "srcw", "source width", OFFSET(srcW), AV_OPT_TYPE_INT, { .dbl = 16 }, 1, INT_MAX, VE }, | |||||
| { "srch", "source height", OFFSET(srcH), AV_OPT_TYPE_INT, { .dbl = 16 }, 1, INT_MAX, VE }, | |||||
| { "dstw", "destination width", OFFSET(dstW), AV_OPT_TYPE_INT, { .dbl = 16 }, 1, INT_MAX, VE }, | |||||
| { "dsth", "destination height", OFFSET(dstH), AV_OPT_TYPE_INT, { .dbl = 16 }, 1, INT_MAX, VE }, | |||||
| { "src_format", "source format", OFFSET(srcFormat), AV_OPT_TYPE_INT, { .dbl = DEFAULT }, 0, PIX_FMT_NB - 1, VE }, | |||||
| { "dst_format", "destination format", OFFSET(dstFormat), AV_OPT_TYPE_INT, { .dbl = DEFAULT }, 0, PIX_FMT_NB - 1, VE }, | |||||
| { "src_range", "source range", OFFSET(srcRange), AV_OPT_TYPE_INT, { .dbl = DEFAULT }, 0, 1, VE }, | |||||
| { "dst_range", "destination range", OFFSET(dstRange), AV_OPT_TYPE_INT, { .dbl = DEFAULT }, 0, 1, VE }, | |||||
| { "param0", "scaler param 0", OFFSET(param[0]), AV_OPT_TYPE_DOUBLE, { .dbl = SWS_PARAM_DEFAULT }, INT_MIN, INT_MAX, VE }, | |||||
| { "param1", "scaler param 1", OFFSET(param[1]), AV_OPT_TYPE_DOUBLE, { .dbl = SWS_PARAM_DEFAULT }, INT_MIN, INT_MAX, VE }, | |||||
| { NULL } | { NULL } | ||||
| }; | }; | ||||
| @@ -22,48 +22,58 @@ | |||||
| * License along with FFmpeg; if not, write to the Free Software | * License along with FFmpeg; if not, write to the Free Software | ||||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
| */ | */ | ||||
| #include <inttypes.h> | #include <inttypes.h> | ||||
| #include "config.h" | |||||
| #include "libavutil/bswap.h" | #include "libavutil/bswap.h" | ||||
| #include "config.h" | |||||
| #include "rgb2rgb.h" | #include "rgb2rgb.h" | ||||
| #include "swscale.h" | #include "swscale.h" | ||||
| #include "swscale_internal.h" | #include "swscale_internal.h" | ||||
| void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size); | void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size); | ||||
| void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size); | void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size); | ||||
| void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size); | void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size); | ||||
| void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size); | void (*rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size); | ||||
| void (*rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size); | void (*rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size); | ||||
| void (*rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size); | void (*rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size); | ||||
| void (*rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size); | void (*rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size); | ||||
| void (*rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size); | void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size); | ||||
| void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size); | |||||
| void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, | |||||
| void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, | |||||
| const uint8_t *vsrc, uint8_t *dst, | |||||
| int width, int height, | int width, int height, | ||||
| int lumStride, int chromStride, int dstStride); | int lumStride, int chromStride, int dstStride); | ||||
| void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, | |||||
| void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, | |||||
| const uint8_t *vsrc, uint8_t *dst, | |||||
| int width, int height, | int width, int height, | ||||
| int lumStride, int chromStride, int dstStride); | int lumStride, int chromStride, int dstStride); | ||||
| void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, | |||||
| void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, | |||||
| const uint8_t *vsrc, uint8_t *dst, | |||||
| int width, int height, | int width, int height, | ||||
| int lumStride, int chromStride, int dstStride); | int lumStride, int chromStride, int dstStride); | ||||
| void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, | |||||
| void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, | |||||
| const uint8_t *vsrc, uint8_t *dst, | |||||
| int width, int height, | int width, int height, | ||||
| int lumStride, int chromStride, int dstStride); | int lumStride, int chromStride, int dstStride); | ||||
| void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |||||
| void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst, | |||||
| uint8_t *udst, uint8_t *vdst, | |||||
| int width, int height, | int width, int height, | ||||
| int lumStride, int chromStride, int srcStride); | int lumStride, int chromStride, int srcStride); | ||||
| void (*rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |||||
| void (*rgb24toyv12)(const uint8_t *src, uint8_t *ydst, | |||||
| uint8_t *udst, uint8_t *vdst, | |||||
| int width, int height, | int width, int height, | ||||
| int lumStride, int chromStride, int srcStride); | int lumStride, int chromStride, int srcStride); | ||||
| void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, | void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, | ||||
| @@ -76,45 +86,44 @@ void (*vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2, | |||||
| int width, int height, | int width, int height, | ||||
| int srcStride1, int srcStride2, | int srcStride1, int srcStride2, | ||||
| int dstStride1, int dstStride2); | int dstStride1, int dstStride2); | ||||
| void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, | |||||
| uint8_t *dst, | |||||
| void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, | |||||
| const uint8_t *src3, uint8_t *dst, | |||||
| int width, int height, | int width, int height, | ||||
| int srcStride1, int srcStride2, | int srcStride1, int srcStride2, | ||||
| int srcStride3, int dstStride); | int srcStride3, int dstStride); | ||||
| void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, | |||||
| int width, int height, | |||||
| void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |||||
| const uint8_t *src, int width, int height, | |||||
| int lumStride, int chromStride, int srcStride); | int lumStride, int chromStride, int srcStride); | ||||
| void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, | |||||
| int width, int height, | |||||
| void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |||||
| const uint8_t *src, int width, int height, | |||||
| int lumStride, int chromStride, int srcStride); | int lumStride, int chromStride, int srcStride); | ||||
| void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, | |||||
| int width, int height, | |||||
| void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |||||
| const uint8_t *src, int width, int height, | |||||
| int lumStride, int chromStride, int srcStride); | int lumStride, int chromStride, int srcStride); | ||||
| void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, | |||||
| int width, int height, | |||||
| void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |||||
| const uint8_t *src, int width, int height, | |||||
| int lumStride, int chromStride, int srcStride); | int lumStride, int chromStride, int srcStride); | ||||
| #define RGB2YUV_SHIFT 8 | #define RGB2YUV_SHIFT 8 | ||||
| #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5)) | |||||
| #define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5)) | |||||
| #define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) | |||||
| #define GY ((int)( 0.504*(1<<RGB2YUV_SHIFT)+0.5)) | |||||
| #define GV ((int)(-0.368*(1<<RGB2YUV_SHIFT)+0.5)) | |||||
| #define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5)) | |||||
| #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5)) | |||||
| #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) | |||||
| #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5)) | |||||
| #define BY ((int)( 0.098 * (1 << RGB2YUV_SHIFT) + 0.5)) | |||||
| #define BV ((int)(-0.071 * (1 << RGB2YUV_SHIFT) + 0.5)) | |||||
| #define BU ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5)) | |||||
| #define GY ((int)( 0.504 * (1 << RGB2YUV_SHIFT) + 0.5)) | |||||
| #define GV ((int)(-0.368 * (1 << RGB2YUV_SHIFT) + 0.5)) | |||||
| #define GU ((int)(-0.291 * (1 << RGB2YUV_SHIFT) + 0.5)) | |||||
| #define RY ((int)( 0.257 * (1 << RGB2YUV_SHIFT) + 0.5)) | |||||
| #define RV ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5)) | |||||
| #define RU ((int)(-0.148 * (1 << RGB2YUV_SHIFT) + 0.5)) | |||||
| //plain C versions | //plain C versions | ||||
| #include "rgb2rgb_template.c" | #include "rgb2rgb_template.c" | ||||
| /* | /* | ||||
| RGB15->RGB16 original by Strepto/Astral | |||||
| ported to gcc & bugfixed : A'rpi | |||||
| MMX2, 3DNOW optimization by Nick Kurshev | |||||
| 32-bit C version, and and&add trick by Michael Niedermayer | |||||
| */ | |||||
| * RGB15->RGB16 original by Strepto/Astral | |||||
| * ported to gcc & bugfixed : A'rpi | |||||
| * MMX2, 3DNOW optimization by Nick Kurshev | |||||
| * 32-bit C version, and and&add trick by Michael Niedermayer | |||||
| */ | |||||
| void sws_rgb2rgb_init(void) | void sws_rgb2rgb_init(void) | ||||
| { | { | ||||
| @@ -125,18 +134,18 @@ void sws_rgb2rgb_init(void) | |||||
| void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size) | void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| int i; | |||||
| int num_pixels = src_size >> 2; | |||||
| for (i=0; i<num_pixels; i++) { | |||||
| int i, num_pixels = src_size >> 2; | |||||
| for (i = 0; i < num_pixels; i++) { | |||||
| #if HAVE_BIGENDIAN | #if HAVE_BIGENDIAN | ||||
| /* RGB32 (= A,B,G,R) -> BGR24 (= B,G,R) */ | /* RGB32 (= A,B,G,R) -> BGR24 (= B,G,R) */ | ||||
| dst[3*i + 0] = src[4*i + 1]; | |||||
| dst[3*i + 1] = src[4*i + 2]; | |||||
| dst[3*i + 2] = src[4*i + 3]; | |||||
| dst[3 * i + 0] = src[4 * i + 1]; | |||||
| dst[3 * i + 1] = src[4 * i + 2]; | |||||
| dst[3 * i + 2] = src[4 * i + 3]; | |||||
| #else | #else | ||||
| dst[3*i + 0] = src[4*i + 2]; | |||||
| dst[3*i + 1] = src[4*i + 1]; | |||||
| dst[3*i + 2] = src[4*i + 0]; | |||||
| dst[3 * i + 0] = src[4 * i + 2]; | |||||
| dst[3 * i + 1] = src[4 * i + 1]; | |||||
| dst[3 * i + 2] = src[4 * i + 0]; | |||||
| #endif | #endif | ||||
| } | } | ||||
| } | } | ||||
| @@ -144,40 +153,40 @@ void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size) | |||||
| void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size) | void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| int i; | int i; | ||||
| for (i=0; 3*i<src_size; i++) { | |||||
| for (i = 0; 3 * i < src_size; i++) { | |||||
| #if HAVE_BIGENDIAN | #if HAVE_BIGENDIAN | ||||
| /* RGB24 (= R,G,B) -> BGR32 (= A,R,G,B) */ | |||||
| dst[4*i + 0] = 255; | |||||
| dst[4*i + 1] = src[3*i + 0]; | |||||
| dst[4*i + 2] = src[3*i + 1]; | |||||
| dst[4*i + 3] = src[3*i + 2]; | |||||
| /* RGB24 (= R, G, B) -> BGR32 (= A, R, G, B) */ | |||||
| dst[4 * i + 0] = 255; | |||||
| dst[4 * i + 1] = src[3 * i + 0]; | |||||
| dst[4 * i + 2] = src[3 * i + 1]; | |||||
| dst[4 * i + 3] = src[3 * i + 2]; | |||||
| #else | #else | ||||
| dst[4*i + 0] = src[3*i + 2]; | |||||
| dst[4*i + 1] = src[3*i + 1]; | |||||
| dst[4*i + 2] = src[3*i + 0]; | |||||
| dst[4*i + 3] = 255; | |||||
| dst[4 * i + 0] = src[3 * i + 2]; | |||||
| dst[4 * i + 1] = src[3 * i + 1]; | |||||
| dst[4 * i + 2] = src[3 * i + 0]; | |||||
| dst[4 * i + 3] = 255; | |||||
| #endif | #endif | ||||
| } | } | ||||
| } | } | ||||
| void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size) | void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| const uint16_t *end; | |||||
| uint8_t *d = dst; | |||||
| const uint16_t *s = (const uint16_t *)src; | |||||
| end = s + src_size/2; | |||||
| uint8_t *d = dst; | |||||
| const uint16_t *s = (const uint16_t *)src; | |||||
| const uint16_t *end = s + src_size / 2; | |||||
| while (s < end) { | while (s < end) { | ||||
| register uint16_t bgr; | |||||
| bgr = *s++; | |||||
| register uint16_t bgr = *s++; | |||||
| #if HAVE_BIGENDIAN | #if HAVE_BIGENDIAN | ||||
| *d++ = 255; | *d++ = 255; | ||||
| *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2); | |||||
| *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9); | |||||
| *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |||||
| *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); | |||||
| *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | ||||
| #else | #else | ||||
| *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | ||||
| *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9); | |||||
| *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2); | |||||
| *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); | |||||
| *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |||||
| *d++ = 255; | *d++ = 255; | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -185,78 +194,74 @@ void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size) | |||||
| void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size) | void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| const uint16_t *end; | |||||
| uint16_t *d = (uint16_t *)dst; | |||||
| const uint16_t *s = (const uint16_t *)src; | |||||
| uint16_t rgb, r, g, b; | uint16_t rgb, r, g, b; | ||||
| end = s + src_size / 2; | |||||
| uint16_t *d = (uint16_t *)dst; | |||||
| const uint16_t *s = (const uint16_t *)src; | |||||
| const uint16_t *end = s + src_size / 2; | |||||
| while (s < end) { | while (s < end) { | ||||
| rgb = *s++; | |||||
| r = rgb & 0xF00; | |||||
| g = rgb & 0x0F0; | |||||
| b = rgb & 0x00F; | |||||
| r = (r << 3) | ((r & 0x800) >> 1); | |||||
| g = (g << 2) | ((g & 0x080) >> 2); | |||||
| b = (b << 1) | ( b >> 3); | |||||
| rgb = *s++; | |||||
| r = rgb & 0xF00; | |||||
| g = rgb & 0x0F0; | |||||
| b = rgb & 0x00F; | |||||
| r = (r << 3) | ((r & 0x800) >> 1); | |||||
| g = (g << 2) | ((g & 0x080) >> 2); | |||||
| b = (b << 1) | ( b >> 3); | |||||
| *d++ = r | g | b; | *d++ = r | g | b; | ||||
| } | } | ||||
| } | } | ||||
| void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size) | void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| const uint16_t *end; | |||||
| uint8_t *d = dst; | |||||
| const uint16_t *s = (const uint16_t *)src; | |||||
| end = s + src_size/2; | |||||
| uint8_t *d = dst; | |||||
| const uint16_t *s = (const uint16_t *)src; | |||||
| const uint16_t *end = s + src_size / 2; | |||||
| while (s < end) { | while (s < end) { | ||||
| register uint16_t bgr; | |||||
| bgr = *s++; | |||||
| register uint16_t bgr = *s++; | |||||
| *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | ||||
| *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9); | |||||
| *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2); | |||||
| *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); | |||||
| *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |||||
| } | } | ||||
| } | } | ||||
| void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size) | void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| int i; | |||||
| int num_pixels = src_size >> 1; | |||||
| int i, num_pixels = src_size >> 1; | |||||
| for (i=0; i<num_pixels; i++) { | |||||
| unsigned rgb = ((const uint16_t*)src)[i]; | |||||
| ((uint16_t*)dst)[i] = (rgb>>11) | (rgb&0x7E0) | (rgb<<11); | |||||
| for (i = 0; i < num_pixels; i++) { | |||||
| unsigned rgb = ((const uint16_t *)src)[i]; | |||||
| ((uint16_t *)dst)[i] = (rgb >> 11) | (rgb & 0x7E0) | (rgb << 11); | |||||
| } | } | ||||
| } | } | ||||
| void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size) | void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| int i; | |||||
| int num_pixels = src_size >> 1; | |||||
| int i, num_pixels = src_size >> 1; | |||||
| for (i=0; i<num_pixels; i++) { | |||||
| unsigned rgb = ((const uint16_t*)src)[i]; | |||||
| ((uint16_t*)dst)[i] = (rgb>>11) | ((rgb&0x7C0)>>1) | ((rgb&0x1F)<<10); | |||||
| for (i = 0; i < num_pixels; i++) { | |||||
| unsigned rgb = ((const uint16_t *)src)[i]; | |||||
| ((uint16_t *)dst)[i] = (rgb >> 11) | ((rgb & 0x7C0) >> 1) | ((rgb & 0x1F) << 10); | |||||
| } | } | ||||
| } | } | ||||
| void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size) | void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| const uint16_t *end; | |||||
| uint8_t *d = dst; | |||||
| const uint16_t *s = (const uint16_t *)src; | |||||
| end = s + src_size/2; | |||||
| uint8_t *d = dst; | |||||
| const uint16_t *s = (const uint16_t *)src; | |||||
| const uint16_t *end = s + src_size / 2; | |||||
| while (s < end) { | while (s < end) { | ||||
| register uint16_t bgr; | |||||
| bgr = *s++; | |||||
| register uint16_t bgr = *s++; | |||||
| #if HAVE_BIGENDIAN | #if HAVE_BIGENDIAN | ||||
| *d++ = 255; | *d++ = 255; | ||||
| *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2); | |||||
| *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7); | |||||
| *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |||||
| *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); | |||||
| *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | ||||
| #else | #else | ||||
| *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | ||||
| *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7); | |||||
| *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2); | |||||
| *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); | |||||
| *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |||||
| *d++ = 255; | *d++ = 255; | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -264,62 +269,59 @@ void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size) | |||||
| void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size) | void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| const uint16_t *end; | |||||
| uint8_t *d = dst; | |||||
| const uint16_t *s = (const uint16_t *)src; | |||||
| end = s + src_size/2; | |||||
| uint8_t *d = dst; | |||||
| const uint16_t *s = (const uint16_t *)src; | |||||
| const uint16_t *end = s + src_size / 2; | |||||
| while (s < end) { | while (s < end) { | ||||
| register uint16_t bgr; | |||||
| bgr = *s++; | |||||
| register uint16_t bgr = *s++; | |||||
| *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | ||||
| *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7); | |||||
| *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2); | |||||
| *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); | |||||
| *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |||||
| } | } | ||||
| } | } | ||||
| void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size) | void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| int i; | |||||
| int num_pixels = src_size >> 1; | |||||
| int i, num_pixels = src_size >> 1; | |||||
| for (i=0; i<num_pixels; i++) { | |||||
| unsigned rgb = ((const uint16_t*)src)[i]; | |||||
| ((uint16_t*)dst)[i] = ((rgb&0x7C00)>>10) | ((rgb&0x3E0)<<1) | (rgb<<11); | |||||
| for (i = 0; i < num_pixels; i++) { | |||||
| unsigned rgb = ((const uint16_t *)src)[i]; | |||||
| ((uint16_t *)dst)[i] = ((rgb & 0x7C00) >> 10) | ((rgb & 0x3E0) << 1) | (rgb << 11); | |||||
| } | } | ||||
| } | } | ||||
| void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size) | void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| int i; | |||||
| int num_pixels = src_size >> 1; | |||||
| int i, num_pixels = src_size >> 1; | |||||
| for (i=0; i<num_pixels; i++) { | |||||
| unsigned br; | |||||
| unsigned rgb = ((const uint16_t*)src)[i]; | |||||
| br = rgb&0x7c1F; | |||||
| ((uint16_t*)dst)[i] = (br>>10) | (rgb&0x3E0) | (br<<10); | |||||
| for (i = 0; i < num_pixels; i++) { | |||||
| unsigned rgb = ((const uint16_t *)src)[i]; | |||||
| unsigned br = rgb & 0x7C1F; | |||||
| ((uint16_t *)dst)[i] = (br >> 10) | (rgb & 0x3E0) | (br << 10); | |||||
| } | } | ||||
| } | } | ||||
| void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size) | void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size) | ||||
| { | { | ||||
| uint16_t *d = (uint16_t*)dst; | |||||
| uint16_t *s = (uint16_t*)src; | |||||
| int i; | |||||
| int num_pixels = src_size >> 1; | |||||
| uint16_t *d = (uint16_t *)dst; | |||||
| uint16_t *s = (uint16_t *)src; | |||||
| int i, num_pixels = src_size >> 1; | |||||
| for (i = 0; i < num_pixels; i++) { | for (i = 0; i < num_pixels; i++) { | ||||
| unsigned rgb = s[i]; | unsigned rgb = s[i]; | ||||
| d[i] = (rgb << 8 | rgb & 0xF0 | rgb >> 8) & 0xFFF; | |||||
| d[i] = (rgb << 8 | rgb & 0xF0 | rgb >> 8) & 0xFFF; | |||||
| } | } | ||||
| } | } | ||||
| #define DEFINE_SHUFFLE_BYTES(a, b, c, d) \ | #define DEFINE_SHUFFLE_BYTES(a, b, c, d) \ | ||||
| void shuffle_bytes_##a##b##c##d(const uint8_t *src, uint8_t *dst, int src_size) \ | |||||
| void shuffle_bytes_ ## a ## b ## c ## d(const uint8_t *src, \ | |||||
| uint8_t *dst, int src_size) \ | |||||
| { \ | { \ | ||||
| int i; \ | |||||
| int i; \ | |||||
| \ | \ | ||||
| for (i = 0; i < src_size; i+=4) { \ | |||||
| for (i = 0; i < src_size; i += 4) { \ | |||||
| dst[i + 0] = src[i + a]; \ | dst[i + 0] = src[i + a]; \ | ||||
| dst[i + 1] = src[i + b]; \ | dst[i + 1] = src[i + b]; \ | ||||
| dst[i + 2] = src[i + c]; \ | dst[i + 2] = src[i + c]; \ | ||||