~thopiekar/arm-mali/libvdpau-sunxi

« back to all changes in this revision

Viewing changes to surface_video.c

  • Committer: Jens Kuske
  • Date: 2016-02-16 13:12:22 UTC
  • Revision ID: git-v1:685769372a8281bf67046a958883323aaf14d232
Use libcedrus

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include <string.h>
 
21
#include <cedrus/cedrus.h>
21
22
#include "vdpau_private.h"
22
 
#include "ve.h"
23
23
#include "tiled_yuv.h"
24
24
 
25
25
void yuv_unref(yuv_data_t *yuv)
28
28
 
29
29
        if (yuv->ref_count == 0)
30
30
        {
31
 
                ve_free(yuv->data);
 
31
                cedrus_mem_free(yuv->data);
32
32
                free(yuv);
33
33
        }
34
34
}
46
46
                return VDP_STATUS_RESOURCES;
47
47
 
48
48
        video_surface->yuv->ref_count = 1;
49
 
        video_surface->yuv->data = ve_malloc(video_surface->luma_size + video_surface->chroma_size);
 
49
        video_surface->yuv->data = cedrus_mem_alloc(video_surface->device->cedrus, video_surface->luma_size + video_surface->chroma_size);
50
50
 
51
51
        if (!(video_surface->yuv->data))
52
52
        {
70
70
 
71
71
VdpStatus rec_prepare(video_surface_ctx_t *video_surface)
72
72
{
73
 
        if (ve_get_version() == 0x1680)
 
73
        if (cedrus_get_ve_version(video_surface->device->cedrus) == 0x1680)
74
74
        {
75
75
                if (!video_surface->rec)
76
76
                {
77
 
                        video_surface->rec = ve_malloc(video_surface->luma_size + video_surface->chroma_size);
 
77
                        video_surface->rec = cedrus_mem_alloc(video_surface->device->cedrus, video_surface->luma_size + video_surface->chroma_size);
78
78
                        if (!video_surface->rec)
79
79
                                return VDP_STATUS_RESOURCES;
80
80
                }
147
147
                vs->decoder_private_free(vs);
148
148
 
149
149
        if (vs->rec && vs->rec != vs->yuv->data)
150
 
                ve_free(vs->rec);
 
150
                cedrus_mem_free(vs->rec);
151
151
 
152
152
        yuv_unref(vs->yuv);
153
153
 
195
195
        switch (destination_ycbcr_format)
196
196
        {
197
197
        case VDP_YCBCR_FORMAT_NV12:
198
 
                tiled_to_planar(vs->yuv->data->virt, destination_data[0], destination_pitches[0], vs->width, vs->height);
199
 
                tiled_to_planar(vs->yuv->data->virt + vs->luma_size, destination_data[1], destination_pitches[1], vs->width, vs->height / 2);
 
198
                tiled_to_planar(cedrus_mem_get_pointer(vs->yuv->data), destination_data[0], destination_pitches[0], vs->width, vs->height);
 
199
                tiled_to_planar(cedrus_mem_get_pointer(vs->yuv->data) + vs->luma_size, destination_data[1], destination_pitches[1], vs->width, vs->height / 2);
200
200
                return VDP_STATUS_OK;
201
201
 
202
202
        case VDP_YCBCR_FORMAT_YV12:
203
203
                if (destination_pitches[2] != destination_pitches[1])
204
204
                        return VDP_STATUS_ERROR;
205
 
                tiled_to_planar(vs->yuv->data->virt, destination_data[0], destination_pitches[0], vs->width, vs->height);
206
 
                tiled_deinterleave_to_planar(vs->yuv->data->virt + vs->luma_size, destination_data[2], destination_data[1], destination_pitches[1], vs->width, vs->height / 2);
 
205
                tiled_to_planar(cedrus_mem_get_pointer(vs->yuv->data), destination_data[0], destination_pitches[0], vs->width, vs->height);
 
206
                tiled_deinterleave_to_planar(cedrus_mem_get_pointer(vs->yuv->data) + vs->luma_size, destination_data[2], destination_data[1], destination_pitches[1], vs->width, vs->height / 2);
207
207
                return VDP_STATUS_OK;
208
208
        }
209
209
 
235
235
                if (vs->chroma_type != VDP_CHROMA_TYPE_422)
236
236
                        return VDP_STATUS_INVALID_CHROMA_TYPE;
237
237
                src = source_data[0];
238
 
                dst = vs->yuv->data->virt;
 
238
                dst = cedrus_mem_get_pointer(vs->yuv->data);
239
239
                for (i = 0; i < vs->height; i++) {
240
240
                        memcpy(dst, src, 2*vs->width);
241
241
                        src += source_pitches[0];
251
251
                if (vs->chroma_type != VDP_CHROMA_TYPE_420)
252
252
                        return VDP_STATUS_INVALID_CHROMA_TYPE;
253
253
                src = source_data[0];
254
 
                dst = vs->yuv->data->virt;
 
254
                dst = cedrus_mem_get_pointer(vs->yuv->data);
255
255
                for (i = 0; i < vs->height; i++) {
256
256
                        memcpy(dst, src, vs->width);
257
257
                        src += source_pitches[0];
258
258
                        dst += vs->width;
259
259
                }
260
260
                src = source_data[1];
261
 
                dst = vs->yuv->data->virt + vs->luma_size;
 
261
                dst = cedrus_mem_get_pointer(vs->yuv->data) + vs->luma_size;
262
262
                for (i = 0; i < vs->height / 2; i++) {
263
263
                        memcpy(dst, src, vs->width);
264
264
                        src += source_pitches[1];
270
270
                if (vs->chroma_type != VDP_CHROMA_TYPE_420)
271
271
                        return VDP_STATUS_INVALID_CHROMA_TYPE;
272
272
                src = source_data[0];
273
 
                dst = vs->yuv->data->virt;
 
273
                dst = cedrus_mem_get_pointer(vs->yuv->data);
274
274
                for (i = 0; i < vs->height; i++) {
275
275
                        memcpy(dst, src, vs->width);
276
276
                        src += source_pitches[0];
277
277
                        dst += vs->width;
278
278
                }
279
279
                src = source_data[2];
280
 
                dst = vs->yuv->data->virt + vs->luma_size;
 
280
                dst = cedrus_mem_get_pointer(vs->yuv->data) + vs->luma_size;
281
281
                for (i = 0; i < vs->height / 2; i++) {
282
282
                        memcpy(dst, src, vs->width / 2);
283
283
                        src += source_pitches[1];
284
284
                        dst += vs->width / 2;
285
285
                }
286
286
                src = source_data[1];
287
 
                dst = vs->yuv->data->virt + vs->luma_size + vs->chroma_size / 2;
 
287
                dst = cedrus_mem_get_pointer(vs->yuv->data) + vs->luma_size + vs->chroma_size / 2;
288
288
                for (i = 0; i < vs->height / 2; i++) {
289
289
                        memcpy(dst, src, vs->width / 2);
290
290
                        src += source_pitches[2];
293
293
                break;
294
294
        }
295
295
 
296
 
        ve_flush_cache(vs->yuv->data);
 
296
        cedrus_mem_flush_cache(vs->yuv->data);
297
297
 
298
298
        return VDP_STATUS_OK;
299
299
}