Path: blob/21.2-virgl/src/gallium/auxiliary/vl/vl_decoder.c
4565 views
/**************************************************************************1*2* Copyright 2009 Younes Manton.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#include "pipe/p_video_codec.h"2829#include "util/u_video.h"3031#include "vl_decoder.h"32#include "vl_mpeg12_decoder.h"3334bool35vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile,36enum pipe_video_entrypoint entrypoint)37{38assert(screen);39switch (u_reduce_video_profile(profile)) {40case PIPE_VIDEO_FORMAT_MPEG12:41return entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE;42default:43return false;44}45}4647int48vl_level_supported(struct pipe_screen *screen, enum pipe_video_profile profile)49{50assert(screen);51switch (profile) {52case PIPE_VIDEO_PROFILE_MPEG1:53return 0;54case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:55case PIPE_VIDEO_PROFILE_MPEG2_MAIN:56return 3;57default:58return 0;59}60}6162struct pipe_video_codec *63vl_create_decoder(struct pipe_context *pipe,64const struct pipe_video_codec *templat)65{66unsigned width = templat->width, height = templat->height;67struct pipe_video_codec temp;68bool pot_buffers;6970assert(pipe);71assert(width > 0 && height > 0);7273pot_buffers = !pipe->screen->get_video_param74(75pipe->screen,76templat->profile,77templat->entrypoint,78PIPE_VIDEO_CAP_NPOT_TEXTURES79);8081temp = *templat;82temp.width = pot_buffers ? util_next_power_of_two(width) : align(width, VL_MACROBLOCK_WIDTH);83temp.height = pot_buffers ? util_next_power_of_two(height) : align(height, VL_MACROBLOCK_HEIGHT);8485switch (u_reduce_video_profile(temp.profile)) {86case PIPE_VIDEO_FORMAT_MPEG12:87return vl_create_mpeg12_decoder(pipe, &temp);8889default:90return NULL;91}92return NULL;93}949596