mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
utvideoenc: align mangled buffer starts.
This is essential for fast SIMD accesses. The same should be done with the predict output. Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
d79c87a697
commit
729b2d02af
@ -75,6 +75,7 @@ typedef struct UtvideoContext {
|
|||||||
int interlaced;
|
int interlaced;
|
||||||
int frame_pred;
|
int frame_pred;
|
||||||
|
|
||||||
|
int slice_stride;
|
||||||
uint8_t *slice_bits, *slice_buffer[4];
|
uint8_t *slice_bits, *slice_buffer[4];
|
||||||
int slice_bits_size;
|
int slice_bits_size;
|
||||||
} UtvideoContext;
|
} UtvideoContext;
|
||||||
|
@ -145,7 +145,8 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < c->planes; i++) {
|
for (i = 0; i < c->planes; i++) {
|
||||||
c->slice_buffer[i] = av_malloc(avctx->width * (avctx->height + 1) +
|
c->slice_stride = FFALIGN(avctx->width, 32);
|
||||||
|
c->slice_buffer[i] = av_malloc(c->slice_stride * (avctx->height + 2) +
|
||||||
FF_INPUT_BUFFER_PADDING_SIZE);
|
FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
if (!c->slice_buffer[i]) {
|
if (!c->slice_buffer[i]) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 1.\n");
|
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 1.\n");
|
||||||
@ -196,11 +197,11 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mangle_rgb_planes(uint8_t *dst[4], uint8_t *src, int step,
|
static void mangle_rgb_planes(uint8_t *dst[4], int dst_stride, uint8_t *src,
|
||||||
int stride, int width, int height)
|
int step, int stride, int width, int height)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int k = width;
|
int k = 2 * dst_stride;
|
||||||
unsigned g;
|
unsigned g;
|
||||||
|
|
||||||
for (j = 0; j < height; j++) {
|
for (j = 0; j < height; j++) {
|
||||||
@ -224,6 +225,7 @@ static void mangle_rgb_planes(uint8_t *dst[4], uint8_t *src, int step,
|
|||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
k += dst_stride - width;
|
||||||
src += stride;
|
src += stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -547,16 +549,16 @@ static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
|
|
||||||
/* In case of RGB, mangle the planes to Ut Video's format */
|
/* In case of RGB, mangle the planes to Ut Video's format */
|
||||||
if (avctx->pix_fmt == PIX_FMT_RGBA || avctx->pix_fmt == PIX_FMT_RGB24)
|
if (avctx->pix_fmt == PIX_FMT_RGBA || avctx->pix_fmt == PIX_FMT_RGB24)
|
||||||
mangle_rgb_planes(c->slice_buffer, pic->data[0], c->planes,
|
mangle_rgb_planes(c->slice_buffer, c->slice_stride, pic->data[0],
|
||||||
pic->linesize[0], width, height);
|
c->planes, pic->linesize[0], width, height);
|
||||||
|
|
||||||
/* Deal with the planes */
|
/* Deal with the planes */
|
||||||
switch (avctx->pix_fmt) {
|
switch (avctx->pix_fmt) {
|
||||||
case PIX_FMT_RGB24:
|
case PIX_FMT_RGB24:
|
||||||
case PIX_FMT_RGBA:
|
case PIX_FMT_RGBA:
|
||||||
for (i = 0; i < c->planes; i++) {
|
for (i = 0; i < c->planes; i++) {
|
||||||
ret = encode_plane(avctx, c->slice_buffer[i] + width,
|
ret = encode_plane(avctx, c->slice_buffer[i] + 2 * c->slice_stride,
|
||||||
c->slice_buffer[i], width,
|
c->slice_buffer[i], c->slice_stride,
|
||||||
width, height, &pb);
|
width, height, &pb);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
Loading…
Reference in New Issue
Block a user