~thopiekar/arm-mali/libvdpau-sunxi

« back to all changes in this revision

Viewing changes to surface_video.c

  • Committer: Jens Kuske
  • Date: 2016-12-17 09:58:38 UTC
  • Revision ID: git-v1:1a2bb1d942bc3c9db61ceaccc2012cb68471dd5e
Fix VdpVideoSurfaceGetBitsYCbCr on H3 and newer

Newer SoCs don't use the tiled video format anymore, so we must
not convert from tiled to normal.
This only works for YV12 now, NV12 would need some conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
186
186
        if (!vs)
187
187
                return VDP_STATUS_INVALID_HANDLE;
188
188
 
189
 
        if (vs->chroma_type != VDP_CHROMA_TYPE_420 || vs->source_format != INTERNAL_YCBCR_FORMAT)
190
 
                return VDP_STATUS_INVALID_Y_CB_CR_FORMAT;
 
189
        if (vs->chroma_type != VDP_CHROMA_TYPE_420)
 
190
                return VDP_STATUS_INVALID_CHROMA_TYPE;
191
191
 
192
192
        if (destination_pitches[0] < vs->width || destination_pitches[1] < vs->width / 2)
193
193
                return VDP_STATUS_ERROR;
194
194
 
 
195
        if (vs->source_format == VDP_YCBCR_FORMAT_YV12 && destination_ycbcr_format == VDP_YCBCR_FORMAT_YV12)
 
196
        {
 
197
                int i;
 
198
                const uint8_t *src;
 
199
                uint8_t *dst;
 
200
 
 
201
                src = cedrus_mem_get_pointer(vs->yuv->data);
 
202
                dst = destination_data[0];
 
203
                for (i = 0; i < vs->height; i++)
 
204
                {
 
205
                        memcpy(dst, src, vs->width);
 
206
                        src += ALIGN(vs->width, 32);
 
207
                        dst += destination_pitches[0];
 
208
                }
 
209
                src = cedrus_mem_get_pointer(vs->yuv->data) + vs->luma_size;
 
210
                dst = destination_data[2];
 
211
                for (i = 0; i < vs->height / 2; i++)
 
212
                {
 
213
                        memcpy(dst, src, vs->width / 2);
 
214
                        src += ALIGN(vs->width / 2, 16);
 
215
                        dst += destination_pitches[2];
 
216
                }
 
217
                src = cedrus_mem_get_pointer(vs->yuv->data) + vs->luma_size + vs->chroma_size / 2;
 
218
                dst = destination_data[1];
 
219
                for (i = 0; i < vs->height / 2; i++)
 
220
                {
 
221
                        memcpy(dst, src, vs->width / 2);
 
222
                        src += ALIGN(vs->width / 2, 16);
 
223
                        dst += destination_pitches[1];
 
224
                }
 
225
                return VDP_STATUS_OK;
 
226
        }
195
227
#ifndef __aarch64__
196
 
        switch (destination_ycbcr_format)
 
228
        else if (vs->source_format == INTERNAL_YCBCR_FORMAT && destination_ycbcr_format == VDP_YCBCR_FORMAT_NV12)
197
229
        {
198
 
        case VDP_YCBCR_FORMAT_NV12:
199
230
                tiled_to_planar(cedrus_mem_get_pointer(vs->yuv->data), destination_data[0], destination_pitches[0], vs->width, vs->height);
200
231
                tiled_to_planar(cedrus_mem_get_pointer(vs->yuv->data) + vs->luma_size, destination_data[1], destination_pitches[1], vs->width, vs->height / 2);
201
232
                return VDP_STATUS_OK;
202
 
 
203
 
        case VDP_YCBCR_FORMAT_YV12:
 
233
        }
 
234
        else if (vs->source_format == INTERNAL_YCBCR_FORMAT && destination_ycbcr_format == VDP_YCBCR_FORMAT_YV12)
 
235
        {
204
236
                if (destination_pitches[2] != destination_pitches[1])
205
237
                        return VDP_STATUS_ERROR;
206
238
                tiled_to_planar(cedrus_mem_get_pointer(vs->yuv->data), destination_data[0], destination_pitches[0], vs->width, vs->height);
209
241
        }
210
242
#endif
211
243
 
212
 
        return VDP_STATUS_ERROR;
 
244
        return VDP_STATUS_INVALID_Y_CB_CR_FORMAT;
213
245
}
214
246
 
215
247
VdpStatus vdp_video_surface_put_bits_y_cb_cr(VdpVideoSurface surface,