Video decompress: use new module API

This commit is contained in:
Martin Pulec
2015-09-08 19:49:13 +02:00
parent 8e9f600a04
commit 243d78487c
20 changed files with 347 additions and 885 deletions

View File

@@ -138,7 +138,6 @@ OBJS = @OBJS@ \
src/video_compress.o \
src/video_compress/none.o \
src/video_decompress.o \
src/video_decompress/null.o \
src/video_display.o \
src/video_display/aggregate.o \
src/video_display/dummy.o \
@@ -609,7 +608,7 @@ rtsp_server: @RTSP_SERVER_LIB_TARGET@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,vcompress_libavcodec.so.@video_compress_abi_version@ $^ @LIBAVCODEC_LIBS@ -o $@
@LIBAVCODEC_DECOMPRESS_LIB_TARGET@: @LIBAVCODEC_DECOMPRESS_OBJ@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,vdecompress_libavcodec.so.@video_decompress_abi_version@ $^ @LIBAVCODEC_LIBS@ -o $@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,module_vdecompress_libavcodec.so $^ @LIBAVCODEC_LIBS@ -o $@
@LIBAVCODEC_AUDIO_CODEC_LIB_TARGET@: @LIBAVCODEC_AUDIO_CODEC_OBJ@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,module_acompress.so $^ @LIBAVCODEC_LIBS@ -o $@
@@ -621,13 +620,13 @@ rtsp_server: @RTSP_SERVER_LIB_TARGET@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,vcompress_cuda_dxt.so.@video_compress_abi_version@ $^ @CUDA_DXT_LIB@ -o $@
@RTDXT_DECOMPRESS_LIB_TARGET@: @GL_COMMON_OBJ@ @X_OBJ@ @RTDXT_COMMON_OBJ@ @RTDXT_DECOMPRESS_OBJ@ @RTDXT_COMMON_HEADERS@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,vdecompress_rtdxt.so.@video_decompress_abi_version@ @GL_COMMON_OBJ@ @X_OBJ@ @RTDXT_COMMON_OBJ@ @RTDXT_DECOMPRESS_OBJ@ @RTDXT_LIB@ -o $@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,module_vdecompress_rtdxt.so @GL_COMMON_OBJ@ @X_OBJ@ @RTDXT_COMMON_OBJ@ @RTDXT_DECOMPRESS_OBJ@ @RTDXT_LIB@ -o $@
@JPEG_DECOMPRESS_LIB_TARGET@: @JPEG_DECOMPRESS_OBJ@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,vdecompress_jpeg.so.@video_decompress_abi_version@ $^ @JPEG_LIB@ -o $@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,module_vdecompress_jpeg.so $^ @JPEG_LIB@ -o $@
@JPEG_TO_DXT_DECOMPRESS_LIB_TARGET@: @JPEG_TO_DXT_OBJ@ @JPEG_DECOMPRESS_OBJ@ @CUDA_COMMON_OBJ@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,vdecompress_jpeg_to_dxt.so.@video_decompress_abi_version@ $^ @JPEG_TO_DXT_LIB@ -o $@
$(LINKER) $(LDFLAGS) -shared -Wl,-soname,module_vdecompress_jpeg_to_dxt.so $^ @JPEG_TO_DXT_LIB@ -o $@
@ALSA_PLAY_LIB_TARGET@: @ALSA_PLAY_OBJ@

View File

@@ -441,15 +441,12 @@ then
fi
video_compress_abi_version=4
video_decompress_abi_version=3
video_rxtx_abi_version=1
vo_pp_abi_version=3
AC_DEFINE_UNQUOTED([VIDEO_COMPRESS_ABI_VERSION], $video_compress_abi_version, [Specifies ABI version for video compression])
AC_DEFINE_UNQUOTED([VIDEO_DECOMPRESS_ABI_VERSION], $video_decompress_abi_version, [Specifies ABI version for video decompression])
AC_DEFINE_UNQUOTED([VIDEO_RXTX_ABI_VERSION], $video_rxtx_abi_version, [Specifies ABI version for video transmission])
AC_DEFINE_UNQUOTED([VO_PP_ABI_VERSION], $vo_pp_abi_version, [Specifies ABI version for video postprocess])
AC_SUBST(video_compress_abi_version)
AC_SUBST(video_decompress_abi_version)
AC_SUBST(vo_pp_abi_version)
# ------------------------------------------------------------------------------------------------
@@ -1912,7 +1909,7 @@ then
RTDXT_DECOMPRESS_OBJ="dxt_compress/dxt_decoder.o src/video_decompress/dxt_glsl.o"
DXT_GLSL_CFLAGS="-std=gnu99"
AC_SUBST(RTDXT_COMPRESS_LIB_TARGET, "lib/ultragrid/vcompress_rtdxt.so.$video_compress_abi_version")
AC_SUBST(RTDXT_DECOMPRESS_LIB_TARGET, "lib/ultragrid/vdecompress_rtdxt.so.$video_decompress_abi_version")
AC_SUBST(RTDXT_DECOMPRESS_LIB_TARGET, "lib/ultragrid/module_vdecompress_rtdxt.so")
LIB_TARGETS="$LIB_TARGETS $RTDXT_COMPRESS_LIB_TARGET $RTDXT_DECOMPRESS_LIB_TARGET"
LIB_OBJS="$LIB_OBJS $RTDXT_COMMON_OBJ $RTDXT_COMPRESS_OBJ $RTDXT_DECOMPRESS_OBJ"
LIB_GENERATED_HEADERS="$RTDXT_COMMON_HEADERS"
@@ -2105,7 +2102,7 @@ then
JPEG_DECOMPRESS_OBJ="src/video_decompress/jpeg.o "
AC_DEFINE([HAVE_JPEG], [1], [Build with JPEG support])
AC_SUBST(JPEG_COMPRESS_LIB_TARGET, "lib/ultragrid/vcompress_jpeg.so.$video_compress_abi_version")
AC_SUBST(JPEG_DECOMPRESS_LIB_TARGET, "lib/ultragrid/vdecompress_jpeg.so.$video_decompress_abi_version")
AC_SUBST(JPEG_DECOMPRESS_LIB_TARGET, "lib/ultragrid/module_vdecompress_jpeg.so")
LIB_TARGETS="$LIB_TARGETS $JPEG_COMPRESS_LIB_TARGET $JPEG_DECOMPRESS_LIB_TARGET"
LIB_OBJS="$LIB_OBJS $JPEG_COMPRESS_OBJ $JPEG_DECOMPRESS_OBJ"
CUDA_MESSAGE
@@ -2192,7 +2189,7 @@ then
JPEG_TO_DXT_INC=" $CUDA_INC"
JPEG_TO_DXT_LIB=" $CUDA_LIB -lgpujpeg"
JPEG_TO_DXT_OBJ="src/video_decompress/jpeg_to_dxt.o cuda_dxt/cuda_dxt.$CU_SUFFIX"
AC_SUBST(JPEG_TO_DXT_DECOMPRESS_LIB_TARGET, "lib/ultragrid/vdecompress_jpeg_to_dxt.so.$video_decompress_abi_version")
AC_SUBST(JPEG_TO_DXT_DECOMPRESS_LIB_TARGET, "lib/ultragrid/module_vdecompress_jpeg_to_dxt.so")
LIB_TARGETS="$LIB_TARGETS $JPEG_TO_DXT_DECOMPRESS_LIB_TARGET"
LIB_OBJS="$LIB_OBJS src/video_decompress/jpeg_to_dxt.o"
AC_DEFINE([HAVE_JPEG_TO_DXT], [1], [Build with JPEG to DXT transcode support])
@@ -2671,7 +2668,7 @@ then
LIBAVCODEC_OBJ="src/video_compress/libavcodec.o"
AC_DEFINE([HAVE_LAVC], [1], [Build with LAVC support])
AC_SUBST(LIBAVCODEC_COMPRESS_LIB_TARGET, "lib/ultragrid/vcompress_libavcodec.so.$video_compress_abi_version")
AC_SUBST(LIBAVCODEC_DECOMPRESS_LIB_TARGET, "lib/ultragrid/vdecompress_libavcodec.so.$video_decompress_abi_version")
AC_SUBST(LIBAVCODEC_DECOMPRESS_LIB_TARGET, "lib/ultragrid/module_vdecompress_libavcodec.so")
AC_SUBST(LIBAVCODEC_AUDIO_CODEC_LIB_TARGET, "lib/ultragrid/module_acompress_libavcodec.so")
AC_DEFINE([HAVE_LAVC_AUDIO], [1], [Build with LAVC audio support])

View File

@@ -70,6 +70,7 @@ const map<enum library_class, library_class_info_t> library_class_info = {
{ LIBRARY_CLASS_VIDEO_CAPTURE, { "Video capture device", "vidcap" }},
{ LIBRARY_CLASS_VIDEO_DISPLAY, { "Video display device", "display" }},
{ LIBRARY_CLASS_AUDIO_COMPRESS, { "Audio compression", "acompress" }},
{ LIBRARY_CLASS_VIDEO_DECOMPRESS, { "Video decompression", "vdecompress" }},
};
static map<string, string> lib_errors;

View File

@@ -73,6 +73,7 @@ enum library_class {
LIBRARY_CLASS_VIDEO_CAPTURE,
LIBRARY_CLASS_VIDEO_DISPLAY,
LIBRARY_CLASS_AUDIO_COMPRESS,
LIBRARY_CLASS_VIDEO_DECOMPRESS,
};
void open_all(const char *pattern);
const void *load_library(const char *name, enum library_class, int abi_version);

View File

@@ -862,111 +862,6 @@ void video_decoder_destroy(struct state_video_decoder *decoder)
delete decoder;
}
/**
* Attemps to initialize decompress of given magic
*
* @param[in] magic magic of the requested decompressor
* @param[out] decompress_state decoder state
* @param[in] substreams number of decoders to be created
* @return true if initialization succeeded
*/
static bool try_initialize_decompress(uint32_t magic,
struct state_decompress **decompress_state, int substreams)
{
for(int i = 0; i < substreams; ++i) {
decompress_state[i] = decompress_init(magic);
if(!decompress_state[i]) {
debug_msg("Decompressor with magic %x was not found.\n");
for(int j = 0; j < substreams; ++j) {
if (decompress_state[i] != NULL)
decompress_done(decompress_state[i]);
decompress_state[i] = NULL;
}
return false;
}
}
return true;
}
/**
* @param[in] in_codec input codec
* @param[in] out_codec output codec
* @param[in] prio_min minimal priority that can be probed
* @param[in] prio_max maximal priority that can be probed
* @param[out] magic if decompressor was found here is stored its magic
* @retval -1 if no found
* @retval priority best decoder's priority
*/
static int find_best_decompress(codec_t in_codec, codec_t out_codec,
int prio_min, int prio_max, uint32_t *magic) {
int trans;
int best_priority = prio_max + 1;
// first pass - find the one with best priority (least)
for(trans = 0; trans < decoders_for_codec_count;
++trans) {
if(in_codec == decoders_for_codec[trans].from &&
out_codec == decoders_for_codec[trans].to) {
int priority = decoders_for_codec[trans].priority;
if(priority <= prio_max &&
priority >= prio_min &&
priority < best_priority) {
if(decompress_is_available(
decoders_for_codec[trans].decompress_index)) {
best_priority = priority;
*magic = decoders_for_codec[trans].decompress_index;
}
}
}
}
if(best_priority == prio_max + 1)
return -1;
return best_priority;
}
/**
* @brief Finds (best) decompress module for specified compression.
*
* If more than one decompress module is available, load the one with highest priority.
*
* @param[in] in_codec source compression
* @param[in] out_codec requested destination pixelformat
* @param[out] state pointer (array) to be filled with state_count instances of decompressor
* @param[in] state_count number of decompress states to be created.
* This is important mainly for interlrame compressions which keeps internal state between individual
* frames. Different tiles need to have different states then.
* @retval true if state_count members of state is filled with valid decompressor
* @retval false if initialization failed
*/
bool init_decompress(codec_t in_codec, codec_t out_codec,
struct state_decompress **state, int state_count)
{
int prio_max = 1000;
int prio_min = 0;
int prio_cur;
uint32_t decompress_magic = 0u;
while(1) {
prio_cur = find_best_decompress(in_codec, out_codec,
prio_min, prio_max, &decompress_magic);
// if found, init decoder
if(prio_cur != -1) {
if(try_initialize_decompress(decompress_magic, state, state_count)) {
return true;
} else {
// failed, try to find another one
prio_min = prio_cur + 1;
continue;
}
} else {
break;
}
}
return false;
}
/**
* This function selects, according to given video description, appropriate
*
@@ -1041,7 +936,7 @@ after_linedecoder_lookup:
out_codec = decoder->native_codecs[native];
decoder->decompress_state = (struct state_decompress **)
calloc(decoder->max_substreams, sizeof(struct state_decompress *));
if(init_decompress(desc.color_spec, decoder->native_codecs[native],
if (decompress_init_multi(desc.color_spec, decoder->native_codecs[native],
decoder->decompress_state,
decoder->max_substreams)) {
int res = 0, ret;

View File

@@ -62,7 +62,6 @@
#include "rtsp/rtsp_utils.h"
#include "video_decompress.h"
#include "video_decompress/libavcodec.h"
#include "pdb.h"
#include "rtp/pbuf.h"
@@ -891,11 +890,8 @@ init_decompressor(void *state) {
sr->sd = (struct state_decompress *) calloc(2,
sizeof(struct state_decompress *));
initialize_video_decompress();
if (decompress_is_available(LIBAVCODEC_MAGIC)) {
sr->sd = decompress_init(LIBAVCODEC_MAGIC);
if (decompress_init_multi(H264, UYVY, &sr->sd, 1)) {
sr->des.width = sr->frame->h264_width;
sr->des.height = sr->frame->h264_height;
sr->des.color_spec = sr->frame->color_spec;

View File

@@ -1,311 +0,0 @@
/**
* @file video_decompress.c
* @author Martin Benes <martinbenesh@gmail.com>
* @author Lukas Hejtmanek <xhejtman@ics.muni.cz>
* @author Petr Holub <hopet@ics.muni.cz>
* @author Milos Liska <xliska@fi.muni.cz>
* @author Jiri Matela <matela@ics.muni.cz>
* @author Dalibor Matura <255899@mail.muni.cz>
* @author Ian Wesley-Smith <iwsmith@cct.lsu.edu>
*
* @ingroup video_decompress
* @brief video compress functions
*/
/*
* Copyright (c) 2005-2013 CESNET z.s.p.o.
*
* Redistribution and use in source and binary forms, with or without
* modification, is permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by CESNET z.s.p.o.
*
* 4. Neither the name of the CESNET nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#endif // HAVE_CONFIG_H
#include <stdio.h>
#include <string.h>
#include "video_codec.h"
#include "video_decompress.h"
#include "video_decompress/dxt_glsl.h"
#include "video_decompress/jpeg.h"
#include "video_decompress/libavcodec.h"
#include "video_decompress/null.h"
#include "video_decompress/jpeg_to_dxt.h"
#include "lib_common.h"
#define DECOMPRESS_MAGIC 0xdff34f21u
/**
* @brief This struct describes individual decompress modules
*
* Initially, in this struct are either callbacks or functions names.
* For actual initialization of the callbacks/names, @ref MK_STATIC and @ref MK_NAME
* macros should be used. After initialization, callbacks are set.
*/
typedef struct {
uint32_t magic; ///< unique module identifier
char *library_name; ///< If module is dynamically loadable, this is the name of library.
decompress_init_t init;
const char *init_str;
decompress_reconfigure_t reconfigure;
const char *reconfigure_str;
decompress_decompress_t decompress;
const char *decompress_str;
decompress_get_property_t get_property;
const char *get_property_str;
decompress_done_t done;
const char *done_str;
void *handle; ///< for modular build, dynamically loaded library handle
} decoder_table_t;
/**
* This struct represents actual decompress state
*/
struct state_decompress {
uint32_t magic; ///< selected decoder magic
decoder_table_t *functions; ///< pointer to selected decoder functions
void *state; ///< decoder driver state
};
#ifdef BUILD_LIBRARIES
/** Opens decompress library of given name. */
static void *decompress_open_library(const char *vidcap_name)
{
char name[128];
snprintf(name, sizeof(name), "vdecompress_%s.so.%d", vidcap_name, VIDEO_DECOMPRESS_ABI_VERSION);
return open_library(name);
}
/** For a given device, load individual functions from library handle (previously opened). */
static int decompress_fill_symbols(decoder_table_t *device)
{
void *handle = device->handle;
device->init = (decompress_init_t)
dlsym(handle, device->init_str);
device->reconfigure = (decompress_reconfigure_t)
dlsym(handle, device->reconfigure_str);
device->decompress = (decompress_decompress_t)
dlsym(handle, device->decompress_str);
device->get_property = (decompress_get_property_t)
dlsym(handle, device->get_property_str);
device->done = (decompress_done_t)
dlsym(handle, device->done_str);
if(!device->init || !device->reconfigure || !device->decompress ||
!device->get_property || !device->done) {
fprintf(stderr, "Library %s opening error: %s \n", device->library_name, dlerror());
return FALSE;
}
return TRUE;
}
#endif
/**
* This array represent list of all known decoders and its capabilities
*
* The lower priority decoders are selected earlier if present.
*/
struct decode_from_to decoders_for_codec[] = {
{ DXT1, RGBA, RTDXT_MAGIC, 500},
{ DXT1_YUV, RGBA, RTDXT_MAGIC, 500 },
{ DXT5, RGBA, RTDXT_MAGIC, 500 },
{ DXT1, UYVY, RTDXT_MAGIC, 500 },
{ DXT1_YUV, UYVY, RTDXT_MAGIC, 500 },
{ DXT5, UYVY, RTDXT_MAGIC, 500 },
{ JPEG, RGB, JPEG_MAGIC, 500 },
{ JPEG, UYVY, JPEG_MAGIC, 500 },
{ H264, UYVY, LIBAVCODEC_MAGIC, 500 },
{ H265, UYVY, LIBAVCODEC_MAGIC, 500 },
{ JPEG, UYVY, LIBAVCODEC_MAGIC, 600 },
{ MJPG, UYVY, LIBAVCODEC_MAGIC, 500 },
{ J2K, RGB, LIBAVCODEC_MAGIC, 500 },
{ JPEG, DXT1, JPEG_TO_DXT_MAGIC, 900 },
{ JPEG, DXT5, JPEG_TO_DXT_MAGIC, 900 },
{ VP8, UYVY, LIBAVCODEC_MAGIC, 500 },
};
/** @brief Length of @ref decoders_for_codec members (items) */
const int decoders_for_codec_count = (sizeof(decoders_for_codec) / sizeof(struct decode_from_to));
/**
* @brief This table contains list of decoders compiled with this UltraGrid version.
* If building modular UltraGrid version, hooks for all modules will be created.
*/
decoder_table_t decoders[] = {
#if defined HAVE_DXT_GLSL || defined BUILD_LIBRARIES
{ RTDXT_MAGIC, "rtdxt", MK_NAME(dxt_glsl_decompress_init), MK_NAME(dxt_glsl_decompress_reconfigure),
MK_NAME(dxt_glsl_decompress), MK_NAME(dxt_glsl_decompress_get_property),
MK_NAME(dxt_glsl_decompress_done), NULL},
#endif
#if defined HAVE_JPEG || defined BUILD_LIBRARIES
{ JPEG_MAGIC, "jpeg", MK_NAME(jpeg_decompress_init), MK_NAME(jpeg_decompress_reconfigure),
MK_NAME(jpeg_decompress), MK_NAME(jpeg_decompress_get_property),
MK_NAME(jpeg_decompress_done), NULL},
#endif
#if defined HAVE_LAVC || defined BUILD_LIBRARIES
{ LIBAVCODEC_MAGIC, "libavcodec",
MK_NAME(libavcodec_decompress_init),
MK_NAME(libavcodec_decompress_reconfigure),
MK_NAME(libavcodec_decompress),
MK_NAME(libavcodec_decompress_get_property),
MK_NAME(libavcodec_decompress_done),
NULL},
#endif
#if defined HAVE_JPEG_TO_DXT || defined BUILD_LIBRARIES
{ JPEG_TO_DXT_MAGIC, "jpeg_to_dxt", MK_NAME(jpeg_to_dxt_decompress_init), MK_NAME(jpeg_to_dxt_decompress_reconfigure),
MK_NAME(jpeg_to_dxt_decompress), MK_NAME(jpeg_to_dxt_decompress_get_property),
MK_NAME(jpeg_to_dxt_decompress_done), NULL},
#endif
{ NULL_MAGIC, NULL, MK_STATIC(null_decompress_init), MK_STATIC(null_decompress_reconfigure),
MK_STATIC(null_decompress), MK_NAME(null_decompress_get_property),
MK_STATIC(null_decompress_done), NULL}
};
/** @brief length of @ref decoders array */
#define MAX_DECODERS (sizeof(decoders) / sizeof(decoder_table_t))
/** @brief List of available decoders
* Initialized with @ref initialize_video_decompress */
decoder_table_t *available_decoders[MAX_DECODERS];
/** Count of @ref available_decoders.
* Initialized with @ref initialize_video_decompress */
int available_decoders_count = -1;
/** must be called before initalization of decoders */
void initialize_video_decompress(void)
{
available_decoders_count = 0;
unsigned int i;
for (i = 0; i < MAX_DECODERS; ++i) {
#ifdef BUILD_LIBRARIES
decoders[i].handle = NULL;
if(decoders[i].library_name) {
decoders[i].handle = decompress_open_library(decoders[i].library_name);
int ret;
if(!decoders[i].handle)
continue;
ret = decompress_fill_symbols(&decoders[i]);
if(!ret)
continue;
}
#endif
available_decoders[available_decoders_count] = &decoders[i];
available_decoders_count++;
}
}
/**
* Checks wheather there is decompressor with given magic present and thus can
* be initialized with decompress_init
*
* @see decompress_init
* @retval TRUE if decoder is present and can be initialized
* @retval FALSE if decoder could not be initialized (not found)
*/
int decompress_is_available(unsigned int decoder_index)
{
int i;
assert(available_decoders_count > -1);
for(i = 0; i < available_decoders_count; ++i) {
if(available_decoders[i]->magic == decoder_index) {
return TRUE;
}
}
return FALSE;
}
/**
* Initializes decompressor or the given magic
*
* @retval NULL if initialization failed
* @retval not-NULL state of new decompressor
*/
struct state_decompress *decompress_init(unsigned int decoder_index)
{
int i;
struct state_decompress *s;
for(i = 0; i < available_decoders_count; ++i) {
if(available_decoders[i]->magic == decoder_index) {
s = (struct state_decompress *) calloc(1, sizeof(struct state_decompress));
s->magic = DECOMPRESS_MAGIC;
s->functions = available_decoders[i];
s->state = s->functions->init();
if (s->state == NULL) {
free(s);
return NULL;
}
return s;
}
}
return NULL;
}
/** @copydoc decompress_reconfigure_t */
int decompress_reconfigure(struct state_decompress *s, struct video_desc desc, int rshift, int gshift, int bshift, int pitch, codec_t out_codec)
{
assert(s->magic == DECOMPRESS_MAGIC);
return s->functions->reconfigure(s->state, desc, rshift, gshift, bshift, pitch, out_codec);
}
/** @copydoc decompress_decompress_t */
int decompress_frame(struct state_decompress *s, unsigned char *dst,
unsigned char *compressed, unsigned int compressed_len, int frame_seq)
{
assert(s->magic == DECOMPRESS_MAGIC);
return s->functions->decompress(s->state, dst, compressed, compressed_len, frame_seq);
}
/** @copydoc decompress_get_property_t */
int decompress_get_property(struct state_decompress *s, int property, void *val, size_t *len)
{
return s->functions->get_property(s->state, property, val, len);
}
/** @copydoc decompress_done_t */
void decompress_done(struct state_decompress *s)
{
assert(s->magic == DECOMPRESS_MAGIC);
s->functions->done(s->state);
free(s);
}

226
src/video_decompress.cpp Normal file
View File

@@ -0,0 +1,226 @@
/**
* @file video_decompress.cpp
* @author Martin Pulec <pulec@cesnet.cz>
*/
/*
* Copyright (c) 2011-2015 CESNET, z. s. p. o.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, is permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of CESNET nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#endif // HAVE_CONFIG_H
#include <stdio.h>
#include <string.h>
#include <string>
#include "debug.h"
#include "video_codec.h"
#include "video_decompress.h"
#include "lib_common.h"
#define DECOMPRESS_MAGIC 0xdff34f21u
using std::string;
/**
* This struct represents actual decompress state
*/
struct state_decompress {
uint32_t magic; ///< selected decoder magic
const struct video_decompress_info *functions; ///< pointer to selected decoder functions
void *state; ///< decoder driver state
};
/**
* @param[in] in_codec input codec
* @param[in] out_codec output codec
* @param[in] prio_min minimal priority that can be probed
* @param[in] prio_max maximal priority that can be probed
* @param[out] magic if decompressor was found here is stored its magic
* @retval -1 if no found
* @retval priority best decoder's priority
*/
static int find_best_decompress(codec_t in_codec, codec_t out_codec,
int prio_min, int prio_max, const struct video_decompress_info **vdi, string & name) {
auto decomps = get_libraries_for_class(LIBRARY_CLASS_VIDEO_DECOMPRESS, VIDEO_DECOMPRESS_ABI_VERSION);
int best_priority = prio_max + 1;
for (const auto & d : decomps) {
// first pass - find the one with best priority (least)
const struct decode_from_to *f = static_cast<const video_decompress_info *>(d.second)->available_decoders;
while (f->from != VIDEO_CODEC_NONE) {
if(in_codec == f->from && out_codec == f->to) {
int priority = f->priority;
if(priority <= prio_max &&
priority >= prio_min &&
priority < best_priority) {
best_priority = priority;
*vdi = static_cast<const video_decompress_info *>(d.second);
name = d.first;
}
}
f++;
}
}
if(best_priority == prio_max + 1)
return -1;
return best_priority;
}
/**
* Initializes decompressor
*
* @retval NULL if initialization failed
* @retval not-NULL state of new decompressor
*/
static struct state_decompress *decompress_init(const video_decompress_info *vdi)
{
struct state_decompress *s;
s = (struct state_decompress *) calloc(1, sizeof(struct state_decompress));
s->magic = DECOMPRESS_MAGIC;
s->functions = vdi;
s->state = s->functions->init();
if (s->state == NULL) {
free(s);
return NULL;
}
return s;
}
/**
* Attemps to initialize decompress of given magic
*
* @param[in] vdi metadata struct of requested decompressor
* @param[out] decompress_state decoder state
* @param[in] substreams number of decoders to be created
* @return true if initialization succeeded
*/
static bool try_initialize_decompress(const video_decompress_info *vdi,
struct state_decompress **decompress_state, int substreams)
{
for(int i = 0; i < substreams; ++i) {
decompress_state[i] = decompress_init(vdi);
if (!decompress_state[i]) {
for(int j = 0; j < substreams; ++j) {
if (decompress_state[i] != NULL)
decompress_done(decompress_state[i]);
decompress_state[i] = NULL;
}
return false;
}
}
return true;
}
/**
* @brief Initializes (multiple) decompress states
*
* If more than one decompress module is available, load the one with highest priority.
*
* @param[in] in_codec source compression
* @param[in] out_codec requested destination pixelformat
* @param[out] out pointer (array) to be filled with state_count instances of decompressor
* @param[in] count number of decompress states to be created.
* This is important mainly for interlrame compressions which keeps internal state between individual
* frames. Different tiles need to have different states then.
* @retval true if state_count members of state is filled with valid decompressor
* @retval false if initialization failed
*/
bool decompress_init_multi(codec_t in_codec, codec_t out_codec, struct state_decompress **out, int count)
{
int prio_max = 1000;
int prio_min = 0;
int prio_cur;
const video_decompress_info *vdi = nullptr;
while(1) {
string name;
prio_cur = find_best_decompress(in_codec, out_codec,
prio_min, prio_max, &vdi, name);
// if found, init decoder
if(prio_cur != -1) {
if (try_initialize_decompress(vdi, out, count)) {
LOG(LOG_LEVEL_VERBOSE) << "Decompressor \"" << name << "\" initialized successfully.\n";
return true;
} else {
// failed, try to find another one
LOG(LOG_LEVEL_VERBOSE) << "Cannot initialize decompressor \"" << name << "\"!\n";
prio_min = prio_cur + 1;
continue;
}
} else {
break;
}
}
return false;
}
/** @copydoc decompress_reconfigure_t */
int decompress_reconfigure(struct state_decompress *s, struct video_desc desc, int rshift, int gshift, int bshift, int pitch, codec_t out_codec)
{
assert(s->magic == DECOMPRESS_MAGIC);
return s->functions->reconfigure(s->state, desc, rshift, gshift, bshift, pitch, out_codec);
}
/** @copydoc decompress_decompress_t */
int decompress_frame(struct state_decompress *s, unsigned char *dst,
unsigned char *compressed, unsigned int compressed_len, int frame_seq)
{
assert(s->magic == DECOMPRESS_MAGIC);
return s->functions->decompress(s->state, dst, compressed, compressed_len, frame_seq);
}
/** @copydoc decompress_get_property_t */
int decompress_get_property(struct state_decompress *s, int property, void *val, size_t *len)
{
return s->functions->get_property(s->state, property, val, len);
}
/** @copydoc decompress_done_t */
void decompress_done(struct state_decompress *s)
{
assert(s->magic == DECOMPRESS_MAGIC);
s->functions->done(s->state);
free(s);
}

View File

@@ -50,6 +50,8 @@
*
*/
#define VIDEO_DECOMPRESS_ABI_VERSION 4
/**
* @defgroup video_decompress Video Decompress
* @{
@@ -130,19 +132,23 @@ struct decode_from_to {
codec_t from; ///< input (compressed) codec
codec_t to; ///< output pixelformat
uint32_t decompress_index; ///< unique identifier of decompress module
/** Priority to select this decoder if there are multiple matches for
* specified compress/pixelformat pair.
* Range is [0..1000], lower is better.
*/
int priority;
};
extern struct decode_from_to decoders_for_codec[];
extern const int decoders_for_codec_count;
void initialize_video_decompress(void);
int decompress_is_available(unsigned int decoder_index);
struct state_decompress *decompress_init(unsigned int magic);
struct video_decompress_info {
decompress_init_t init;
decompress_reconfigure_t reconfigure;
decompress_decompress_t decompress;
decompress_get_property_t get_property;
decompress_done_t done;
const struct decode_from_to *available_decoders;
};
bool decompress_init_multi(codec_t from, codec_t to, struct state_decompress **out, int count);
int decompress_reconfigure(struct state_decompress *, struct video_desc, int rshift, int gshift, int bshift, int pitch, codec_t out_codec);
int decompress_frame(struct state_decompress *, unsigned char *dst,
unsigned char *src, unsigned int src_len, int frame_seq);

View File

@@ -60,7 +60,7 @@
#include "video.h"
#include <pthread.h>
#include <stdlib.h>
#include "video_decompress/dxt_glsl.h"
#include "lib_common.h"
#include "gl_context.h"
@@ -112,7 +112,7 @@ static void configure_with(struct state_decompress_rtdxt *decompressor, struct v
decompressor->configured = TRUE;
}
void * dxt_glsl_decompress_init(void)
static void * dxt_glsl_decompress_init(void)
{
struct state_decompress_rtdxt *s;
@@ -122,7 +122,7 @@ void * dxt_glsl_decompress_init(void)
return s;
}
int dxt_glsl_decompress_reconfigure(void *state, struct video_desc desc,
static int dxt_glsl_decompress_reconfigure(void *state, struct video_desc desc,
int rshift, int gshift, int bshift, int pitch, codec_t out_codec)
{
struct state_decompress_rtdxt *s = (struct state_decompress_rtdxt *) state;
@@ -146,7 +146,7 @@ int dxt_glsl_decompress_reconfigure(void *state, struct video_desc desc,
return TRUE;
}
int dxt_glsl_decompress(void *state, unsigned char *dst, unsigned char *buffer,
static int dxt_glsl_decompress(void *state, unsigned char *dst, unsigned char *buffer,
unsigned int src_len, int frame_seq)
{
struct state_decompress_rtdxt *s = (struct state_decompress_rtdxt *) state;
@@ -198,7 +198,7 @@ int dxt_glsl_decompress(void *state, unsigned char *dst, unsigned char *buffer,
return TRUE;
}
int dxt_glsl_decompress_get_property(void *state, int property, void *val, size_t *len)
static int dxt_glsl_decompress_get_property(void *state, int property, void *val, size_t *len)
{
struct state_decompress_rtdxt *s = (struct state_decompress_rtdxt *) state;
UNUSED(s);
@@ -219,7 +219,7 @@ int dxt_glsl_decompress_get_property(void *state, int property, void *val, size_
return ret;
}
void dxt_glsl_decompress_done(void *state)
static void dxt_glsl_decompress_done(void *state)
{
struct state_decompress_rtdxt *s = (struct state_decompress_rtdxt *) state;
@@ -232,3 +232,24 @@ void dxt_glsl_decompress_done(void *state)
free(s);
}
static const struct decode_from_to dxt_glsl_decoders[] = {
{ DXT1, RGBA, 500 },
{ DXT1_YUV, RGBA, 500 },
{ DXT5, RGBA, 500 },
{ DXT1, UYVY, 500 },
{ DXT1_YUV, UYVY, 500 },
{ DXT5, UYVY, 500 },
{ VIDEO_CODEC_NONE, VIDEO_CODEC_NONE, 0 },
};
static const struct video_decompress_info dxt_glsl_info = {
dxt_glsl_decompress_init,
dxt_glsl_decompress_reconfigure,
dxt_glsl_decompress,
dxt_glsl_decompress_get_property,
dxt_glsl_decompress_done,
dxt_glsl_decoders,
};
REGISTER_MODULE(dxt_glsl, &dxt_glsl_info, LIBRARY_CLASS_VIDEO_DECOMPRESS, VIDEO_DECOMPRESS_ABI_VERSION);

View File

@@ -1,59 +0,0 @@
/*
* FILE: video_decompress/dxt_glsl.c
* AUTHORS: Martin Benes <martinbenesh@gmail.com>
* Lukas Hejtmanek <xhejtman@ics.muni.cz>
* Petr Holub <hopet@ics.muni.cz>
* Milos Liska <xliska@fi.muni.cz>
* Jiri Matela <matela@ics.muni.cz>
* Dalibor Matura <255899@mail.muni.cz>
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
*
* Copyright (c) 2005-2010 CESNET z.s.p.o.
*
* Redistribution and use in source and binary forms, with or without
* modification, is permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by CESNET z.s.p.o.
*
* 4. Neither the name of the CESNET nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "types.h"
#define RTDXT_MAGIC 0x2cc33ba3u
void * dxt_glsl_decompress_init(void);
int dxt_glsl_decompress_reconfigure(void *state, struct video_desc desc,
int rshift, int gshift, int bshift, int pitch, codec_t out_codec);
int dxt_glsl_decompress(void *state, unsigned char *dst, unsigned char *buffer,
unsigned int src_len, int frame_seq);
int dxt_glsl_decompress_get_property(void *state, int property, void *val, size_t *len);
void dxt_glsl_decompress_done(void *state);

View File

@@ -59,7 +59,7 @@
//#include "compat/platform_semaphore.h"
#include <pthread.h>
#include <stdlib.h>
#include "video_decompress/jpeg.h"
#include "lib_common.h"
struct state_decompress_jpeg {
struct gpujpeg_decoder *decoder;
@@ -91,7 +91,7 @@ static int configure_with(struct state_decompress_jpeg *s, struct video_desc des
return TRUE;
}
void * jpeg_decompress_init(void)
static void * jpeg_decompress_init(void)
{
struct state_decompress_jpeg *s;
@@ -113,7 +113,7 @@ void * jpeg_decompress_init(void)
return s;
}
int jpeg_decompress_reconfigure(void *state, struct video_desc desc,
static int jpeg_decompress_reconfigure(void *state, struct video_desc desc,
int rshift, int gshift, int bshift, int pitch, codec_t out_codec)
{
struct state_decompress_jpeg *s = (struct state_decompress_jpeg *) state;
@@ -140,7 +140,7 @@ int jpeg_decompress_reconfigure(void *state, struct video_desc desc,
}
}
int jpeg_decompress(void *state, unsigned char *dst, unsigned char *buffer,
static int jpeg_decompress(void *state, unsigned char *dst, unsigned char *buffer,
unsigned int src_len, int frame_seq)
{
UNUSED(frame_seq);
@@ -197,7 +197,7 @@ int jpeg_decompress(void *state, unsigned char *dst, unsigned char *buffer,
return TRUE;
}
int jpeg_decompress_get_property(void *state, int property, void *val, size_t *len)
static int jpeg_decompress_get_property(void *state, int property, void *val, size_t *len)
{
struct state_decompress *s = (struct state_decompress *) state;
UNUSED(s);
@@ -218,7 +218,7 @@ int jpeg_decompress_get_property(void *state, int property, void *val, size_t *l
return ret;
}
void jpeg_decompress_done(void *state)
static void jpeg_decompress_done(void *state)
{
struct state_decompress_jpeg *s = (struct state_decompress_jpeg *) state;
@@ -227,3 +227,21 @@ void jpeg_decompress_done(void *state)
}
free(s);
}
static const struct decode_from_to jpeg_decoders[] = {
{ JPEG, RGB, 500 },
{ JPEG, UYVY, 500 },
{ VIDEO_CODEC_NONE, VIDEO_CODEC_NONE, 0 },
};
static const struct video_decompress_info jpeg_info = {
jpeg_decompress_init,
jpeg_decompress_reconfigure,
jpeg_decompress,
jpeg_decompress_get_property,
jpeg_decompress_done,
jpeg_decoders,
};
REGISTER_MODULE(jpeg, &jpeg_info, LIBRARY_CLASS_VIDEO_DECOMPRESS, VIDEO_DECOMPRESS_ABI_VERSION);

View File

@@ -1,59 +0,0 @@
/*
* FILE: video_decompress/dxt_glsl.c
* AUTHORS: Martin Benes <martinbenesh@gmail.com>
* Lukas Hejtmanek <xhejtman@ics.muni.cz>
* Petr Holub <hopet@ics.muni.cz>
* Milos Liska <xliska@fi.muni.cz>
* Jiri Matela <matela@ics.muni.cz>
* Dalibor Matura <255899@mail.muni.cz>
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
*
* Copyright (c) 2005-2010 CESNET z.s.p.o.
*
* Redistribution and use in source and binary forms, with or without
* modification, is permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by CESNET z.s.p.o.
*
* 4. Neither the name of the CESNET nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "types.h"
#define JPEG_MAGIC 0x3fd43f51u
void * jpeg_decompress_init(void);
int jpeg_decompress_reconfigure(void *state, struct video_desc desc,
int rshift, int gshift, int bshift, int pitch, codec_t out_codec);
int jpeg_decompress(void *state, unsigned char *dst, unsigned char *buffer,
unsigned int src_len, int buffer_seq);
int jpeg_decompress_get_property(void *state, int property, void *val, size_t *len);
void jpeg_decompress_done(void *state);

View File

@@ -41,7 +41,6 @@
#include "config_win32.h"
#endif // HAVE_CONFIG_H
#include "video_decompress/jpeg_to_dxt.h"
#include "cuda_dxt/cuda_dxt.h"
#include <pthread.h>
@@ -50,11 +49,11 @@
#include "libgpujpeg/gpujpeg_decoder.h"
#include "debug.h"
#include "lib_common.h"
#include "host.h"
#include "utils/synchronized_queue.h"
#include "video.h"
#include "video_decompress.h"
#include "video_decompress/jpeg.h"
namespace {
@@ -360,3 +359,21 @@ void jpeg_to_dxt_decompress_done(void *state)
delete s;
}
static const struct decode_from_to jpeg_to_dxt_decoders[] = {
{ JPEG, DXT1, 900 },
{ JPEG, DXT5, 900 },
{ VIDEO_CODEC_NONE, VIDEO_CODEC_NONE, 0 },
};
static const struct video_decompress_info jpeg_to_dxt_info = {
jpeg_to_dxt_decompress_init,
jpeg_to_dxt_decompress_reconfigure,
jpeg_to_dxt_decompress,
jpeg_to_dxt_decompress_get_property,
jpeg_to_dxt_decompress_done,
jpeg_to_dxt_decoders,
};
REGISTER_MODULE(jpeg_to_dxt, &jpeg_to_dxt_info, LIBRARY_CLASS_VIDEO_DECOMPRESS, VIDEO_DECOMPRESS_ABI_VERSION);

View File

@@ -1,67 +0,0 @@
/*
* FILE: video_decompress/transcode.h
* AUTHORS: Martin Benes <martinbenesh@gmail.com>
* Lukas Hejtmanek <xhejtman@ics.muni.cz>
* Petr Holub <hopet@ics.muni.cz>
* Milos Liska <xliska@fi.muni.cz>
* Jiri Matela <matela@ics.muni.cz>
* Dalibor Matura <255899@mail.muni.cz>
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
*
* Copyright (c) 2005-2010 CESNET z.s.p.o.
*
* Redistribution and use in source and binary forms, with or without
* modification, is permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by CESNET z.s.p.o.
*
* 4. Neither the name of the CESNET nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "types.h"
#define JPEG_TO_DXT_MAGIC 0x20BF0088
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void * jpeg_to_dxt_decompress_init(void);
int jpeg_to_dxt_decompress_reconfigure(void *state, struct video_desc desc,
int rshift, int gshift, int bshift, int pitch, codec_t out_codec);
int jpeg_to_dxt_decompress(void *state, unsigned char *dst, unsigned char *buffer,
unsigned int src_len, int frame_seq);
int jpeg_to_dxt_decompress_get_property(void *state, int property, void *val, size_t *len);
void jpeg_to_dxt_decompress_done(void *state);
#ifdef __cplusplus
}
#endif // __cplusplus

View File

@@ -42,11 +42,10 @@
#include "config_win32.h"
#endif // HAVE_CONFIG_H
#include "video_decompress/libavcodec.h"
#include "debug.h"
#include "host.h"
#include "libavcodec_common.h"
#include "lib_common.h"
#include "utils/resource_manager.h"
#include "video.h"
#include "video_decompress.h"
@@ -200,7 +199,7 @@ static bool configure_with(struct state_libavcodec_decompress *s,
return true;
}
void * libavcodec_decompress_init(void)
static void * libavcodec_decompress_init(void)
{
struct state_libavcodec_decompress *s;
@@ -228,7 +227,7 @@ void * libavcodec_decompress_init(void)
return s;
}
int libavcodec_decompress_reconfigure(void *state, struct video_desc desc,
static int libavcodec_decompress_reconfigure(void *state, struct video_desc desc,
int rshift, int gshift, int bshift, int pitch, codec_t out_codec)
{
struct state_libavcodec_decompress *s =
@@ -450,7 +449,7 @@ static void error_callback(void *ptr, int level, const char *fmt, va_list vl) {
}
int libavcodec_decompress(void *state, unsigned char *dst, unsigned char *src,
static int libavcodec_decompress(void *state, unsigned char *dst, unsigned char *src,
unsigned int src_len, int frame_seq)
{
struct state_libavcodec_decompress *s = (struct state_libavcodec_decompress *) state;
@@ -539,7 +538,7 @@ int libavcodec_decompress(void *state, unsigned char *dst, unsigned char *src,
return res;
}
int libavcodec_decompress_get_property(void *state, int property, void *val, size_t *len)
static int libavcodec_decompress_get_property(void *state, int property, void *val, size_t *len)
{
struct state_libavcodec_decompress *s =
(struct state_libavcodec_decompress *) state;
@@ -565,7 +564,7 @@ int libavcodec_decompress_get_property(void *state, int property, void *val, siz
return ret;
}
void libavcodec_decompress_done(void *state)
static void libavcodec_decompress_done(void *state)
{
struct state_libavcodec_decompress *s =
(struct state_libavcodec_decompress *) state;
@@ -577,3 +576,24 @@ void libavcodec_decompress_done(void *state)
free(s);
}
static const struct decode_from_to libavcodec_decoders[] = {
{ H264, UYVY, 500 },
{ H265, UYVY, 500 },
{ JPEG, UYVY, 600 },
{ MJPG, UYVY, 500 },
{ J2K, RGB, 500 },
{ VP8, UYVY, 500 },
{ VIDEO_CODEC_NONE, VIDEO_CODEC_NONE, 0 },
};
static const struct video_decompress_info libavcodec_info = {
libavcodec_decompress_init,
libavcodec_decompress_reconfigure,
libavcodec_decompress,
libavcodec_decompress_get_property,
libavcodec_decompress_done,
libavcodec_decoders,
};
REGISTER_MODULE(libavcodec, &libavcodec_info, LIBRARY_CLASS_VIDEO_DECOMPRESS, VIDEO_DECOMPRESS_ABI_VERSION);

View File

@@ -1,59 +0,0 @@
/*
* FILE: video_decompress/dxt_glsl.c
* AUTHORS: Martin Benes <martinbenesh@gmail.com>
* Lukas Hejtmanek <xhejtman@ics.muni.cz>
* Petr Holub <hopet@ics.muni.cz>
* Milos Liska <xliska@fi.muni.cz>
* Jiri Matela <matela@ics.muni.cz>
* Dalibor Matura <255899@mail.muni.cz>
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
*
* Copyright (c) 2005-2010 CESNET z.s.p.o.
*
* Redistribution and use in source and binary forms, with or without
* modification, is permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by CESNET z.s.p.o.
*
* 4. Neither the name of the CESNET nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "types.h"
#define LIBAVCODEC_MAGIC 0xff2f1b41u
void *libavcodec_decompress_init(void);
int libavcodec_decompress_reconfigure(void *state, struct video_desc desc,
int rshift, int gshift, int bshift, int pitch, codec_t out_codec);
int libavcodec_decompress(void *state, unsigned char *dst,
unsigned char *buffer, unsigned int src_len, int frame_seq);
int libavcodec_decompress_get_property(void *state, int property, void *val, size_t *len);
void libavcodec_decompress_done(void *state);

View File

@@ -1,119 +0,0 @@
/*
* FILE: video_decompress/dxt_glsl.c
* AUTHORS: Martin Benes <martinbenesh@gmail.com>
* Lukas Hejtmanek <xhejtman@ics.muni.cz>
* Petr Holub <hopet@ics.muni.cz>
* Milos Liska <xliska@fi.muni.cz>
* Jiri Matela <matela@ics.muni.cz>
* Dalibor Matura <255899@mail.muni.cz>
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
*
* Copyright (c) 2005-2011 CESNET z.s.p.o.
*
* Redistribution and use in source and binary forms, with or without
* modification, is permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by CESNET z.s.p.o.
*
* 4. Neither the name of the CESNET nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#include "debug.h"
#include "video_decompress/null.h"
#include <stdlib.h>
struct state_decompress_null {
uint32_t magic;
};
void * null_decompress_init(void)
{
struct state_decompress_null *s;
s = (struct state_decompress_null *) malloc(sizeof(struct state_decompress_null));
s->magic = NULL_MAGIC;
return s;
}
int null_decompress_reconfigure(void *state, struct video_desc desc,
int rshift, int gshift, int bshift, int pitch, codec_t out_codec)
{
struct state_decompress_null *s = (struct state_decompress_null *) state;
UNUSED(desc);
UNUSED(rshift);
UNUSED(gshift);
UNUSED(bshift);
UNUSED(pitch);
UNUSED(out_codec);
assert(s->magic == NULL_MAGIC);
return TRUE;
}
int null_decompress(void *state, unsigned char *dst, unsigned char *buffer,
unsigned int src_len, int frame_seq)
{
struct state_decompress_null *s = (struct state_decompress_null *) state;
assert(s->magic == NULL_MAGIC);
UNUSED(dst);
UNUSED(buffer);
UNUSED(src_len);
UNUSED(frame_seq);
return TRUE;
}
int null_decompress_get_property(void *state, int property, void *val, size_t *len)
{
struct state_decompress *s = (struct state_decompress *) state;
UNUSED(s);
UNUSED(property);
UNUSED(val);
UNUSED(len);
return FALSE;
}
void null_decompress_done(void *state)
{
struct state_decompress_null *s = (struct state_decompress_null *) state;
if(!s)
return;
assert(s->magic == NULL_MAGIC);
free(s);
}

View File

@@ -1,59 +0,0 @@
/*
* FILE: video_decompress/dxt_glsl.c
* AUTHORS: Martin Benes <martinbenesh@gmail.com>
* Lukas Hejtmanek <xhejtman@ics.muni.cz>
* Petr Holub <hopet@ics.muni.cz>
* Milos Liska <xliska@fi.muni.cz>
* Jiri Matela <matela@ics.muni.cz>
* Dalibor Matura <255899@mail.muni.cz>
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
*
* Copyright (c) 2005-2010 CESNET z.s.p.o.
*
* Redistribution and use in source and binary forms, with or without
* modification, is permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by CESNET z.s.p.o.
*
* 4. Neither the name of the CESNET nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "types.h"
#define NULL_MAGIC 0x24443b5bu
void * null_decompress_init(void);
int null_decompress_reconfigure(void *state, struct video_desc desc,
int rshift, int gshift, int bshift, int pitch, codec_t out_codec);
int null_decompress(void *state, unsigned char *dst, unsigned char *buffer,
unsigned int src_len, int frame_seq);
int null_decompress_get_property(void *state, int property, void *val, size_t *len);
void null_decompress_done(void *state);

View File

@@ -330,8 +330,6 @@ void *ultragrid_rtp_video_rxtx::receiver_loop()
}
#endif // SHARED_DECODER
initialize_video_decompress();
fr = 1;
while (!should_exit_receiver) {