From df966ee263d44ecbd9022bc0d07a6152e12549a2 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 5 May 2015 14:38:23 +0200 Subject: [PATCH] Removed external line_decoders Changed video decoder in order to select preferred display codec with fast decoder. If none of supported display codecs is selected, tries also slower decoders (like RGB->UYVY). --- src/rtp/video_decoders.cpp | 31 ++++++++++------ src/video_codec.c | 75 ++++++++++++++------------------------ src/video_codec.h | 10 ----- 3 files changed, 47 insertions(+), 69 deletions(-) diff --git a/src/rtp/video_decoders.cpp b/src/rtp/video_decoders.cpp index d166f197d..70c460fa7 100644 --- a/src/rtp/video_decoders.cpp +++ b/src/rtp/video_decoders.cpp @@ -993,20 +993,29 @@ static codec_t choose_codec_and_decoder(struct state_video_decoder *decoder, str } } /* otherwise if we have line decoder */ - int trans; - for(trans = 0; line_decoders[trans].line_decoder != NULL; - ++trans) { - for(native = 0; native < decoder->native_count; ++native) - { + for(native = 0; native < decoder->native_count; ++native) + { + decoder_t decode; + if ((decode = get_decoder_from_to(desc.color_spec, decoder->native_codecs[native], false)) != NULL) { + *decode_line = decode; + + decoder->decoder_type = LINE_DECODER; out_codec = decoder->native_codecs[native]; - if(desc.color_spec == line_decoders[trans].from && - out_codec == line_decoders[trans].to) { + goto after_linedecoder_lookup; - *decode_line = line_decoders[trans].line_decoder; + } + } + /* the same, but include also slow decoders */ + for(native = 0; native < decoder->native_count; ++native) + { + decoder_t decode; + if ((decode = get_decoder_from_to(desc.color_spec, decoder->native_codecs[native], true)) != NULL) { + *decode_line = decode; + + decoder->decoder_type = LINE_DECODER; + out_codec = decoder->native_codecs[native]; + goto after_linedecoder_lookup; - decoder->decoder_type = LINE_DECODER; - goto after_linedecoder_lookup; - } } } diff --git a/src/video_codec.c b/src/video_codec.c index 2578fb774..49c109dbc 100644 --- a/src/video_codec.c +++ b/src/video_codec.c @@ -135,27 +135,6 @@ static const struct codec_info_t codec_info[] = { {(codec_t) 0, NULL, 0, 0, 0.0, 0, FALSE, FALSE, FALSE, NULL} }; -/* Also note that this is a priority list - is choosen first one that - * matches input codec and one of the supported output codec, so eg. - * list 10b->10b earlier to 10b->8b etc. */ -const struct line_decode_from_to line_decoders[] = { - { RGBA, RGBA, vc_copylineRGBA}, - { RGB, RGB, vc_copylineRGB}, - { DVS10, v210, (decoder_t) vc_copylineDVS10toV210}, - { DVS10, UYVY, (decoder_t) vc_copylineDVS10}, - { R10k, RGBA, vc_copyliner10k}, - { v210, UYVY, (decoder_t) vc_copylinev210}, - { YUYV, UYVY, (decoder_t) vc_copylineYUYV}, - { RGBA, RGB, (decoder_t) vc_copylineRGBAtoRGB}, - { RGB, RGBA, vc_copylineRGBtoRGBA}, - { DPX10, RGBA, vc_copylineDPX10toRGBA}, - { DPX10, RGB, (decoder_t) vc_copylineDPX10toRGB}, - { RGB, UYVY, (decoder_t) vc_copylineRGBtoUYVY}, - { BGR, UYVY, (decoder_t) vc_copylineBGRtoUYVY}, - { BGR, RGB, (decoder_t) vc_copylineBGRtoRGB}, - { (codec_t) 0, (codec_t) 0, NULL } -}; - /** * This struct specifies alias FourCC used for another FourCC */ @@ -1270,38 +1249,38 @@ vc_copylineDPX10toRGB(unsigned char *dst, const unsigned char *src, int dst_len) } } +struct decoder_item { + decoder_t decoder; + codec_t in; + codec_t out; + bool slow; +}; + +const static struct decoder_item decoders[] = { + { (decoder_t) vc_copylineDVS10, DVS10, UYVY, false }, + { (decoder_t) vc_copylinev210, v210, UYVY, false }, + { (decoder_t) vc_copylineYUYV, YUYV, UYVY, false }, + { (decoder_t) vc_copyliner10k, R10k, RGBA, false }, + { vc_copylineRGBA, RGBA, RGBA, false }, + { (decoder_t) vc_copylineDVS10toV210, DVS10, v210, false }, + { (decoder_t) vc_copylineRGBAtoRGB, RGBA, RGB, false }, + { (decoder_t) vc_copylineRGBtoRGBA, RGB, RGBA, false }, + { (decoder_t) vc_copylineRGBtoUYVY, RGB, UYVY, true }, + { (decoder_t) vc_copylineUYVYtoRGB, UYVY, RGB, true }, + { (decoder_t) vc_copylineBGRtoUYVY, BGR, UYVY, true }, + { (decoder_t) vc_copylineRGBAtoUYVY, RGBA, UYVY, true }, + { (decoder_t) vc_copylineBGRtoRGB, BGR, RGB, false }, + { (decoder_t) vc_copylineDPX10toRGBA, DPX10, RGBA, false }, + { (decoder_t) vc_copylineDPX10toRGB, DPX10, RGB, false }, + { vc_copylineRGB, RGB, RGB, false }, +}; + /** * Returns line decoder for specifiedn input and output codec. */ decoder_t get_decoder_from_to(codec_t in, codec_t out, bool slow) { - struct item { - decoder_t decoder; - codec_t in; - codec_t out; - bool slow; - }; - - struct item decoders[] = { - { (decoder_t) vc_copylineDVS10, DVS10, UYVY, false }, - { (decoder_t) vc_copylinev210, v210, UYVY, false }, - { (decoder_t) vc_copylineYUYV, YUYV, UYVY, false }, - { (decoder_t) vc_copyliner10k, R10k, RGBA, false }, - { vc_copylineRGBA, RGBA, RGBA, false }, - { (decoder_t) vc_copylineDVS10toV210, DVS10, v210, false }, - { (decoder_t) vc_copylineRGBAtoRGB, RGBA, RGB, false }, - { (decoder_t) vc_copylineRGBtoRGBA, RGB, RGBA, false }, - { (decoder_t) vc_copylineRGBtoUYVY, RGB, UYVY, true }, - { (decoder_t) vc_copylineUYVYtoRGB, UYVY, RGB, true }, - { (decoder_t) vc_copylineBGRtoUYVY, BGR, UYVY, true }, - { (decoder_t) vc_copylineRGBAtoUYVY, RGBA, UYVY, true }, - { (decoder_t) vc_copylineBGRtoRGB, BGR, RGB, false }, - { (decoder_t) vc_copylineDPX10toRGBA, DPX10, RGBA, false }, - { (decoder_t) vc_copylineDPX10toRGB, DPX10, RGB, false }, - { vc_copylineRGB, RGB, RGB, false }, - }; - - for (unsigned int i = 0; i < sizeof(decoders)/sizeof(struct item); ++i) { + for (unsigned int i = 0; i < sizeof(decoders)/sizeof(struct decoder_item); ++i) { if (decoders[i].in == in && decoders[i].out == out && (decoders[i].slow == false || slow == true)) { return decoders[i].decoder; diff --git a/src/video_codec.h b/src/video_codec.h index 0d2f78cc5..59ea3507c 100644 --- a/src/video_codec.h +++ b/src/video_codec.h @@ -65,16 +65,6 @@ extern "C" { typedef void (*decoder_t)(unsigned char *dst, const unsigned char *src, int dst_len, int rshift, int gshift, int bshift); -/** Defines decoder from one pixel format to another */ -struct line_decode_from_to { - codec_t from; ///< source pixel format - codec_t to; ///< destination pixel format - decoder_t line_decoder; ///< decoding function -}; - -/** @brief 0-terminated list of available supported pixelformat decoders */ -extern const struct line_decode_from_to line_decoders[]; /* defined int .c */ - /** Prints list of suppored codecs for video module * @deprecated Individual modules should print list of supported codecs by itself. */