Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
-version <next>:
-
-- XWD encoder and decoder
-- Support for fragmentation in the mov/mp4 muxer
-- ISMV (Smooth Streaming) muxer
+version next:
+- v408 Quicktime and Microsoft AYUV Uncompressed 4:4:4:4 encoder and decoder
+- setfield filter
- CDXL demuxer and decoder
- Apple ProRes encoder
+- ffprobe -count_packets and -count_frames options
- Sun Rasterfile Encoder
-- remove libpostproc
- ID3v2 attached pictures reading and writing
+ - WMA Lossless decoder
-version 0.8:
-
+version 0.10:
+- Fixes: CVE-2011-3929, CVE-2011-3934, CVE-2011-3935, CVE-2011-3936,
+ CVE-2011-3937, CVE-2011-3940, CVE-2011-3941, CVE-2011-3944,
+ CVE-2011-3945, CVE-2011-3946, CVE-2011-3947, CVE-2011-3949,
+ CVE-2011-3950, CVE-2011-3951, CVE-2011-3952
+- v410 Quicktime Uncompressed 4:4:4 10-bit encoder and decoder
+- SBaGen (SBG) binaural beats script demuxer
+- OpenMG Audio muxer
+- Timecode extraction in DV and MOV
+- thumbnail video filter
+- XML output in ffprobe
+- asplit audio filter
+- tinterlace video filter
+- astreamsync audio filter
+- amerge audio filter
+- ISMV (Smooth Streaming) muxer
- GSM audio parser
- SMJPEG muxer
-
-
-version 0.8_beta2:
-
+- XWD encoder and decoder
- Automatic thread count based on detection number of (available) CPU cores
-- Deprecate libpostproc. If desired, the switch --enable-postproc will
- enable it but it may be removed in a later Libav release.
+- y41p Brooktree Uncompressed 4:1:1 12-bit encoder and decoder
+- ffprobe -show_error option
+- Avid 1:1 10-bit RGB Packer codec
+- v308 Quicktime Uncompressed 4:4:4 encoder and decoder
+- yuv4 libquicktime packed 4:2:0 encoder and decoder
+- ffprobe -show_frames option
+- silencedetect audio filter
+- ffprobe -show_program_version, -show_library_versions, -show_versions options
- rv34: frame-level multi-threading
- optimized iMDCT transform on x86 using SSE for for mpegaudiodec
+- Improved PGS subtitle decoder
+- dumpgraph option to lavfi device
+- r210 and r10k encoders
+- ffwavesynth decoder
+- aviocat tool
+- ffeval tool
-version 0.8_beta1:
+version 0.9:
+- openal input device added
+- boxblur filter added
- BWF muxer
- Flash Screen Video 2 decoder
-- ffplay/ffprobe/ffserver renamed to avplay/avprobe/avserver
-- ffmpeg deprecated, added avconv, which is almost the same for now, except
+- lavfi input device added
+- added avconv, which is almost the same for now, except
for a few incompatible changes in the options, which will hopefully make them
easier to use. The changes are:
* The options placement is now strictly enforced! While in theory the
OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4.o msmpeg4data.o h263dec.o \
h263.o ituh263dec.o mpeg4videodec.o
- OBJS-$(CONFIG_MSMPEG4V2_ENCODER) += msmpeg4.o msmpeg4data.o h263dec.o \
- h263.o ituh263dec.o mpeg4videodec.o
+ OBJS-$(CONFIG_MSMPEG4V2_ENCODER) += msmpeg4.o msmpeg4enc.o msmpeg4data.o \
+ h263dec.o h263.o ituh263dec.o \
+ mpeg4videodec.o
OBJS-$(CONFIG_MSMPEG4V3_DECODER) += msmpeg4.o msmpeg4data.o h263dec.o \
h263.o ituh263dec.o mpeg4videodec.o
- OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4.o msmpeg4data.o h263dec.o \
- h263.o ituh263dec.o mpeg4videodec.o
+ OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4.o msmpeg4enc.o msmpeg4data.o \
+ h263dec.o h263.o ituh263dec.o \
+ mpeg4videodec.o
OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o
OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o
+OBJS-$(CONFIG_MSVIDEO1_ENCODER) += msvideo1enc.o elbg.o
OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o
OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o mjpegdec.o mjpeg.o
OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o nellymoser.o
#include <stdint.h>
#include "libavcodec/vp8dsp.h"
-void ff_vp8_luma_dc_wht_neon(DCTELEM block[4][4][16], DCTELEM dc[16]);
-void ff_vp8_luma_dc_wht_dc_neon(DCTELEM block[4][4][16], DCTELEM dc[16]);
+void ff_vp8_luma_dc_wht_dc_armv6(DCTELEM block[4][4][16], DCTELEM dc[16]);
-void ff_vp8_idct_add_neon(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride);
-void ff_vp8_idct_dc_add_neon(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride);
-void ff_vp8_idct_dc_add4y_neon(uint8_t *dst, DCTELEM block[4][16], ptrdiff_t stride);
-void ff_vp8_idct_dc_add4uv_neon(uint8_t *dst, DCTELEM block[4][16], ptrdiff_t stride);
+#define idct_funcs(opt) \
+void ff_vp8_luma_dc_wht_ ## opt(DCTELEM block[4][4][16], DCTELEM dc[16]); \
- void ff_vp8_idct_add_ ## opt(uint8_t *dst, DCTELEM block[16], int stride); \
- void ff_vp8_idct_dc_add_ ## opt(uint8_t *dst, DCTELEM block[16], int stride); \
- void ff_vp8_idct_dc_add4y_ ## opt(uint8_t *dst, DCTELEM block[4][16], int stride); \
- void ff_vp8_idct_dc_add4uv_ ## opt(uint8_t *dst, DCTELEM block[4][16], int stride)
++void ff_vp8_idct_add_ ## opt(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride); \
++void ff_vp8_idct_dc_add_ ## opt(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride); \
++void ff_vp8_idct_dc_add4y_ ## opt(uint8_t *dst, DCTELEM block[4][16], ptrdiff_t stride); \
++void ff_vp8_idct_dc_add4uv_ ## opt(uint8_t *dst, DCTELEM block[4][16], ptrdiff_t stride)
+
+idct_funcs(neon);
+idct_funcs(armv6);
- void ff_vp8_v_loop_filter16_neon(uint8_t *dst, int stride,
+ void ff_vp8_v_loop_filter16_neon(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh);
- void ff_vp8_h_loop_filter16_neon(uint8_t *dst, int stride,
+ void ff_vp8_h_loop_filter16_neon(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh);
- void ff_vp8_v_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, int stride,
+ void ff_vp8_v_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh);
- void ff_vp8_h_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, int stride,
+ void ff_vp8_h_loop_filter8uv_neon(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh);
- void ff_vp8_v_loop_filter16_inner_neon(uint8_t *dst, int stride,
+ void ff_vp8_v_loop_filter16_inner_neon(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh);
- void ff_vp8_h_loop_filter16_inner_neon(uint8_t *dst, int stride,
+ void ff_vp8_h_loop_filter16_inner_neon(uint8_t *dst, ptrdiff_t stride,
int flim_E, int flim_I, int hev_thresh);
void ff_vp8_v_loop_filter8uv_inner_neon(uint8_t *dstU, uint8_t *dstV,
- int stride, int flim_E, int flim_I,
+ ptrdiff_t stride, int flim_E, int flim_I,
int hev_thresh);
void ff_vp8_h_loop_filter8uv_inner_neon(uint8_t *dstU, uint8_t *dstV,
- int stride, int flim_E, int flim_I,
+ ptrdiff_t stride, int flim_E, int flim_I,
int hev_thresh);
- void ff_vp8_v_loop_filter_inner_armv6(uint8_t *dst, int stride,
-void ff_vp8_v_loop_filter16_simple_neon(uint8_t *dst, ptrdiff_t stride, int flim);
-void ff_vp8_h_loop_filter16_simple_neon(uint8_t *dst, ptrdiff_t stride, int flim);
++void ff_vp8_v_loop_filter_inner_armv6(uint8_t *dst, ptrdiff_t stride,
+ int flim_E, int flim_I,
+ int hev_thresh, int count);
- void ff_vp8_h_loop_filter_inner_armv6(uint8_t *dst, int stride,
++void ff_vp8_h_loop_filter_inner_armv6(uint8_t *dst, ptrdiff_t stride,
+ int flim_E, int flim_I,
+ int hev_thresh, int count);
- void ff_vp8_v_loop_filter_armv6(uint8_t *dst, int stride,
++void ff_vp8_v_loop_filter_armv6(uint8_t *dst, ptrdiff_t stride,
+ int flim_E, int flim_I,
+ int hev_thresh, int count);
- void ff_vp8_h_loop_filter_armv6(uint8_t *dst, int stride,
++void ff_vp8_h_loop_filter_armv6(uint8_t *dst, ptrdiff_t stride,
+ int flim_E, int flim_I,
+ int hev_thresh, int count);
+
- static void ff_vp8_v_loop_filter16_armv6(uint8_t *dst, int stride,
++static void ff_vp8_v_loop_filter16_armv6(uint8_t *dst, ptrdiff_t stride,
+ int flim_E, int flim_I, int hev_thresh)
+{
+ ff_vp8_v_loop_filter_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
+}
+
- static void ff_vp8_h_loop_filter16_armv6(uint8_t *dst, int stride,
++static void ff_vp8_h_loop_filter16_armv6(uint8_t *dst, ptrdiff_t stride,
+ int flim_E, int flim_I, int hev_thresh)
+{
+ ff_vp8_h_loop_filter_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
+}
- static void ff_vp8_v_loop_filter8uv_armv6(uint8_t *dstU, uint8_t *dstV, int stride,
++static void ff_vp8_v_loop_filter8uv_armv6(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
+ int flim_E, int flim_I, int hev_thresh)
+{
+ ff_vp8_v_loop_filter_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
+ ff_vp8_v_loop_filter_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2);
+}
+
- static void ff_vp8_h_loop_filter8uv_armv6(uint8_t *dstU, uint8_t *dstV, int stride,
++static void ff_vp8_h_loop_filter8uv_armv6(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
+ int flim_E, int flim_I, int hev_thresh)
+{
+ ff_vp8_h_loop_filter_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
+ ff_vp8_h_loop_filter_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2);
+}
+
- static void ff_vp8_v_loop_filter16_inner_armv6(uint8_t *dst, int stride,
++static void ff_vp8_v_loop_filter16_inner_armv6(uint8_t *dst, ptrdiff_t stride,
+ int flim_E, int flim_I, int hev_thresh)
+{
+ ff_vp8_v_loop_filter_inner_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
+}
+
- static void ff_vp8_h_loop_filter16_inner_armv6(uint8_t *dst, int stride,
++static void ff_vp8_h_loop_filter16_inner_armv6(uint8_t *dst, ptrdiff_t stride,
+ int flim_E, int flim_I, int hev_thresh)
+{
+ ff_vp8_h_loop_filter_inner_armv6(dst, stride, flim_E, flim_I, hev_thresh, 4);
+}
+
+static void ff_vp8_v_loop_filter8uv_inner_armv6(uint8_t *dstU, uint8_t *dstV,
- int stride, int flim_E, int flim_I,
++ ptrdiff_t stride, int flim_E, int flim_I,
+ int hev_thresh)
+{
+ ff_vp8_v_loop_filter_inner_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
+ ff_vp8_v_loop_filter_inner_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2);
+}
+
+static void ff_vp8_h_loop_filter8uv_inner_armv6(uint8_t *dstU, uint8_t *dstV,
- int stride, int flim_E, int flim_I,
++ ptrdiff_t stride, int flim_E, int flim_I,
+ int hev_thresh)
+{
+ ff_vp8_h_loop_filter_inner_armv6(dstU, stride, flim_E, flim_I, hev_thresh, 2);
+ ff_vp8_h_loop_filter_inner_armv6(dstV, stride, flim_E, flim_I, hev_thresh, 2);
+}
+
+#define simple_lf_funcs(opt) \
- void ff_vp8_v_loop_filter16_simple_ ## opt(uint8_t *dst, int stride, int flim); \
- void ff_vp8_h_loop_filter16_simple_ ## opt(uint8_t *dst, int stride, int flim)
++void ff_vp8_v_loop_filter16_simple_ ## opt(uint8_t *dst, ptrdiff_t stride, int flim); \
++void ff_vp8_h_loop_filter16_simple_ ## opt(uint8_t *dst, ptrdiff_t stride, int flim)
+
+simple_lf_funcs(neon);
+simple_lf_funcs(armv6);
- #define VP8_MC_OPT(n, opt) \
- void ff_put_vp8_##n##_##opt(uint8_t *dst, int dststride, \
- uint8_t *src, int srcstride, \
- int h, int x, int y)
+ #define VP8_MC(n) \
+ void ff_put_vp8_##n##_neon(uint8_t *dst, ptrdiff_t dststride, \
+ uint8_t *src, ptrdiff_t srcstride, \
+ int h, int x, int y)
+#define VP8_MC(n) \
+ VP8_MC_OPT(n, neon)
+
#define VP8_EPEL(w) \
- VP8_MC(pixels ## w); \
VP8_MC(epel ## w ## _h4); \
VP8_MC(epel ## w ## _h6); \
- VP8_MC(epel ## w ## _v4); \
VP8_MC(epel ## w ## _h4v4); \
VP8_MC(epel ## w ## _h6v4); \
+ VP8_MC(epel ## w ## _v4); \
VP8_MC(epel ## w ## _v6); \
VP8_MC(epel ## w ## _h4v6); \
VP8_MC(epel ## w ## _h6v6)
static av_cold int bmp_encode_init(AVCodecContext *avctx){
BMPContext *s = avctx->priv_data;
- avcodec_get_frame_defaults((AVFrame*)&s->picture);
- avctx->coded_frame = (AVFrame*)&s->picture;
+ avcodec_get_frame_defaults(&s->picture);
+ avctx->coded_frame = &s->picture;
switch (avctx->pix_fmt) {
+ case PIX_FMT_BGRA:
+ avctx->bits_per_coded_sample = 32;
+ break;
case PIX_FMT_BGR24:
avctx->bits_per_coded_sample = 24;
break;
const AVFrame *pict, int *got_packet)
{
BMPContext *s = avctx->priv_data;
- AVFrame * const p= (AVFrame*)&s->picture;
+ AVFrame * const p = &s->picture;
int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize, ret;
const uint32_t *pal = NULL;
+ uint32_t palette256[256];
int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB;
int bit_count = avctx->bits_per_coded_sample;
uint8_t *ptr, *buf;
if (s->avctx->codec_id == CODEC_ID_H264) {
// FIXME
} else {
- ff_thread_await_progress((AVFrame *) s->last_picture_ptr,
+ ff_thread_await_progress(&s->last_picture_ptr->f,
mb_y, 0);
}
- is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr,
- s->linesize, 16);
- is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr,
- last_mb_ptr + s->linesize * 16,
- s->linesize, 16);
+ is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16);
+ // FIXME need await_progress() here
+ is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16);
} else {
if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
is_intra_likely++;
{
FrapsContext * const s = avctx->priv_data;
- avctx->coded_frame = (AVFrame*)&s->frame;
+ avcodec_get_frame_defaults(&s->frame);
- avctx->pix_fmt= PIX_FMT_NONE; /* set in decode_frame */
+ avctx->coded_frame = &s->frame;
s->avctx = avctx;
s->tmpbuf = NULL;
field_end(h, 0);
- if (!h->next_output_pic) {
- /* Wait for second field. */
- *data_size = 0;
-
- } else {
- *data_size = sizeof(AVFrame);
- *pict = h->next_output_pic->f;
+ *data_size = 0; /* Wait for second field. */
+ if (h->next_output_pic && (h->next_output_pic->sync || h->sync>1)) {
+ *data_size = sizeof(AVFrame);
- *pict = *(AVFrame*)h->next_output_pic;
++ *pict = h->next_output_pic->f;
}
}
int buf_size = avpkt->size;
Ir2Context * const s = avctx->priv_data;
AVFrame *picture = data;
- AVFrame * const p= (AVFrame*)&s->picture;
+ AVFrame * const p = &s->picture;
int start;
- if(p->data[0])
- avctx->release_buffer(avctx, p);
-
- p->reference = 1;
+ p->reference = 3;
p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
if (avctx->reget_buffer(avctx, p)) {
av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
static av_cold int decode_init_thread_copy(AVCodecContext *avctx){
MDECContext * const a = avctx->priv_data;
- AVFrame *p = (AVFrame*)&a->picture;
+ AVFrame *p = &a->picture;
- avctx->coded_frame = p;
+ avctx->coded_frame= p;
a->avctx= avctx;
- p->qscale_table = av_mallocz( a->mb_width);
+ p->qscale_table= av_mallocz(a->mb_width);
return 0;
}
/* per-MB end of slice check */
if(s->codec_id==CODEC_ID_MPEG4){
- if(mpeg4_is_resync(s)){
- const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
+ int next= mpeg4_is_resync(s);
+ if(next) {
+ if (s->mb_x + s->mb_y*s->mb_width + 1 > next && (s->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
+ return -1;
+ } else if (s->mb_x + s->mb_y*s->mb_width + 1 >= next)
+ return SLICE_END;
- if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture.f.mbskip_table[xy + delta]) {
+ if(s->pict_type==AV_PICTURE_TYPE_B){
+ const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
- ff_thread_await_progress((AVFrame*)s->next_picture_ptr,
+ ff_thread_await_progress(&s->next_picture_ptr->f,
(s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y, 0);
+ if (s->next_picture.f.mbskip_table[xy + delta])
+ return SLICE_OK;
}
- if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture.f.mbskip_table[xy + delta])
- return SLICE_OK;
return SLICE_END;
}
}
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &s->chroma_x_shift,
&s->chroma_y_shift);
- /* set default edge pos, will be overriden
- * in decode_header if needed */
- s->h_edge_pos = s->mb_width * 16;
- s->v_edge_pos = s->mb_height * 16;
+ /* set default edge pos, will be overriden in decode_header if needed */
+ s->h_edge_pos = s->mb_width * 16;
+ s->v_edge_pos = s->mb_height * 16;
- s->mb_num = s->mb_width * s->mb_height;
+ s->mb_num = s->mb_width * s->mb_height;
- s->block_wrap[0] =
- s->block_wrap[1] =
- s->block_wrap[2] =
- s->block_wrap[3] = s->b8_stride;
- s->block_wrap[4] =
- s->block_wrap[5] = s->mb_stride;
+ s->block_wrap[0] =
+ s->block_wrap[1] =
+ s->block_wrap[2] =
+ s->block_wrap[3] = s->b8_stride;
+ s->block_wrap[4] =
+ s->block_wrap[5] = s->mb_stride;
- y_size = s->b8_stride * (2 * s->mb_height + 1);
- c_size = s->mb_stride * (s->mb_height + 1);
- yc_size = y_size + 2 * c_size;
+ y_size = s->b8_stride * (2 * s->mb_height + 1);
+ c_size = s->mb_stride * (s->mb_height + 1);
+ yc_size = y_size + 2 * c_size;
- /* convert fourcc to upper case */
- s->codec_tag = avpriv_toupper4(s->avctx->codec_tag);
+ /* convert fourcc to upper case */
+ s->codec_tag = avpriv_toupper4(s->avctx->codec_tag);
+ s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag);
- s->avctx->coded_frame = (AVFrame*)&s->current_picture;
- s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag);
++ s->avctx->coded_frame = &s->current_picture.f;
- s->avctx->coded_frame = &s->current_picture.f;
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int), fail); // error ressilience code looks cleaner with this
+ for (y = 0; y < s->mb_height; y++)
+ for (x = 0; x < s->mb_width; x++)
+ s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
- FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
- fail); // error ressilience code looks cleaner with this
- for (y = 0; y < s->mb_height; y++)
- for (x = 0; x < s->mb_width; x++)
- s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
+ s->mb_index2xy[s->mb_height * s->mb_width] = (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed?
- s->mb_index2xy[s->mb_height * s->mb_width] =
- (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed?
+ if (s->encoding) {
+ /* Allocate MV tables */
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
+ s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1;
+ s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1;
+ s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1;
+ s->b_bidir_forw_mv_table= s->b_bidir_forw_mv_table_base + s->mb_stride + 1;
+ s->b_bidir_back_mv_table= s->b_bidir_back_mv_table_base + s->mb_stride + 1;
+ s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1;
- if (s->encoding) {
- /* Allocate MV tables */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base,
- mv_table_size * 2 * sizeof(int16_t), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base,
- mv_table_size * 2 * sizeof(int16_t), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base,
- mv_table_size * 2 * sizeof(int16_t), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base,
- mv_table_size * 2 * sizeof(int16_t), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base,
- mv_table_size * 2 * sizeof(int16_t), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base,
- mv_table_size * 2 * sizeof(int16_t), fail);
- s->p_mv_table = s->p_mv_table_base +
- s->mb_stride + 1;
- s->b_forw_mv_table = s->b_forw_mv_table_base +
- s->mb_stride + 1;
- s->b_back_mv_table = s->b_back_mv_table_base +
- s->mb_stride + 1;
- s->b_bidir_forw_mv_table = s->b_bidir_forw_mv_table_base +
- s->mb_stride + 1;
- s->b_bidir_back_mv_table = s->b_bidir_back_mv_table_base +
- s->mb_stride + 1;
- s->b_direct_mv_table = s->b_direct_mv_table_base +
- s->mb_stride + 1;
-
- if (s->msmpeg4_version) {
- FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,
- 2 * 2 * (MAX_LEVEL + 1) *
- (MAX_RUN + 1) * 2 * sizeof(int), fail);
- }
- FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
-
- /* Allocate MB type table */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type, mb_array_size *
- sizeof(uint16_t), fail); // needed for encoding
-
- FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size *
- sizeof(int), fail);
-
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix,
- 64 * 32 * sizeof(int), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix,
- 64 * 32 * sizeof(int), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16,
- 64 * 32 * 2 * sizeof(uint16_t), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16,
- 64 * 32 * 2 * sizeof(uint16_t), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture,
- MAX_PICTURE_COUNT * sizeof(Picture *), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,
- MAX_PICTURE_COUNT * sizeof(Picture *), fail);
-
- if (s->avctx->noise_reduction) {
- FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,
- 2 * 64 * sizeof(uint16_t), fail);
- }
+ if(s->msmpeg4_version){
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats, 2*2*(MAX_LEVEL+1)*(MAX_RUN+1)*2*sizeof(int), fail);
+ }
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
+
+ /* Allocate MB type table */
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type , mb_array_size * sizeof(uint16_t), fail) //needed for encoding
+
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(int), fail)
+
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix , 64*32 * sizeof(int), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix , 64*32 * sizeof(int), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix , 64*32 * sizeof(int), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16 , 64*32*2 * sizeof(uint16_t), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix16, 64*32*2 * sizeof(uint16_t), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16 , 64*32*2 * sizeof(uint16_t), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail)
+
+ if(s->avctx->noise_reduction){
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail)
}
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->picture,
s->picture_count * sizeof(Picture), fail);
for (i = 0; i < s->picture_count; i++) {
- avcodec_get_frame_defaults((AVFrame *) &s->picture[i]);
+ avcodec_get_frame_defaults(&s->picture[i].f);
}
- if (s->width && s->height) {
- FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table,
- mb_array_size * sizeof(uint8_t), fail);
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, mb_array_size*sizeof(uint8_t), fail)
- if (s->codec_id == CODEC_ID_MPEG4 ||
- (s->flags & CODEC_FLAG_INTERLACED_ME)) {
+ if(s->codec_id==CODEC_ID_MPEG4 || (s->flags & CODEC_FLAG_INTERLACED_ME)){
/* interlaced direct mode decoding tables */
for (i = 0; i < 2; i++) {
int j, k;
/* Allocate a dummy frame */
i = ff_find_unused_picture(s, 0);
- s->last_picture_ptr = &s->picture[i];
+ if (i < 0)
+ return i;
+ s->last_picture_ptr= &s->picture[i];
+ s->last_picture_ptr->f.key_frame = 0;
if (ff_alloc_picture(s, s->last_picture_ptr, 0) < 0)
return -1;
- ff_thread_report_progress((AVFrame *) s->last_picture_ptr,
- INT_MAX, 0);
- ff_thread_report_progress((AVFrame *) s->last_picture_ptr,
- INT_MAX, 1);
+
+ if(s->codec_id == CODEC_ID_FLV1 || s->codec_id == CODEC_ID_H263){
+ for(i=0; i<avctx->height; i++)
+ memset(s->last_picture_ptr->f.data[0] + s->last_picture_ptr->f.linesize[0]*i, 16, avctx->width);
+ }
+
+ ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 0);
+ ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 1);
}
if ((s->next_picture_ptr == NULL ||
s->next_picture_ptr->f.data[0] == NULL) &&
s->pict_type == AV_PICTURE_TYPE_B) {
/* Allocate a dummy frame */
i = ff_find_unused_picture(s, 0);
- s->next_picture_ptr = &s->picture[i];
+ if (i < 0)
+ return i;
+ s->next_picture_ptr= &s->picture[i];
+ s->next_picture_ptr->f.key_frame = 0;
if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0)
return -1;
- ff_thread_report_progress((AVFrame *) s->next_picture_ptr,
- INT_MAX, 0);
- ff_thread_report_progress((AVFrame *) s->next_picture_ptr,
- INT_MAX, 1);
+ ff_thread_report_progress(&s->next_picture_ptr->f, INT_MAX, 0);
+ ff_thread_report_progress(&s->next_picture_ptr->f, INT_MAX, 1);
}
}
--- /dev/null
- * This file is part of Libav.
+ /*
+ * MSMPEG4 encoder backend
+ * Copyright (c) 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni@gmx.at>
+ *
- * Libav is free software; you can redistribute it and/or
++ * This file is part of FFmpeg.
+ *
- * Libav is distributed in the hope that it will be useful,
++ * 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.
+ *
- * License along with Libav; if not, write to the Free Software
++ * 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
- int best =-1, best_size =9999999;
- int chroma_best=-1, best_chroma_size=9999999;
++ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+ /**
+ * @file
+ * MSMPEG4 encoder backend
+ */
+
+ #include <stdint.h>
+ #include <string.h>
+
+ #include "libavutil/avutil.h"
+ #include "libavutil/mem.h"
+ #include "mpegvideo.h"
+ #include "msmpeg4.h"
+ #include "h263.h"
+ #include "mpeg4video.h"
+ #include "msmpeg4.h"
+ #include "msmpeg4data.h"
+ #include "put_bits.h"
+ #include "rl.h"
+ #include "vc1data.h"
+
+ static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2];
+
+ /* build the table which associate a (x,y) motion vector to a vlc */
+ static void init_mv_table(MVTable *tab)
+ {
+ int i, x, y;
+
+ tab->table_mv_index = av_malloc(sizeof(uint16_t) * 4096);
+ /* mark all entries as not used */
+ for(i=0;i<4096;i++)
+ tab->table_mv_index[i] = tab->n;
+
+ for(i=0;i<tab->n;i++) {
+ x = tab->table_mvx[i];
+ y = tab->table_mvy[i];
+ tab->table_mv_index[(x << 6) | y] = i;
+ }
+ }
+
+ void ff_msmpeg4_code012(PutBitContext *pb, int n)
+ {
+ if (n == 0) {
+ put_bits(pb, 1, 0);
+ } else {
+ put_bits(pb, 1, 1);
+ put_bits(pb, 1, (n >= 2));
+ }
+ }
+
+ static int get_size_of_code(MpegEncContext * s, RLTable *rl, int last, int run, int level, int intra){
+ int size=0;
+ int code;
+ int run_diff= intra ? 0 : 1;
+
+ code = get_rl_index(rl, last, run, level);
+ size+= rl->table_vlc[code][1];
+ if (code == rl->n) {
+ int level1, run1;
+
+ level1 = level - rl->max_level[last][run];
+ if (level1 < 1)
+ goto esc2;
+ code = get_rl_index(rl, last, run, level1);
+ if (code == rl->n) {
+ esc2:
+ size++;
+ if (level > MAX_LEVEL)
+ goto esc3;
+ run1 = run - rl->max_run[last][level] - run_diff;
+ if (run1 < 0)
+ goto esc3;
+ code = get_rl_index(rl, last, run1, level);
+ if (code == rl->n) {
+ esc3:
+ /* third escape */
+ size+=1+1+6+8;
+ } else {
+ /* second escape */
+ size+= 1+1+ rl->table_vlc[code][1];
+ }
+ } else {
+ /* first escape */
+ size+= 1+1+ rl->table_vlc[code][1];
+ }
+ } else {
+ size++;
+ }
+ return size;
+ }
+
+ av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
+ {
+ static int init_done=0;
+ int i;
+
+ ff_msmpeg4_common_init(s);
+ if(s->msmpeg4_version>=4){
+ s->min_qcoeff= -255;
+ s->max_qcoeff= 255;
+ }
+
+ if (!init_done) {
+ /* init various encoding tables */
+ init_done = 1;
+ init_mv_table(&ff_mv_tables[0]);
+ init_mv_table(&ff_mv_tables[1]);
+ for(i=0;i<NB_RL_TABLES;i++)
+ ff_init_rl(&ff_rl_table[i], ff_static_rl_table_store[i]);
+
+ for(i=0; i<NB_RL_TABLES; i++){
+ int level;
+ for (level = 1; level <= MAX_LEVEL; level++) {
+ int run;
+ for(run=0; run<=MAX_RUN; run++){
+ int last;
+ for(last=0; last<2; last++){
+ rl_length[i][level][run][last]= get_size_of_code(s, &ff_rl_table[ i], last, run, level, 0);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ static void find_best_tables(MpegEncContext * s)
+ {
+ int i;
++ int best = 0, best_size = INT_MAX;
++ int chroma_best = 0, best_chroma_size = INT_MAX;
+
+ for(i=0; i<3; i++){
+ int level;
+ int chroma_size=0;
+ int size=0;
+
+ if(i>0){// ;)
+ size++;
+ chroma_size++;
+ }
+ for(level=0; level<=MAX_LEVEL; level++){
+ int run;
+ for(run=0; run<=MAX_RUN; run++){
+ int last;
+ const int last_size= size + chroma_size;
+ for(last=0; last<2; last++){
+ int inter_count = s->ac_stats[0][0][level][run][last] + s->ac_stats[0][1][level][run][last];
+ int intra_luma_count = s->ac_stats[1][0][level][run][last];
+ int intra_chroma_count= s->ac_stats[1][1][level][run][last];
+
+ if(s->pict_type==AV_PICTURE_TYPE_I){
+ size += intra_luma_count *rl_length[i ][level][run][last];
+ chroma_size+= intra_chroma_count*rl_length[i+3][level][run][last];
+ }else{
+ size+= intra_luma_count *rl_length[i ][level][run][last]
+ +intra_chroma_count*rl_length[i+3][level][run][last]
+ +inter_count *rl_length[i+3][level][run][last];
+ }
+ }
+ if(last_size == size+chroma_size) break;
+ }
+ }
+ if(size<best_size){
+ best_size= size;
+ best= i;
+ }
+ if(chroma_size<best_chroma_size){
+ best_chroma_size= chroma_size;
+ chroma_best= i;
+ }
+ }
+
+ // printf("type:%d, best:%d, qp:%d, var:%d, mcvar:%d, size:%d //\n",
+ // s->pict_type, best, s->qscale, s->mb_var_sum, s->mc_mb_var_sum, best_size);
+
+ if(s->pict_type==AV_PICTURE_TYPE_P) chroma_best= best;
+
+ memset(s->ac_stats, 0, sizeof(int)*(MAX_LEVEL+1)*(MAX_RUN+1)*2*2*2);
+
+ s->rl_table_index = best;
+ s->rl_chroma_table_index= chroma_best;
+
+ if(s->pict_type != s->last_non_b_pict_type){
+ s->rl_table_index= 2;
+ if(s->pict_type==AV_PICTURE_TYPE_I)
+ s->rl_chroma_table_index= 1;
+ else
+ s->rl_chroma_table_index= 2;
+ }
+
+ }
+
+ /* write MSMPEG4 compatible frame header */
+ void ff_msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
+ {
+ find_best_tables(s);
+
+ avpriv_align_put_bits(&s->pb);
+ put_bits(&s->pb, 2, s->pict_type - 1);
+
+ put_bits(&s->pb, 5, s->qscale);
+ if(s->msmpeg4_version<=2){
+ s->rl_table_index = 2;
+ s->rl_chroma_table_index = 2;
+ }
+
+ s->dc_table_index = 1;
+ s->mv_table_index = 1; /* only if P frame */
+ s->use_skip_mb_code = 1; /* only if P frame */
+ s->per_mb_rl_table = 0;
+ if(s->msmpeg4_version==4)
+ s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE && s->pict_type==AV_PICTURE_TYPE_P);
+ //printf("%d %d %d %d %d\n", s->pict_type, s->bit_rate, s->inter_intra_pred, s->width, s->height);
+
+ if (s->pict_type == AV_PICTURE_TYPE_I) {
+ s->slice_height= s->mb_height/1;
+ put_bits(&s->pb, 5, 0x16 + s->mb_height/s->slice_height);
+
+ if(s->msmpeg4_version==4){
+ ff_msmpeg4_encode_ext_header(s);
+ if(s->bit_rate>MBAC_BITRATE)
+ put_bits(&s->pb, 1, s->per_mb_rl_table);
+ }
+
+ if(s->msmpeg4_version>2){
+ if(!s->per_mb_rl_table){
+ ff_msmpeg4_code012(&s->pb, s->rl_chroma_table_index);
+ ff_msmpeg4_code012(&s->pb, s->rl_table_index);
+ }
+
+ put_bits(&s->pb, 1, s->dc_table_index);
+ }
+ } else {
+ put_bits(&s->pb, 1, s->use_skip_mb_code);
+
+ if(s->msmpeg4_version==4 && s->bit_rate>MBAC_BITRATE)
+ put_bits(&s->pb, 1, s->per_mb_rl_table);
+
+ if(s->msmpeg4_version>2){
+ if(!s->per_mb_rl_table)
+ ff_msmpeg4_code012(&s->pb, s->rl_table_index);
+
+ put_bits(&s->pb, 1, s->dc_table_index);
+
+ put_bits(&s->pb, 1, s->mv_table_index);
+ }
+ }
+
+ s->esc3_level_length= 0;
+ s->esc3_run_length= 0;
+ }
+
+ void ff_msmpeg4_encode_ext_header(MpegEncContext * s)
+ {
+ put_bits(&s->pb, 5, s->avctx->time_base.den / s->avctx->time_base.num); //yes 29.97 -> 29
+
+ put_bits(&s->pb, 11, FFMIN(s->bit_rate/1024, 2047));
+
+ if(s->msmpeg4_version>=3)
+ put_bits(&s->pb, 1, s->flipflop_rounding);
+ else
+ assert(s->flipflop_rounding==0);
+ }
+
+ void ff_msmpeg4_encode_motion(MpegEncContext * s,
+ int mx, int my)
+ {
+ int code;
+ MVTable *mv;
+
+ /* modulo encoding */
+ /* WARNING : you cannot reach all the MVs even with the modulo
+ encoding. This is a somewhat strange compromise they took !!! */
+ if (mx <= -64)
+ mx += 64;
+ else if (mx >= 64)
+ mx -= 64;
+ if (my <= -64)
+ my += 64;
+ else if (my >= 64)
+ my -= 64;
+
+ mx += 32;
+ my += 32;
+ #if 0
+ if ((unsigned)mx >= 64 ||
+ (unsigned)my >= 64)
+ av_log(s->avctx, AV_LOG_ERROR, "error mx=%d my=%d\n", mx, my);
+ #endif
+ mv = &ff_mv_tables[s->mv_table_index];
+
+ code = mv->table_mv_index[(mx << 6) | my];
+ put_bits(&s->pb,
+ mv->table_mv_bits[code],
+ mv->table_mv_code[code]);
+ if (code == mv->n) {
+ /* escape : code literally */
+ put_bits(&s->pb, 6, mx);
+ put_bits(&s->pb, 6, my);
+ }
+ }
+
+ void ff_msmpeg4_handle_slices(MpegEncContext *s){
+ if (s->mb_x == 0) {
+ if (s->slice_height && (s->mb_y % s->slice_height) == 0) {
+ if(s->msmpeg4_version < 4){
+ ff_mpeg4_clean_buffers(s);
+ }
+ s->first_slice_line = 1;
+ } else {
+ s->first_slice_line = 0;
+ }
+ }
+ }
+
+ static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
+ {
+ int range, bit_size, sign, code, bits;
+
+ if (val == 0) {
+ /* zero vector */
+ code = 0;
+ put_bits(&s->pb, ff_mvtab[code][1], ff_mvtab[code][0]);
+ } else {
+ bit_size = s->f_code - 1;
+ range = 1 << bit_size;
+ if (val <= -64)
+ val += 64;
+ else if (val >= 64)
+ val -= 64;
+
+ if (val >= 0) {
+ sign = 0;
+ } else {
+ val = -val;
+ sign = 1;
+ }
+ val--;
+ code = (val >> bit_size) + 1;
+ bits = val & (range - 1);
+
+ put_bits(&s->pb, ff_mvtab[code][1] + 1, (ff_mvtab[code][0] << 1) | sign);
+ if (bit_size > 0) {
+ put_bits(&s->pb, bit_size, bits);
+ }
+ }
+ }
+
+ void ff_msmpeg4_encode_mb(MpegEncContext * s,
+ DCTELEM block[6][64],
+ int motion_x, int motion_y)
+ {
+ int cbp, coded_cbp, i;
+ int pred_x, pred_y;
+ uint8_t *coded_block;
+
+ ff_msmpeg4_handle_slices(s);
+
+ if (!s->mb_intra) {
+ /* compute cbp */
+ cbp = 0;
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0)
+ cbp |= 1 << (5 - i);
+ }
+ if (s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
+ /* skip macroblock */
+ put_bits(&s->pb, 1, 1);
+ s->last_bits++;
+ s->misc_bits++;
+ s->skip_count++;
+
+ return;
+ }
+ if (s->use_skip_mb_code)
+ put_bits(&s->pb, 1, 0); /* mb coded */
+
+ if(s->msmpeg4_version<=2){
+ put_bits(&s->pb,
+ ff_v2_mb_type[cbp&3][1],
+ ff_v2_mb_type[cbp&3][0]);
+ if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
+ else coded_cbp= cbp;
+
+ put_bits(&s->pb,
+ ff_h263_cbpy_tab[coded_cbp>>2][1],
+ ff_h263_cbpy_tab[coded_cbp>>2][0]);
+
+ s->misc_bits += get_bits_diff(s);
+
+ ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
+ msmpeg4v2_encode_motion(s, motion_x - pred_x);
+ msmpeg4v2_encode_motion(s, motion_y - pred_y);
+ }else{
+ put_bits(&s->pb,
+ ff_table_mb_non_intra[cbp + 64][1],
+ ff_table_mb_non_intra[cbp + 64][0]);
+
+ s->misc_bits += get_bits_diff(s);
+
+ /* motion vector */
+ ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
+ ff_msmpeg4_encode_motion(s, motion_x - pred_x,
+ motion_y - pred_y);
+ }
+
+ s->mv_bits += get_bits_diff(s);
+
+ for (i = 0; i < 6; i++) {
+ ff_msmpeg4_encode_block(s, block[i], i);
+ }
+ s->p_tex_bits += get_bits_diff(s);
+ } else {
+ /* compute cbp */
+ cbp = 0;
+ coded_cbp = 0;
+ for (i = 0; i < 6; i++) {
+ int val, pred;
+ val = (s->block_last_index[i] >= 1);
+ cbp |= val << (5 - i);
+ if (i < 4) {
+ /* predict value for close blocks only for luma */
+ pred = ff_msmpeg4_coded_block_pred(s, i, &coded_block);
+ *coded_block = val;
+ val = val ^ pred;
+ }
+ coded_cbp |= val << (5 - i);
+ }
+
+ if(s->msmpeg4_version<=2){
+ if (s->pict_type == AV_PICTURE_TYPE_I) {
+ put_bits(&s->pb,
+ ff_v2_intra_cbpc[cbp&3][1], ff_v2_intra_cbpc[cbp&3][0]);
+ } else {
+ if (s->use_skip_mb_code)
+ put_bits(&s->pb, 1, 0); /* mb coded */
+ put_bits(&s->pb,
+ ff_v2_mb_type[(cbp&3) + 4][1],
+ ff_v2_mb_type[(cbp&3) + 4][0]);
+ }
+ put_bits(&s->pb, 1, 0); /* no AC prediction yet */
+ put_bits(&s->pb,
+ ff_h263_cbpy_tab[cbp>>2][1],
+ ff_h263_cbpy_tab[cbp>>2][0]);
+ }else{
+ if (s->pict_type == AV_PICTURE_TYPE_I) {
+ put_bits(&s->pb,
+ ff_msmp4_mb_i_table[coded_cbp][1], ff_msmp4_mb_i_table[coded_cbp][0]);
+ } else {
+ if (s->use_skip_mb_code)
+ put_bits(&s->pb, 1, 0); /* mb coded */
+ put_bits(&s->pb,
+ ff_table_mb_non_intra[cbp][1],
+ ff_table_mb_non_intra[cbp][0]);
+ }
+ put_bits(&s->pb, 1, 0); /* no AC prediction yet */
+ if(s->inter_intra_pred){
+ s->h263_aic_dir=0;
+ put_bits(&s->pb, ff_table_inter_intra[s->h263_aic_dir][1], ff_table_inter_intra[s->h263_aic_dir][0]);
+ }
+ }
+ s->misc_bits += get_bits_diff(s);
+
+ for (i = 0; i < 6; i++) {
+ ff_msmpeg4_encode_block(s, block[i], i);
+ }
+ s->i_tex_bits += get_bits_diff(s);
+ s->i_count++;
+ }
+ }
+
+ static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
+ {
+ int sign, code;
+ int pred, extquant;
+ int extrabits = 0;
+
+ int16_t *dc_val;
+ pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
+
+ /* update predictor */
+ if (n < 4) {
+ *dc_val = level * s->y_dc_scale;
+ } else {
+ *dc_val = level * s->c_dc_scale;
+ }
+
+ /* do the prediction */
+ level -= pred;
+
+ if(s->msmpeg4_version<=2){
+ if (n < 4) {
+ put_bits(&s->pb,
+ ff_v2_dc_lum_table[level + 256][1],
+ ff_v2_dc_lum_table[level + 256][0]);
+ }else{
+ put_bits(&s->pb,
+ ff_v2_dc_chroma_table[level + 256][1],
+ ff_v2_dc_chroma_table[level + 256][0]);
+ }
+ }else{
+ sign = 0;
+ if (level < 0) {
+ level = -level;
+ sign = 1;
+ }
+ code = level;
+ if (code > DC_MAX)
+ code = DC_MAX;
+ else if( s->msmpeg4_version>=6 ) {
+ if( s->qscale == 1 ) {
+ extquant = (level + 3) & 0x3;
+ code = ((level+3)>>2);
+ } else if( s->qscale == 2 ) {
+ extquant = (level + 1) & 0x1;
+ code = ((level+1)>>1);
+ }
+ }
+
+ if (s->dc_table_index == 0) {
+ if (n < 4) {
+ put_bits(&s->pb, ff_table0_dc_lum[code][1], ff_table0_dc_lum[code][0]);
+ } else {
+ put_bits(&s->pb, ff_table0_dc_chroma[code][1], ff_table0_dc_chroma[code][0]);
+ }
+ } else {
+ if (n < 4) {
+ put_bits(&s->pb, ff_table1_dc_lum[code][1], ff_table1_dc_lum[code][0]);
+ } else {
+ put_bits(&s->pb, ff_table1_dc_chroma[code][1], ff_table1_dc_chroma[code][0]);
+ }
+ }
+
+ if(s->msmpeg4_version>=6 && s->qscale<=2)
+ extrabits = 3 - s->qscale;
+
+ if (code == DC_MAX)
+ put_bits(&s->pb, 8 + extrabits, level);
+ else if(extrabits > 0)//== VC1 && s->qscale<=2
+ put_bits(&s->pb, extrabits, extquant);
+
+ if (level != 0) {
+ put_bits(&s->pb, 1, sign);
+ }
+ }
+ }
+
+ /* Encoding of a block. Very similar to MPEG4 except for a different
+ escape coding (same as H263) and more vlc tables.
+ */
+ void ff_msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n)
+ {
+ int level, run, last, i, j, last_index;
+ int last_non_zero, sign, slevel;
+ int code, run_diff, dc_pred_dir;
+ const RLTable *rl;
+ const uint8_t *scantable;
+
+ if (s->mb_intra) {
+ msmpeg4_encode_dc(s, block[0], n, &dc_pred_dir);
+ i = 1;
+ if (n < 4) {
+ rl = &ff_rl_table[s->rl_table_index];
+ } else {
+ rl = &ff_rl_table[3 + s->rl_chroma_table_index];
+ }
+ run_diff = s->msmpeg4_version>=4;
+ scantable= s->intra_scantable.permutated;
+ } else {
+ i = 0;
+ rl = &ff_rl_table[3 + s->rl_table_index];
+ if(s->msmpeg4_version<=2)
+ run_diff = 0;
+ else
+ run_diff = 1;
+ scantable= s->inter_scantable.permutated;
+ }
+
+ /* recalculate block_last_index for M$ wmv1 */
+ if(s->msmpeg4_version>=4 && s->msmpeg4_version<6 && s->block_last_index[n]>0){
+ for(last_index=63; last_index>=0; last_index--){
+ if(block[scantable[last_index]]) break;
+ }
+ s->block_last_index[n]= last_index;
+ }else
+ last_index = s->block_last_index[n];
+ /* AC coefs */
+ last_non_zero = i - 1;
+ for (; i <= last_index; i++) {
+ j = scantable[i];
+ level = block[j];
+ if (level) {
+ run = i - last_non_zero - 1;
+ last = (i == last_index);
+ sign = 0;
+ slevel = level;
+ if (level < 0) {
+ sign = 1;
+ level = -level;
+ }
+
+ if(level<=MAX_LEVEL && run<=MAX_RUN){
+ s->ac_stats[s->mb_intra][n>3][level][run][last]++;
+ }
+
+ s->ac_stats[s->mb_intra][n > 3][40][63][0]++; //esc3 like
+
+ code = get_rl_index(rl, last, run, level);
+ put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
+ if (code == rl->n) {
+ int level1, run1;
+
+ level1 = level - rl->max_level[last][run];
+ if (level1 < 1)
+ goto esc2;
+ code = get_rl_index(rl, last, run, level1);
+ if (code == rl->n) {
+ esc2:
+ put_bits(&s->pb, 1, 0);
+ if (level > MAX_LEVEL)
+ goto esc3;
+ run1 = run - rl->max_run[last][level] - run_diff;
+ if (run1 < 0)
+ goto esc3;
+ code = get_rl_index(rl, last, run1+1, level);
+ if (s->msmpeg4_version == 4 && code == rl->n)
+ goto esc3;
+ code = get_rl_index(rl, last, run1, level);
+ if (code == rl->n) {
+ esc3:
+ /* third escape */
+ put_bits(&s->pb, 1, 0);
+ put_bits(&s->pb, 1, last);
+ if(s->msmpeg4_version>=4){
+ if(s->esc3_level_length==0){
+ s->esc3_level_length=8;
+ s->esc3_run_length= 6;
+ //ESCLVLSZ + ESCRUNSZ
+ if(s->qscale<8)
+ put_bits(&s->pb, 6 + (s->msmpeg4_version>=6), 3);
+ else
+ put_bits(&s->pb, 8, 3);
+ }
+ put_bits(&s->pb, s->esc3_run_length, run);
+ put_bits(&s->pb, 1, sign);
+ put_bits(&s->pb, s->esc3_level_length, level);
+ }else{
+ put_bits(&s->pb, 6, run);
+ put_sbits(&s->pb, 8, slevel);
+ }
+ } else {
+ /* second escape */
+ put_bits(&s->pb, 1, 1);
+ put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
+ put_bits(&s->pb, 1, sign);
+ }
+ } else {
+ /* first escape */
+ put_bits(&s->pb, 1, 1);
+ put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
+ put_bits(&s->pb, 1, sign);
+ }
+ } else {
+ put_bits(&s->pb, 1, sign);
+ }
+ last_non_zero = i;
+ }
+ }
+ }
int buf_size = avpkt->size;
PNMContext * const s = avctx->priv_data;
AVFrame *picture = data;
- AVFrame * const p = (AVFrame*)&s->picture;
+ AVFrame * const p = &s->picture;
- int i, j, n, linesize, h, upgrade = 0;
+ int i, j, n, linesize, h, upgrade = 0, is_mono = 0;
unsigned char *ptr;
int components, sample_len;
}
}
break;
- case PIX_FMT_RGB32:
- ptr = p->data[0];
- linesize = p->linesize[0];
- if (s->bytestream + avctx->width * avctx->height * 4 > s->bytestream_end)
- return -1;
- for (i = 0; i < avctx->height; i++) {
- int j, r, g, b, a;
-
- for (j = 0; j < avctx->width; j++) {
- r = *s->bytestream++;
- g = *s->bytestream++;
- b = *s->bytestream++;
- a = *s->bytestream++;
- ((uint32_t *)ptr)[j] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- ptr += linesize;
- }
- break;
}
- *picture = *(AVFrame*)&s->picture;
+ *picture = s->picture;
*data_size = sizeof(AVPicture);
return s->bytestream - s->bytestream_start;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
QpegContext * const a = avctx->priv_data;
- AVFrame * p= (AVFrame*)&a->pic;
- AVFrame * ref= (AVFrame*)&a->ref;
- AVFrame * const p = &a->pic;
++ AVFrame * p = &a->pic;
++ AVFrame * ref= &a->ref;
uint8_t* outdata;
- int delta;
+ int delta, ret = 0;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
- p->reference = 3;
- if (avctx->reget_buffer(avctx, p) < 0) {
- av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
+ if(ref->data[0])
+ avctx->release_buffer(avctx, ref);
+ FFSWAP(AVFrame, *ref, *p);
+
+ p->reference= 3;
+ if(avctx->get_buffer(avctx, p) < 0){
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
outdata = a->pic.data[0];
static av_cold int decode_end(AVCodecContext *avctx){
QpegContext * const a = avctx->priv_data;
- AVFrame * const p= (AVFrame*)&a->pic;
- AVFrame * const ref= (AVFrame*)&a->ref;
+ AVFrame * const p = &a->pic;
++ AVFrame * const ref= &a->ref;
if(p->data[0])
avctx->release_buffer(avctx, p);
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
+ int linesize_align = 4;
RawVideoContext *context = avctx->priv_data;
- AVFrame * frame = (AVFrame *) data;
- AVPicture * picture = (AVPicture *) data;
+ AVFrame *frame = data;
+ AVPicture *picture = data;
frame->pict_type = avctx->coded_frame->pict_type;
frame->interlaced_frame = avctx->coded_frame->interlaced_frame;
static av_cold int raw_init_encoder(AVCodecContext *avctx)
{
- avctx->coded_frame = (AVFrame *)avctx->priv_data;
+ avctx->coded_frame = avctx->priv_data;
+ avcodec_get_frame_defaults(avctx->coded_frame);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
avctx->bits_per_coded_sample = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]);
if(!avctx->codec_tag)
avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
const uint8_t *buf_end = avpkt->data + avpkt->size;
TargaContext * const s = avctx->priv_data;
AVFrame *picture = data;
- AVFrame * const p= (AVFrame*)&s->picture;
+ AVFrame * const p = &s->picture;
uint8_t *dst;
int stride;
- int idlen, compr, y, w, h, bpp, flags;
+ int idlen, pal, compr, y, w, h, bpp, flags;
int first_clr, colors, csize;
/* parse image header */
}
}
}
+ if(flags & 0x10){ // right-to-left, needs horizontal flip
+ int x;
+ for(y = 0; y < s->height; y++){
+ void *line = &p->data[0][y * p->linesize[0]];
+ for(x = 0; x < s->width >> 1; x++){
+ switch(s->bpp){
+ case 32:
+ FFSWAP(uint32_t, ((uint32_t *)line)[x], ((uint32_t *)line)[s->width - x - 1]);
+ break;
+ case 24:
+ FFSWAP(uint8_t, ((uint8_t *)line)[3 * x ], ((uint8_t *)line)[3 * s->width - 3 * x - 3]);
+ FFSWAP(uint8_t, ((uint8_t *)line)[3 * x + 1], ((uint8_t *)line)[3 * s->width - 3 * x - 2]);
+ FFSWAP(uint8_t, ((uint8_t *)line)[3 * x + 2], ((uint8_t *)line)[3 * s->width - 3 * x - 1]);
+ break;
+ case 16:
+ FFSWAP(uint16_t, ((uint16_t *)line)[x], ((uint16_t *)line)[s->width - x - 1]);
+ break;
+ case 8:
+ FFSWAP(uint8_t, ((uint8_t *)line)[x], ((uint8_t *)line)[s->width - x - 1]);
+ }
+ }
+ }
+ }
- *picture= *(AVFrame*)&s->picture;
+ *picture = s->picture;
*data_size = sizeof(AVPicture);
return avpkt->size;
}
if(s->invert){
- uint8_t *src;
- int j;
-
- src = s->picture.data[0];
- for(j = 0; j < s->height; j++){
- for(i = 0; i < s->picture.linesize[0]; i++)
- src[i] = 255 - src[i];
- src += s->picture.linesize[0];
+ dst = s->picture.data[0];
+ for(i = 0; i < s->height; i++){
+ for(j = 0; j < s->picture.linesize[0]; j++)
+ dst[j] = (s->avctx->pix_fmt == PIX_FMT_PAL8 ? (1<<s->bpp) - 1 : 255) - dst[j];
+ dst += s->picture.linesize[0];
}
}
- *picture= *(AVFrame*)&s->picture;
+ *picture = s->picture;
*data_size = sizeof(AVPicture);
return buf_size;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
TM2Context * const l = avctx->priv_data;
- AVFrame * const p= (AVFrame*)&l->pic;
+ AVFrame * const p = &l->pic;
int i, skip, t;
- uint8_t *swbuf;
- swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if(!swbuf){
+ av_fast_padded_malloc(&l->buffer, &l->buffer_size, buf_size);
+ if(!l->buffer){
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
return -1;
}
s->height = avctx->height;
s->blocks = (s->width / 8) * (s->height / 8);
avctx->pix_fmt = PIX_FMT_YUV410P;
- avcodec_get_frame_defaults(&s->frame);
+ avctx->coded_frame = &s->frame;
+ avctx->coded_frame = (AVFrame*) &s->frame;
s->ulti_codebook = ulti_codebook;
return 0;
avpkt->size = 0;
else if (!(avctx->codec->capabilities & CODEC_CAP_DELAY))
avpkt->pts = avpkt->dts = frame->pts;
+ if (avpkt->data && avpkt->destruct == av_destruct_packet) {
+ new_data = av_realloc(avpkt->data,
+ avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (new_data)
+ avpkt->data = new_data;
+ }
+ if (!user_packet && avpkt->data) {
+ uint8_t *new_data = av_realloc(avpkt->data, avpkt->size);
+ if (new_data)
+ avpkt->data = new_data;
+ }
+
avctx->frame_number++;
}
static av_cold void common_init(AVCodecContext *avctx){
VCR1Context * const a = avctx->priv_data;
- avctx->coded_frame= (AVFrame*)&a->picture;
+ avctx->coded_frame = &a->picture;
+ avcodec_get_frame_defaults(&a->picture);
a->avctx= avctx;
}
#define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 54
--#define LIBAVCODEC_VERSION_MINOR 5
-#define LIBAVCODEC_VERSION_MICRO 0
++#define LIBAVCODEC_VERSION_MINOR 6
+#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
* Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion
* Copyright (c) 2008 - 2011 Sascha Sommer, Benjamin Larsson
* Copyright (c) 2011 Andreas Öman
+ * Copyright (c) 2011 - 2012 Mashiat Sarker Shakkhar
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * 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.
ea->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ea->video_codec;
+ // parsing is necessary to make FFmpeg generate correct timestamps
+ if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO)
+ st->need_parsing = AVSTREAM_PARSE_HEADERS;
st->codec->codec_tag = 0; /* no fourcc */
- if (ea->time_base.num)
- avpriv_set_pts_info(st, 64, ea->time_base.num, ea->time_base.den);
st->codec->width = ea->width;
st->codec->height = ea->height;
- avpriv_set_pts_info(st, 33, ea->time_base.num, ea->time_base.den);
++ if (ea->time_base.num)
++ avpriv_set_pts_info(st, 64, ea->time_base.num, ea->time_base.den);
+ st->r_frame_rate = st->avg_frame_rate = (AVRational){ea->time_base.den,
+ ea->time_base.num};
}
if (ea->audio_codec) {
return AVERROR(EIO);
}
- avio_rb32(pb); /* header size */
- avio_rb16(pb);
- avio_rb32(pb);
- avio_rb32(pb); /* number of headers */
+ tag_size = avio_rb32(pb);
+ avio_skip(pb, tag_size - 8);
for(;;) {
- if (pb->eof_reached)
+ if (url_feof(pb))
return -1;
tag = avio_rl32(pb);
tag_size = avio_rb32(pb);
typedef unsigned char ubyte;
typedef signed char sbyte;
-
/* RGB interleaver, 16 planar pels 8-bit samples per channel in
- homogeneous vector registers x0,x1,x2 are interleaved with the
- following technique:
-
- o0 = vec_mergeh (x0,x1);
- o1 = vec_perm (o0, x2, perm_rgb_0);
- o2 = vec_perm (o0, x2, perm_rgb_1);
- o3 = vec_mergel (x0,x1);
- o4 = vec_perm (o3,o2,perm_rgb_2);
- o5 = vec_perm (o3,o2,perm_rgb_3);
-
- perm_rgb_0: o0(RG).h v1(B) --> o1*
- 0 1 2 3 4
- rgbr|gbrg|brgb|rgbr
- 0010 0100 1001 0010
- 0102 3145 2673 894A
-
- perm_rgb_1: o0(RG).h v1(B) --> o2
- 0 1 2 3 4
- gbrg|brgb|bbbb|bbbb
- 0100 1001 1111 1111
- B5CD 6EF7 89AB CDEF
-
- perm_rgb_2: o3(RG).l o2(rgbB.l) --> o4*
- 0 1 2 3 4
- gbrg|brgb|rgbr|gbrg
- 1111 1111 0010 0100
- 89AB CDEF 0182 3945
-
- perm_rgb_2: o3(RG).l o2(rgbB.l) ---> o5*
- 0 1 2 3 4
- brgb|rgbr|gbrg|brgb
- 1001 0010 0100 1001
- a67b 89cA BdCD eEFf
-
- */
- static
- const vector unsigned char
- perm_rgb_0 = {0x00,0x01,0x10,0x02,0x03,0x11,0x04,0x05,
- 0x12,0x06,0x07,0x13,0x08,0x09,0x14,0x0a},
- perm_rgb_1 = {0x0b,0x15,0x0c,0x0d,0x16,0x0e,0x0f,0x17,
- 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f},
- perm_rgb_2 = {0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
- 0x00,0x01,0x18,0x02,0x03,0x19,0x04,0x05},
- perm_rgb_3 = {0x1a,0x06,0x07,0x1b,0x08,0x09,0x1c,0x0a,
- 0x0b,0x1d,0x0c,0x0d,0x1e,0x0e,0x0f,0x1f};
-
- #define vec_merge3(x2,x1,x0,y0,y1,y2) \
- do { \
- __typeof__(x0) o0,o2,o3; \
- o0 = vec_mergeh (x0,x1); \
- y0 = vec_perm (o0, x2, perm_rgb_0); \
- o2 = vec_perm (o0, x2, perm_rgb_1); \
- o3 = vec_mergel (x0,x1); \
- y1 = vec_perm (o3,o2,perm_rgb_2); \
- y2 = vec_perm (o3,o2,perm_rgb_3); \
- } while(0)
-
- #define vec_mstbgr24(x0,x1,x2,ptr) \
- do { \
- __typeof__(x0) _0,_1,_2; \
- vec_merge3 (x0,x1,x2,_0,_1,_2); \
- vec_st (_0, 0, ptr++); \
- vec_st (_1, 0, ptr++); \
- vec_st (_2, 0, ptr++); \
- } while (0)
-
- #define vec_mstrgb24(x0,x1,x2,ptr) \
- do { \
- __typeof__(x0) _0,_1,_2; \
- vec_merge3 (x2,x1,x0,_0,_1,_2); \
- vec_st (_0, 0, ptr++); \
- vec_st (_1, 0, ptr++); \
- vec_st (_2, 0, ptr++); \
- } while (0)
+ * homogeneous vector registers x0,x1,x2 are interleaved with the
+ * following technique:
+ *
+ * o0 = vec_mergeh(x0, x1);
+ * o1 = vec_perm(o0, x2, perm_rgb_0);
+ * o2 = vec_perm(o0, x2, perm_rgb_1);
+ * o3 = vec_mergel(x0, x1);
+ * o4 = vec_perm(o3, o2, perm_rgb_2);
+ * o5 = vec_perm(o3, o2, perm_rgb_3);
+ *
+ * perm_rgb_0: o0(RG).h v1(B) --> o1*
+ * 0 1 2 3 4
+ * rgbr|gbrg|brgb|rgbr
+ * 0010 0100 1001 0010
+ * 0102 3145 2673 894A
+ *
+ * perm_rgb_1: o0(RG).h v1(B) --> o2
+ * 0 1 2 3 4
+ * gbrg|brgb|bbbb|bbbb
+ * 0100 1001 1111 1111
+ * B5CD 6EF7 89AB CDEF
+ *
+ * perm_rgb_2: o3(RG).l o2(rgbB.l) --> o4*
+ * 0 1 2 3 4
+ * gbrg|brgb|rgbr|gbrg
+ * 1111 1111 0010 0100
+ * 89AB CDEF 0182 3945
+ *
+ * perm_rgb_2: o3(RG).l o2(rgbB.l) ---> o5*
+ * 0 1 2 3 4
+ * brgb|rgbr|gbrg|brgb
+ * 1001 0010 0100 1001
+ * a67b 89cA BdCD eEFf
+ *
+ */
+ static const vector unsigned char
+ perm_rgb_0 = { 0x00, 0x01, 0x10, 0x02, 0x03, 0x11, 0x04, 0x05,
+ 0x12, 0x06, 0x07, 0x13, 0x08, 0x09, 0x14, 0x0a },
+ perm_rgb_1 = { 0x0b, 0x15, 0x0c, 0x0d, 0x16, 0x0e, 0x0f, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
+ perm_rgb_2 = { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x00, 0x01, 0x18, 0x02, 0x03, 0x19, 0x04, 0x05 },
+ perm_rgb_3 = { 0x1a, 0x06, 0x07, 0x1b, 0x08, 0x09, 0x1c, 0x0a,
+ 0x0b, 0x1d, 0x0c, 0x0d, 0x1e, 0x0e, 0x0f, 0x1f };
+
+ #define vec_merge3(x2, x1, x0, y0, y1, y2) \
+ do { \
+ __typeof__(x0) o0, o2, o3; \
+ o0 = vec_mergeh(x0, x1); \
+ y0 = vec_perm(o0, x2, perm_rgb_0); \
+ o2 = vec_perm(o0, x2, perm_rgb_1); \
+ o3 = vec_mergel(x0, x1); \
+ y1 = vec_perm(o3, o2, perm_rgb_2); \
+ y2 = vec_perm(o3, o2, perm_rgb_3); \
+ } while (0)
+
+ #define vec_mstbgr24(x0, x1, x2, ptr) \
+ do { \
+ __typeof__(x0) _0, _1, _2; \
+ vec_merge3(x0, x1, x2, _0, _1, _2); \
+ vec_st(_0, 0, ptr++); \
+ vec_st(_1, 0, ptr++); \
+ vec_st(_2, 0, ptr++); \
+ } while (0)
+
+ #define vec_mstrgb24(x0, x1, x2, ptr) \
+ do { \
+ __typeof__(x0) _0, _1, _2; \
+ vec_merge3(x2, x1, x0, _0, _1, _2); \
+ vec_st(_0, 0, ptr++); \
+ vec_st(_1, 0, ptr++); \
+ vec_st(_2, 0, ptr++); \
+ } while (0)
/* pack the pixels in rgb0 format
- msb R
- lsb 0
- */
- #define vec_mstrgb32(T,x0,x1,x2,x3,ptr) \
- do { \
- T _0,_1,_2,_3; \
- _0 = vec_mergeh (x0,x1); \
- _1 = vec_mergeh (x2,x3); \
- _2 = (T)vec_mergeh ((vector unsigned short)_0,(vector unsigned short)_1); \
- _3 = (T)vec_mergel ((vector unsigned short)_0,(vector unsigned short)_1); \
- vec_st (_2, 0*16, (T *)ptr); \
- vec_st (_3, 1*16, (T *)ptr); \
- _0 = vec_mergel (x0,x1); \
- _1 = vec_mergel (x2,x3); \
- _2 = (T)vec_mergeh ((vector unsigned short)_0,(vector unsigned short)_1); \
- _3 = (T)vec_mergel ((vector unsigned short)_0,(vector unsigned short)_1); \
- vec_st (_2, 2*16, (T *)ptr); \
- vec_st (_3, 3*16, (T *)ptr); \
- ptr += 4; \
- } while (0)
+ * msb R
+ * lsb 0
+ */
+ #define vec_mstrgb32(T, x0, x1, x2, x3, ptr) \
+ do { \
+ T _0, _1, _2, _3; \
+ _0 = vec_mergeh(x0, x1); \
+ _1 = vec_mergeh(x2, x3); \
+ _2 = (T) vec_mergeh((vector unsigned short) _0, \
+ (vector unsigned short) _1); \
+ _3 = (T) vec_mergel((vector unsigned short) _0, \
+ (vector unsigned short) _1); \
+ vec_st(_2, 0 * 16, (T *) ptr); \
+ vec_st(_3, 1 * 16, (T *) ptr); \
+ _0 = vec_mergel(x0, x1); \
+ _1 = vec_mergel(x2, x3); \
+ _2 = (T) vec_mergeh((vector unsigned short) _0, \
+ (vector unsigned short) _1); \
+ _3 = (T) vec_mergel((vector unsigned short) _0, \
+ (vector unsigned short) _1); \
+ vec_st(_2, 2 * 16, (T *) ptr); \
+ vec_st(_3, 3 * 16, (T *) ptr); \
+ ptr += 4; \
+ } while (0)
/*
+ * 1 0 1.4021 | | Y |
+ * 1 -0.3441 -0.7142 |x| Cb|
+ * 1 1.7718 0 | | Cr|
+ *
+ *
+ * Y: [-128 127]
+ * Cb/Cr : [-128 127]
+ *
+ * typical YUV conversion works on Y: 0-255 this version has been
+ * optimized for JPEG decoding.
+ */
- | 1 0 1.4021 | | Y |
- | 1 -0.3441 -0.7142 |x| Cb|
- | 1 1.7718 0 | | Cr|
-
-
- Y: [-128 127]
- Cb/Cr : [-128 127]
-
- typical yuv conversion work on Y: 0-255 this version has been optimized for jpeg decode.
-
- */
-
-
-
-
- #define vec_unh(x) \
- (vector signed short) \
- vec_perm(x,(__typeof__(x)){0}, \
- ((vector unsigned char){0x10,0x00,0x10,0x01,0x10,0x02,0x10,0x03,\
- 0x10,0x04,0x10,0x05,0x10,0x06,0x10,0x07}))
- #define vec_unl(x) \
- (vector signed short) \
- vec_perm(x,(__typeof__(x)){0}, \
- ((vector unsigned char){0x10,0x08,0x10,0x09,0x10,0x0A,0x10,0x0B,\
- 0x10,0x0C,0x10,0x0D,0x10,0x0E,0x10,0x0F}))
-
- #define vec_clip_s16(x) \
- vec_max (vec_min (x, ((vector signed short){235,235,235,235,235,235,235,235})), \
- ((vector signed short){ 16, 16, 16, 16, 16, 16, 16, 16}))
-
- #define vec_packclp(x,y) \
- (vector unsigned char)vec_packs \
- ((vector unsigned short)vec_max (x,((vector signed short) {0})), \
- (vector unsigned short)vec_max (y,((vector signed short) {0})))
-
- //#define out_pixels(a,b,c,ptr) vec_mstrgb32(__typeof__(a),((__typeof__ (a)){255}),a,a,a,ptr)
-
-
- static inline void cvtyuvtoRGB (SwsContext *c,
- vector signed short Y, vector signed short U, vector signed short V,
- vector signed short *R, vector signed short *G, vector signed short *B)
+ #define vec_unh(x) \
+ (vector signed short) \
+ vec_perm(x, (__typeof__(x)) { 0 }, \
+ ((vector unsigned char) { \
+ 0x10, 0x00, 0x10, 0x01, 0x10, 0x02, 0x10, 0x03, \
+ 0x10, 0x04, 0x10, 0x05, 0x10, 0x06, 0x10, 0x07 }))
+
+ #define vec_unl(x) \
+ (vector signed short) \
+ vec_perm(x, (__typeof__(x)) { 0 }, \
+ ((vector unsigned char) { \
+ 0x10, 0x08, 0x10, 0x09, 0x10, 0x0A, 0x10, 0x0B, \
+ 0x10, 0x0C, 0x10, 0x0D, 0x10, 0x0E, 0x10, 0x0F }))
+
+ #define vec_clip_s16(x) \
+ vec_max(vec_min(x, ((vector signed short) { \
+ 235, 235, 235, 235, 235, 235, 235, 235 })), \
+ ((vector signed short) { 16, 16, 16, 16, 16, 16, 16, 16 }))
+
+ #define vec_packclp(x, y) \
+ (vector unsigned char) \
+ vec_packs((vector unsigned short) \
+ vec_max(x, ((vector signed short) { 0 })), \
+ (vector unsigned short) \
+ vec_max(y, ((vector signed short) { 0 })))
+
+ //#define out_pixels(a, b, c, ptr) vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), a, a, a, ptr)
+
+ static inline void cvtyuvtoRGB(SwsContext *c, vector signed short Y,
+ vector signed short U, vector signed short V,
+ vector signed short *R, vector signed short *G,
+ vector signed short *B)
{
- vector signed short vx,ux,uvx;
+ vector signed short vx, ux, uvx;
- Y = vec_mradds (Y, c->CY, c->OY);
- U = vec_sub (U,(vector signed short)
- vec_splat((vector signed short){128},0));
- V = vec_sub (V,(vector signed short)
- vec_splat((vector signed short){128},0));
+ Y = vec_mradds(Y, c->CY, c->OY);
+ U = vec_sub(U, (vector signed short)
+ vec_splat((vector signed short) { 128 }, 0));
+ V = vec_sub(V, (vector signed short)
+ vec_splat((vector signed short) { 128 }, 0));
- // ux = (CBU*(u<<c->CSHIFT)+0x4000)>>15;
- ux = vec_sl (U, c->CSHIFT);
- *B = vec_mradds (ux, c->CBU, Y);
+ // ux = (CBU * (u << c->CSHIFT) + 0x4000) >> 15;
+ ux = vec_sl(U, c->CSHIFT);
+ *B = vec_mradds(ux, c->CBU, Y);
- // vx = (CRV*(v<<c->CSHIFT)+0x4000)>>15;
- vx = vec_sl (V, c->CSHIFT);
- *R = vec_mradds (vx, c->CRV, Y);
+ // vx = (CRV * (v << c->CSHIFT) + 0x4000) >> 15;
+ vx = vec_sl(V, c->CSHIFT);
+ *R = vec_mradds(vx, c->CRV, Y);
- // uvx = ((CGU*u) + (CGV*v))>>15;
- uvx = vec_mradds (U, c->CGU, Y);
- *G = vec_mradds (V, c->CGV, uvx);
+ // uvx = ((CGU * u) + (CGV * v)) >> 15;
+ uvx = vec_mradds(U, c->CGU, Y);
+ *G = vec_mradds(V, c->CGV, uvx);
}
-
/*
- ------------------------------------------------------------------------------
- CS converters
- ------------------------------------------------------------------------------
- */
-
+ * ------------------------------------------------------------------------------
+ * CS converters
+ * ------------------------------------------------------------------------------
+ */
- #define DEFCSP420_CVT(name,out_pixels) \
- static int altivec_##name (SwsContext *c, \
- const unsigned char **in, int *instrides, \
- int srcSliceY, int srcSliceH, \
- unsigned char **oplanes, int *outstrides) \
- { \
- int w = c->srcW; \
- int h = srcSliceH; \
- int i,j; \
- int instrides_scl[3]; \
- vector unsigned char y0,y1; \
- \
- vector signed char u,v; \
- \
- vector signed short Y0,Y1,Y2,Y3; \
- vector signed short U,V; \
- vector signed short vx,ux,uvx; \
- vector signed short vx0,ux0,uvx0; \
- vector signed short vx1,ux1,uvx1; \
- vector signed short R0,G0,B0; \
- vector signed short R1,G1,B1; \
- vector unsigned char R,G,B; \
- \
- const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP; \
- vector unsigned char align_perm; \
- \
- vector signed short \
- lCY = c->CY, \
- lOY = c->OY, \
- lCRV = c->CRV, \
- lCBU = c->CBU, \
- lCGU = c->CGU, \
- lCGV = c->CGV; \
- \
- vector unsigned short lCSHIFT = c->CSHIFT; \
- \
- const ubyte *y1i = in[0]; \
- const ubyte *y2i = in[0]+instrides[0]; \
- const ubyte *ui = in[1]; \
- const ubyte *vi = in[2]; \
- \
- vector unsigned char *oute \
- = (vector unsigned char *) \
- (oplanes[0]+srcSliceY*outstrides[0]); \
- vector unsigned char *outo \
- = (vector unsigned char *) \
- (oplanes[0]+srcSliceY*outstrides[0]+outstrides[0]); \
- \
- \
- instrides_scl[0] = instrides[0]*2-w; /* the loop moves y{1,2}i by w */ \
- instrides_scl[1] = instrides[1]-w/2; /* the loop moves ui by w/2 */ \
- instrides_scl[2] = instrides[2]-w/2; /* the loop moves vi by w/2 */ \
- \
- \
- for (i=0;i<h/2;i++) { \
- vec_dstst (outo, (0x02000002|(((w*3+32)/32)<<16)), 0); \
- vec_dstst (oute, (0x02000002|(((w*3+32)/32)<<16)), 1); \
- \
- for (j=0;j<w/16;j++) { \
- \
- y1ivP = (const vector unsigned char *)y1i; \
- y2ivP = (const vector unsigned char *)y2i; \
- uivP = (const vector unsigned char *)ui; \
- vivP = (const vector unsigned char *)vi; \
- \
- align_perm = vec_lvsl (0, y1i); \
- y0 = (vector unsigned char) \
- vec_perm (y1ivP[0], y1ivP[1], align_perm); \
- \
- align_perm = vec_lvsl (0, y2i); \
- y1 = (vector unsigned char) \
- vec_perm (y2ivP[0], y2ivP[1], align_perm); \
- \
- align_perm = vec_lvsl (0, ui); \
- u = (vector signed char) \
- vec_perm (uivP[0], uivP[1], align_perm); \
- \
- align_perm = vec_lvsl (0, vi); \
- v = (vector signed char) \
- vec_perm (vivP[0], vivP[1], align_perm); \
- \
- u = (vector signed char) \
- vec_sub (u,(vector signed char) \
- vec_splat((vector signed char){128},0)); \
- v = (vector signed char) \
- vec_sub (v,(vector signed char) \
- vec_splat((vector signed char){128},0)); \
- \
- U = vec_unpackh (u); \
- V = vec_unpackh (v); \
- \
- \
- Y0 = vec_unh (y0); \
- Y1 = vec_unl (y0); \
- Y2 = vec_unh (y1); \
- Y3 = vec_unl (y1); \
- \
- Y0 = vec_mradds (Y0, lCY, lOY); \
- Y1 = vec_mradds (Y1, lCY, lOY); \
- Y2 = vec_mradds (Y2, lCY, lOY); \
- Y3 = vec_mradds (Y3, lCY, lOY); \
- \
- /* ux = (CBU*(u<<CSHIFT)+0x4000)>>15 */ \
- ux = vec_sl (U, lCSHIFT); \
- ux = vec_mradds (ux, lCBU, (vector signed short){0}); \
- ux0 = vec_mergeh (ux,ux); \
- ux1 = vec_mergel (ux,ux); \
- \
- /* vx = (CRV*(v<<CSHIFT)+0x4000)>>15; */ \
- vx = vec_sl (V, lCSHIFT); \
- vx = vec_mradds (vx, lCRV, (vector signed short){0}); \
- vx0 = vec_mergeh (vx,vx); \
- vx1 = vec_mergel (vx,vx); \
- \
- /* uvx = ((CGU*u) + (CGV*v))>>15 */ \
- uvx = vec_mradds (U, lCGU, (vector signed short){0}); \
- uvx = vec_mradds (V, lCGV, uvx); \
- uvx0 = vec_mergeh (uvx,uvx); \
- uvx1 = vec_mergel (uvx,uvx); \
- \
- R0 = vec_add (Y0,vx0); \
- G0 = vec_add (Y0,uvx0); \
- B0 = vec_add (Y0,ux0); \
- R1 = vec_add (Y1,vx1); \
- G1 = vec_add (Y1,uvx1); \
- B1 = vec_add (Y1,ux1); \
- \
- R = vec_packclp (R0,R1); \
- G = vec_packclp (G0,G1); \
- B = vec_packclp (B0,B1); \
- \
- out_pixels(R,G,B,oute); \
- \
- R0 = vec_add (Y2,vx0); \
- G0 = vec_add (Y2,uvx0); \
- B0 = vec_add (Y2,ux0); \
- R1 = vec_add (Y3,vx1); \
- G1 = vec_add (Y3,uvx1); \
- B1 = vec_add (Y3,ux1); \
- R = vec_packclp (R0,R1); \
- G = vec_packclp (G0,G1); \
- B = vec_packclp (B0,B1); \
- \
- \
- out_pixels(R,G,B,outo); \
- \
- y1i += 16; \
- y2i += 16; \
- ui += 8; \
- vi += 8; \
- \
- } \
- \
- outo += (outstrides[0])>>4; \
- oute += (outstrides[0])>>4; \
- \
- ui += instrides_scl[1]; \
- vi += instrides_scl[2]; \
- y1i += instrides_scl[0]; \
- y2i += instrides_scl[0]; \
- } \
- return srcSliceH; \
+ #define DEFCSP420_CVT(name, out_pixels) \
+ static int altivec_ ## name(SwsContext *c, const unsigned char **in, \
+ int *instrides, int srcSliceY, int srcSliceH, \
+ unsigned char **oplanes, int *outstrides) \
+ { \
+ int w = c->srcW; \
+ int h = srcSliceH; \
+ int i, j; \
+ int instrides_scl[3]; \
+ vector unsigned char y0, y1; \
+ \
+ vector signed char u, v; \
+ \
+ vector signed short Y0, Y1, Y2, Y3; \
+ vector signed short U, V; \
+ vector signed short vx, ux, uvx; \
+ vector signed short vx0, ux0, uvx0; \
+ vector signed short vx1, ux1, uvx1; \
+ vector signed short R0, G0, B0; \
+ vector signed short R1, G1, B1; \
+ vector unsigned char R, G, B; \
+ \
- vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP; \
++ const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP; \
+ vector unsigned char align_perm; \
+ \
+ vector signed short lCY = c->CY; \
+ vector signed short lOY = c->OY; \
+ vector signed short lCRV = c->CRV; \
+ vector signed short lCBU = c->CBU; \
+ vector signed short lCGU = c->CGU; \
+ vector signed short lCGV = c->CGV; \
+ vector unsigned short lCSHIFT = c->CSHIFT; \
+ \
+ const ubyte *y1i = in[0]; \
+ const ubyte *y2i = in[0] + instrides[0]; \
+ const ubyte *ui = in[1]; \
+ const ubyte *vi = in[2]; \
+ \
+ vector unsigned char *oute = \
+ (vector unsigned char *) \
+ (oplanes[0] + srcSliceY * outstrides[0]); \
+ vector unsigned char *outo = \
+ (vector unsigned char *) \
+ (oplanes[0] + srcSliceY * outstrides[0] + outstrides[0]); \
+ \
+ /* loop moves y{1, 2}i by w */ \
+ instrides_scl[0] = instrides[0] * 2 - w; \
+ /* loop moves ui by w / 2 */ \
+ instrides_scl[1] = instrides[1] - w / 2; \
+ /* loop moves vi by w / 2 */ \
+ instrides_scl[2] = instrides[2] - w / 2; \
+ \
+ for (i = 0; i < h / 2; i++) { \
+ vec_dstst(outo, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 0); \
+ vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1); \
+ \
+ for (j = 0; j < w / 16; j++) { \
- y1ivP = (vector unsigned char *) y1i; \
- y2ivP = (vector unsigned char *) y2i; \
- uivP = (vector unsigned char *) ui; \
- vivP = (vector unsigned char *) vi; \
++ y1ivP = (const vector unsigned char *) y1i; \
++ y2ivP = (const vector unsigned char *) y2i; \
++ uivP = (const vector unsigned char *) ui; \
++ vivP = (const vector unsigned char *) vi; \
+ \
+ align_perm = vec_lvsl(0, y1i); \
+ y0 = (vector unsigned char) \
+ vec_perm(y1ivP[0], y1ivP[1], align_perm); \
+ \
+ align_perm = vec_lvsl(0, y2i); \
+ y1 = (vector unsigned char) \
+ vec_perm(y2ivP[0], y2ivP[1], align_perm); \
+ \
+ align_perm = vec_lvsl(0, ui); \
+ u = (vector signed char) \
+ vec_perm(uivP[0], uivP[1], align_perm); \
+ \
+ align_perm = vec_lvsl(0, vi); \
+ v = (vector signed char) \
+ vec_perm(vivP[0], vivP[1], align_perm); \
+ \
+ u = (vector signed char) \
+ vec_sub(u, \
+ (vector signed char) \
+ vec_splat((vector signed char) { 128 }, 0)); \
+ v = (vector signed char) \
+ vec_sub(v, \
+ (vector signed char) \
+ vec_splat((vector signed char) { 128 }, 0)); \
+ \
+ U = vec_unpackh(u); \
+ V = vec_unpackh(v); \
+ \
+ Y0 = vec_unh(y0); \
+ Y1 = vec_unl(y0); \
+ Y2 = vec_unh(y1); \
+ Y3 = vec_unl(y1); \
+ \
+ Y0 = vec_mradds(Y0, lCY, lOY); \
+ Y1 = vec_mradds(Y1, lCY, lOY); \
+ Y2 = vec_mradds(Y2, lCY, lOY); \
+ Y3 = vec_mradds(Y3, lCY, lOY); \
+ \
+ /* ux = (CBU * (u << CSHIFT) + 0x4000) >> 15 */ \
+ ux = vec_sl(U, lCSHIFT); \
+ ux = vec_mradds(ux, lCBU, (vector signed short) { 0 }); \
+ ux0 = vec_mergeh(ux, ux); \
+ ux1 = vec_mergel(ux, ux); \
+ \
+ /* vx = (CRV * (v << CSHIFT) + 0x4000) >> 15; */ \
+ vx = vec_sl(V, lCSHIFT); \
+ vx = vec_mradds(vx, lCRV, (vector signed short) { 0 }); \
+ vx0 = vec_mergeh(vx, vx); \
+ vx1 = vec_mergel(vx, vx); \
+ \
+ /* uvx = ((CGU * u) + (CGV * v)) >> 15 */ \
+ uvx = vec_mradds(U, lCGU, (vector signed short) { 0 }); \
+ uvx = vec_mradds(V, lCGV, uvx); \
+ uvx0 = vec_mergeh(uvx, uvx); \
+ uvx1 = vec_mergel(uvx, uvx); \
+ \
+ R0 = vec_add(Y0, vx0); \
+ G0 = vec_add(Y0, uvx0); \
+ B0 = vec_add(Y0, ux0); \
+ R1 = vec_add(Y1, vx1); \
+ G1 = vec_add(Y1, uvx1); \
+ B1 = vec_add(Y1, ux1); \
+ \
+ R = vec_packclp(R0, R1); \
+ G = vec_packclp(G0, G1); \
+ B = vec_packclp(B0, B1); \
+ \
+ out_pixels(R, G, B, oute); \
+ \
+ R0 = vec_add(Y2, vx0); \
+ G0 = vec_add(Y2, uvx0); \
+ B0 = vec_add(Y2, ux0); \
+ R1 = vec_add(Y3, vx1); \
+ G1 = vec_add(Y3, uvx1); \
+ B1 = vec_add(Y3, ux1); \
+ R = vec_packclp(R0, R1); \
+ G = vec_packclp(G0, G1); \
+ B = vec_packclp(B0, B1); \
+ \
+ \
+ out_pixels(R, G, B, outo); \
+ \
+ y1i += 16; \
+ y2i += 16; \
+ ui += 8; \
+ vi += 8; \
+ } \
+ \
+ outo += (outstrides[0]) >> 4; \
+ oute += (outstrides[0]) >> 4; \
+ \
+ ui += instrides_scl[1]; \
+ vi += instrides_scl[2]; \
+ y1i += instrides_scl[0]; \
+ y2i += instrides_scl[0]; \
+ } \
+ return srcSliceH; \
}
-
- #define out_abgr(a,b,c,ptr) vec_mstrgb32(__typeof__(a),((__typeof__ (a)){255}),c,b,a,ptr)
- #define out_bgra(a,b,c,ptr) vec_mstrgb32(__typeof__(a),c,b,a,((__typeof__ (a)){255}),ptr)
- #define out_rgba(a,b,c,ptr) vec_mstrgb32(__typeof__(a),a,b,c,((__typeof__ (a)){255}),ptr)
- #define out_argb(a,b,c,ptr) vec_mstrgb32(__typeof__(a),((__typeof__ (a)){255}),a,b,c,ptr)
- #define out_rgb24(a,b,c,ptr) vec_mstrgb24(a,b,c,ptr)
- #define out_bgr24(a,b,c,ptr) vec_mstbgr24(a,b,c,ptr)
-
- DEFCSP420_CVT (yuv2_abgr, out_abgr)
- DEFCSP420_CVT (yuv2_bgra, out_bgra)
- DEFCSP420_CVT (yuv2_rgba, out_rgba)
- DEFCSP420_CVT (yuv2_argb, out_argb)
- DEFCSP420_CVT (yuv2_rgb24, out_rgb24)
- DEFCSP420_CVT (yuv2_bgr24, out_bgr24)
-
+ #define out_abgr(a, b, c, ptr) \
+ vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), c, b, a, ptr)
+ #define out_bgra(a, b, c, ptr) \
+ vec_mstrgb32(__typeof__(a), c, b, a, ((__typeof__(a)) { 255 }), ptr)
+ #define out_rgba(a, b, c, ptr) \
+ vec_mstrgb32(__typeof__(a), a, b, c, ((__typeof__(a)) { 255 }), ptr)
+ #define out_argb(a, b, c, ptr) \
+ vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), a, b, c, ptr)
+ #define out_rgb24(a, b, c, ptr) vec_mstrgb24(a, b, c, ptr)
+ #define out_bgr24(a, b, c, ptr) vec_mstbgr24(a, b, c, ptr)
+
+ DEFCSP420_CVT(yuv2_abgr, out_abgr)
+ DEFCSP420_CVT(yuv2_bgra, out_bgra)
+ DEFCSP420_CVT(yuv2_rgba, out_rgba)
+ DEFCSP420_CVT(yuv2_argb, out_argb)
+ DEFCSP420_CVT(yuv2_rgb24, out_rgb24)
+ DEFCSP420_CVT(yuv2_bgr24, out_bgr24)
// uyvy|uyvy|uyvy|uyvy
// 0123 4567 89ab cdef
}
/* scale and clip signals */
- Y0 = vec_sra (Y0, SCL);
- Y1 = vec_sra (Y1, SCL);
- U = vec_sra (U, SCL);
- V = vec_sra (V, SCL);
+ Y0 = vec_sra(Y0, SCL);
+ Y1 = vec_sra(Y1, SCL);
+ U = vec_sra(U, SCL);
+ V = vec_sra(V, SCL);
- Y0 = vec_clip_s16 (Y0);
- Y1 = vec_clip_s16 (Y1);
- U = vec_clip_s16 (U);
- V = vec_clip_s16 (V);
+ Y0 = vec_clip_s16(Y0);
+ Y1 = vec_clip_s16(Y1);
+ U = vec_clip_s16(U);
+ V = vec_clip_s16(V);
/* now we have
- Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
- U= u0 u1 u2 u3 u4 u5 u6 u7 V= v0 v1 v2 v3 v4 v5 v6 v7
-
- Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
- U0= u0 u0 u1 u1 u2 u2 u3 u3 U1= u4 u4 u5 u5 u6 u6 u7 u7
- V0= v0 v0 v1 v1 v2 v2 v3 v3 V1= v4 v4 v5 v5 v6 v6 v7 v7
- */
-
- U0 = vec_mergeh (U,U);
- V0 = vec_mergeh (V,V);
-
- U1 = vec_mergel (U,U);
- V1 = vec_mergel (V,V);
-
- cvtyuvtoRGB (c, Y0,U0,V0,&R0,&G0,&B0);
- cvtyuvtoRGB (c, Y1,U1,V1,&R1,&G1,&B1);
-
- R = vec_packclp (R0,R1);
- G = vec_packclp (G0,G1);
- B = vec_packclp (B0,B1);
-
- switch(target) {
- case PIX_FMT_ABGR: out_abgr (R,G,B,out); break;
- case PIX_FMT_BGRA: out_bgra (R,G,B,out); break;
- case PIX_FMT_RGBA: out_rgba (R,G,B,out); break;
- case PIX_FMT_ARGB: out_argb (R,G,B,out); break;
- case PIX_FMT_RGB24: out_rgb24 (R,G,B,out); break;
- case PIX_FMT_BGR24: out_bgr24 (R,G,B,out); break;
+ * Y0 = y0 y1 y2 y3 y4 y5 y6 y7 Y1 = y8 y9 y10 y11 y12 y13 y14 y15
+ * U = u0 u1 u2 u3 u4 u5 u6 u7 V = v0 v1 v2 v3 v4 v5 v6 v7
+ *
+ * Y0 = y0 y1 y2 y3 y4 y5 y6 y7 Y1 = y8 y9 y10 y11 y12 y13 y14 y15
+ * U0 = u0 u0 u1 u1 u2 u2 u3 u3 U1 = u4 u4 u5 u5 u6 u6 u7 u7
+ * V0 = v0 v0 v1 v1 v2 v2 v3 v3 V1 = v4 v4 v5 v5 v6 v6 v7 v7
+ */
+
+ U0 = vec_mergeh(U, U);
+ V0 = vec_mergeh(V, V);
+
+ U1 = vec_mergel(U, U);
+ V1 = vec_mergel(V, V);
+
+ cvtyuvtoRGB(c, Y0, U0, V0, &R0, &G0, &B0);
+ cvtyuvtoRGB(c, Y1, U1, V1, &R1, &G1, &B1);
+
+ R = vec_packclp(R0, R1);
+ G = vec_packclp(G0, G1);
+ B = vec_packclp(B0, B1);
+
+ switch (target) {
+ case PIX_FMT_ABGR:
+ out_abgr(R, G, B, out);
+ break;
+ case PIX_FMT_BGRA:
+ out_bgra(R, G, B, out);
+ break;
+ case PIX_FMT_RGBA:
+ out_rgba(R, G, B, out);
+ break;
+ case PIX_FMT_ARGB:
+ out_argb(R, G, B, out);
+ break;
+ case PIX_FMT_RGB24:
+ out_rgb24(R, G, B, out);
+ break;
+ case PIX_FMT_BGR24:
+ out_bgr24(R, G, B, out);
+ break;
default:
- {
- /* If this is reached, the caller should have called yuv2packedXinC
- instead. */
- static int printed_error_message;
- if (!printed_error_message) {
- av_log(c, AV_LOG_ERROR, "altivec_yuv2packedX doesn't support %s output\n",
- av_get_pix_fmt_name(c->dstFormat));
- printed_error_message=1;
- }
- return;
+ {
+ /* If this is reached, the caller should have called yuv2packedXinC
+ * instead. */
+ static int printed_error_message;
+ if (!printed_error_message) {
+ av_log(c, AV_LOG_ERROR,
+ "altivec_yuv2packedX doesn't support %s output\n",
- sws_format_name(c->dstFormat));
++ av_get_pix_fmt_name(c->dstFormat));
+ printed_error_message = 1;
}
+ return;
+ }
}
}
}
/* scale and clip signals */
- Y0 = vec_sra (Y0, SCL);
- Y1 = vec_sra (Y1, SCL);
- U = vec_sra (U, SCL);
- V = vec_sra (V, SCL);
+ Y0 = vec_sra(Y0, SCL);
+ Y1 = vec_sra(Y1, SCL);
+ U = vec_sra(U, SCL);
+ V = vec_sra(V, SCL);
- Y0 = vec_clip_s16 (Y0);
- Y1 = vec_clip_s16 (Y1);
- U = vec_clip_s16 (U);
- V = vec_clip_s16 (V);
+ Y0 = vec_clip_s16(Y0);
+ Y1 = vec_clip_s16(Y1);
+ U = vec_clip_s16(U);
+ V = vec_clip_s16(V);
/* now we have
- Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
- U = u0 u1 u2 u3 u4 u5 u6 u7 V = v0 v1 v2 v3 v4 v5 v6 v7
-
- Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
- U0= u0 u0 u1 u1 u2 u2 u3 u3 U1= u4 u4 u5 u5 u6 u6 u7 u7
- V0= v0 v0 v1 v1 v2 v2 v3 v3 V1= v4 v4 v5 v5 v6 v6 v7 v7
- */
-
- U0 = vec_mergeh (U,U);
- V0 = vec_mergeh (V,V);
-
- U1 = vec_mergel (U,U);
- V1 = vec_mergel (V,V);
-
- cvtyuvtoRGB (c, Y0,U0,V0,&R0,&G0,&B0);
- cvtyuvtoRGB (c, Y1,U1,V1,&R1,&G1,&B1);
-
- R = vec_packclp (R0,R1);
- G = vec_packclp (G0,G1);
- B = vec_packclp (B0,B1);
-
- nout = (vector unsigned char *)scratch;
- switch(target) {
- case PIX_FMT_ABGR: out_abgr (R,G,B,nout); break;
- case PIX_FMT_BGRA: out_bgra (R,G,B,nout); break;
- case PIX_FMT_RGBA: out_rgba (R,G,B,nout); break;
- case PIX_FMT_ARGB: out_argb (R,G,B,nout); break;
- case PIX_FMT_RGB24: out_rgb24 (R,G,B,nout); break;
- case PIX_FMT_BGR24: out_bgr24 (R,G,B,nout); break;
+ * Y0 = y0 y1 y2 y3 y4 y5 y6 y7 Y1 = y8 y9 y10 y11 y12 y13 y14 y15
+ * U = u0 u1 u2 u3 u4 u5 u6 u7 V = v0 v1 v2 v3 v4 v5 v6 v7
+ *
+ * Y0 = y0 y1 y2 y3 y4 y5 y6 y7 Y1 = y8 y9 y10 y11 y12 y13 y14 y15
+ * U0 = u0 u0 u1 u1 u2 u2 u3 u3 U1 = u4 u4 u5 u5 u6 u6 u7 u7
+ * V0 = v0 v0 v1 v1 v2 v2 v3 v3 V1 = v4 v4 v5 v5 v6 v6 v7 v7
+ */
+
+ U0 = vec_mergeh(U, U);
+ V0 = vec_mergeh(V, V);
+
+ U1 = vec_mergel(U, U);
+ V1 = vec_mergel(V, V);
+
+ cvtyuvtoRGB(c, Y0, U0, V0, &R0, &G0, &B0);
+ cvtyuvtoRGB(c, Y1, U1, V1, &R1, &G1, &B1);
+
+ R = vec_packclp(R0, R1);
+ G = vec_packclp(G0, G1);
+ B = vec_packclp(B0, B1);
+
+ nout = (vector unsigned char *) scratch;
+ switch (target) {
+ case PIX_FMT_ABGR:
+ out_abgr(R, G, B, nout);
+ break;
+ case PIX_FMT_BGRA:
+ out_bgra(R, G, B, nout);
+ break;
+ case PIX_FMT_RGBA:
+ out_rgba(R, G, B, nout);
+ break;
+ case PIX_FMT_ARGB:
+ out_argb(R, G, B, nout);
+ break;
+ case PIX_FMT_RGB24:
+ out_rgb24(R, G, B, nout);
+ break;
+ case PIX_FMT_BGR24:
+ out_bgr24(R, G, B, nout);
+ break;
default:
/* Unreachable, I think. */
- av_log(c, AV_LOG_ERROR, "altivec_yuv2packedX doesn't support %s output\n",
+ av_log(c, AV_LOG_ERROR,
+ "altivec_yuv2packedX doesn't support %s output\n",
- sws_format_name(c->dstFormat));
+ av_get_pix_fmt_name(c->dstFormat));
return;
}
- b813a52d4efe6cf7974190ea9c4c7e8c *./tests/data/acodec/g722.wav
-7b0492eee76b04b710990235f97a0bf2 *./tests/data/acodec/g722.wav
- 48053 ./tests/data/acodec/g722.wav
-b5568e0e3930ff563824156e8e1015f0 *./tests/data/g722.acodec.out.wav
-stddev: 8939.44 PSNR: 17.30 MAXDIFF:40370 bytes: 191980/ 1058400
++d1a10c4d35f752f60798114a156be3a8 *./tests/data/acodec/g722.wav
+48053 ./tests/data/acodec/g722.wav
- d8344d14a11eef0418b856af70694cbe *./tests/data/g722.acodec.out.wav
- stddev: 8841.18 PSNR: 17.40 MAXDIFF:36225 bytes: 191980/ 1058400
++8dafe5b74ccd5f08fed2fb2a69c5475f *./tests/data/g722.acodec.out.wav
++stddev: 8939.47 PSNR: 17.30 MAXDIFF:40370 bytes: 191980/ 1058400