lavc/libxavs2.c: avoid recomputations of pointers in xavs2_copy_frame* functions
Signed-off-by: hwren <hwrenx@126.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
3003917a8f
commit
6721cd942a
|
@ -132,28 +132,42 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
|
||||||
|
|
||||||
static void xavs2_copy_frame_with_shift(xavs2_picture_t *pic, const AVFrame *frame, const int shift_in)
|
static void xavs2_copy_frame_with_shift(xavs2_picture_t *pic, const AVFrame *frame, const int shift_in)
|
||||||
{
|
{
|
||||||
int plane, hIdx, wIdx;
|
uint16_t *p_plane;
|
||||||
|
uint8_t *p_buffer;
|
||||||
|
int plane;
|
||||||
|
int hIdx;
|
||||||
|
int wIdx;
|
||||||
|
|
||||||
for (plane = 0; plane < 3; plane++) {
|
for (plane = 0; plane < 3; plane++) {
|
||||||
int i_stride = pic->img.i_stride[plane];
|
p_plane = (uint16_t *)pic->img.img_planes[plane];
|
||||||
|
p_buffer = frame->data[plane];
|
||||||
for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
|
for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
|
||||||
uint16_t *p_plane = (uint16_t *)&pic->img.img_planes[plane][hIdx * i_stride];
|
memset(p_plane, 0, pic->img.i_stride[plane]);
|
||||||
uint8_t *p_buffer = frame->data[plane] + frame->linesize[plane] * hIdx;
|
|
||||||
memset(p_plane, 0, i_stride);
|
|
||||||
for (wIdx = 0; wIdx < pic->img.i_width[plane]; wIdx++) {
|
for (wIdx = 0; wIdx < pic->img.i_width[plane]; wIdx++) {
|
||||||
p_plane[wIdx] = p_buffer[wIdx] << shift_in;
|
p_plane[wIdx] = p_buffer[wIdx] << shift_in;
|
||||||
}
|
}
|
||||||
|
p_plane += pic->img.i_stride[plane];
|
||||||
|
p_buffer += frame->linesize[plane];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xavs2_copy_frame(xavs2_picture_t *pic, const AVFrame *frame)
|
static void xavs2_copy_frame(xavs2_picture_t *pic, const AVFrame *frame)
|
||||||
{
|
{
|
||||||
int plane, hIdx;
|
uint8_t *p_plane;
|
||||||
|
uint8_t *p_buffer;
|
||||||
|
int plane;
|
||||||
|
int hIdx;
|
||||||
|
int stride;
|
||||||
|
|
||||||
for (plane = 0; plane < 3; plane++) {
|
for (plane = 0; plane < 3; plane++) {
|
||||||
|
p_plane = pic->img.img_planes[plane];
|
||||||
|
p_buffer = frame->data[plane];
|
||||||
|
stride = pic->img.i_width[plane] * pic->img.in_sample_size;
|
||||||
for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
|
for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
|
||||||
memcpy( pic->img.img_planes[plane] + pic->img.i_stride[plane] * hIdx,
|
memcpy(p_plane, p_buffer, stride);
|
||||||
frame->data[plane]+frame->linesize[plane] * hIdx,
|
p_plane += pic->img.i_stride[plane];
|
||||||
pic->img.i_width[plane] * pic->img.in_sample_size);
|
p_buffer += frame->linesize[plane];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user