From cde6e7bb7851e8a22c1b9ffbe02fb17ffbf4d4ed Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 31 Jan 2014 16:45:13 +0100 Subject: [PATCH] Removed 2vuy and DVS8 codec types --- src/rtp/video_decoders.cpp | 27 +++------------------------ src/types.h | 2 -- src/video_capture/decklink.cpp | 13 +++++-------- src/video_capture/dvs.c | 2 -- src/video_capture/quicktime.c | 16 +++++++++++----- src/video_capture/testcard.c | 2 +- src/video_capture/testcard2.c | 2 +- src/video_codec.c | 15 ++++++--------- src/video_compress/dxt_glsl.cpp | 2 -- src/video_compress/jpeg.cpp | 2 -- src/video_compress/libavcodec.c | 2 -- src/video_display/quicktime.c | 11 +++++++++-- 12 files changed, 36 insertions(+), 60 deletions(-) diff --git a/src/rtp/video_decoders.cpp b/src/rtp/video_decoders.cpp index 527e30737..f726edec8 100644 --- a/src/rtp/video_decoders.cpp +++ b/src/rtp/video_decoders.cpp @@ -789,12 +789,6 @@ bool video_decoder_register_display(struct state_video_decoder *decoder, struct return false; } - /* next check if we didn't receive alias for UYVY */ - for(i = 0; i < (int) decoder->native_count; ++i) { - assert(decoder->native_codecs[i] != Vuy2 && - decoder->native_codecs[i] != DVS8); - } - if(decoder->postprocess) { codec_t postprocess_supported_codecs[20]; size_t len = sizeof(postprocess_supported_codecs); @@ -981,17 +975,6 @@ static int find_best_decompress(codec_t in_codec, codec_t out_codec, return best_priority; } -/** - * This helper function removes redundancy in codec_t - triplicity of 8-bit YCbCr. - */ -static codec_t codec_remove_aliases(codec_t codec) -{ - if(codec == DVS8 || codec == Vuy2) - return UYVY; - else - return codec; -} - /** * @brief Finds (best) decompress module for specified compression. * @@ -1009,8 +992,6 @@ static codec_t codec_remove_aliases(codec_t codec) bool init_decompress(codec_t in_codec, codec_t out_codec, struct state_decompress **state, int state_count) { - out_codec = codec_remove_aliases(out_codec); - int prio_max = 1000; int prio_min = 0; int prio_cur; @@ -1054,7 +1035,7 @@ static codec_t choose_codec_and_decoder(struct state_video_decoder *decoder, str /* first check if the codec is natively supported */ for(native = 0u; native < decoder->native_count; ++native) { - out_codec = codec_remove_aliases(decoder->native_codecs[native]); + out_codec = decoder->native_codecs[native]; if(desc.color_spec == out_codec) { if((out_codec == DXT1 || out_codec == DXT1_YUV || out_codec == DXT5) @@ -1076,7 +1057,7 @@ static codec_t choose_codec_and_decoder(struct state_video_decoder *decoder, str ++trans) { for(native = 0; native < decoder->native_count; ++native) { - out_codec = codec_remove_aliases(decoder->native_codecs[native]); + out_codec = decoder->native_codecs[native]; if(desc.color_spec == line_decoders[trans].from && out_codec == line_decoders[trans].to) { @@ -1094,7 +1075,7 @@ after_linedecoder_lookup: if(*decode_line == NULL) { for(native = 0; native < decoder->native_count; ++native) { - out_codec = codec_remove_aliases(decoder->native_codecs[native]); + 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], @@ -1201,8 +1182,6 @@ static bool reconfigure_decoder(struct state_video_decoder *decoder, desc.tile_count = get_video_mode_tiles_x(decoder->video_mode) * get_video_mode_tiles_y(decoder->video_mode); - desc.color_spec = codec_remove_aliases(desc.color_spec); - out_codec = choose_codec_and_decoder(decoder, desc, &decode_line); if(out_codec == (codec_t) -1) return false; diff --git a/src/types.h b/src/types.h index fece75917..d4f618030 100644 --- a/src/types.h +++ b/src/types.h @@ -60,8 +60,6 @@ typedef enum { RGBA, ///< RGBA 8-bit UYVY, ///< YCbCr 422 8-bit - Cb Y0 Cr Y1 YUYV, ///< YCbCr 422 8-bit - Y0 Cb Y1 Cr - Vuy2, ///< YCbCr 422 8-bit (same as UYVY) - DVS8, ///< YCbCr 422 8-bit (same as UYVY) R10k, ///< RGB 10-bit (also know as r210) v210, ///< YCbCr 422 10-bit DVS10, ///< DVS 10-bit format diff --git a/src/video_capture/decklink.cpp b/src/video_capture/decklink.cpp index c82a4aade..03b60ba74 100644 --- a/src/video_capture/decklink.cpp +++ b/src/video_capture/decklink.cpp @@ -201,7 +201,7 @@ public: pthread_mutex_lock(&(s->lock)); switch(flags) { case bmdDetectedVideoInputYCbCr422: - codec = Vuy2; + codec = UYVY; break; case bmdDetectedVideoInputRGB444: codec = RGBA; @@ -486,7 +486,7 @@ decklink_help() } else { printf("\n\n"); printf("Available Colorspaces:\n"); - printf("\t2vuy\n"); + printf("\tUYVY\n"); printf("\tv210\n"); printf("\tRGBA\n"); printf("\tR10k\n"); @@ -515,7 +515,7 @@ settings_init(void *state, char *fmt) int i; for(i=0; codec_info[i].name != NULL; i++) { - if(codec_info[i].codec == Vuy2) { + if(codec_info[i].codec == UYVY) { s->c_info = &codec_info[i]; break; } @@ -559,7 +559,7 @@ settings_init(void *state, char *fmt) if(!tmp) { int i; for(i=0; codec_info[i].name != NULL; i++) { - if(codec_info[i].codec == Vuy2) { + if(codec_info[i].codec == UYVY) { s->c_info = &codec_info[i]; break; } @@ -651,7 +651,7 @@ static HRESULT set_display_mode_properties(struct vidcap_decklink_state *s, stru case RGBA: *pf = bmdFormat8BitBGRA; break; - case Vuy2: + case UYVY: *pf = bmdFormat8BitYUV; break; case R10k: @@ -670,9 +670,6 @@ static HRESULT set_display_mode_properties(struct vidcap_decklink_state *s, stru tile->width = displayMode->GetWidth(); tile->height = displayMode->GetHeight(); s->frame->color_spec = s->c_info->codec; - if(s->frame->color_spec == Vuy2 || s->frame->color_spec == DVS8) { - s->frame->color_spec = UYVY; - } displayMode->GetFrameRate(&frameRateDuration, &frameRateScale); s->frame->fps = (double)frameRateScale / (double)frameRateDuration; diff --git a/src/video_capture/dvs.c b/src/video_capture/dvs.c index b690cbf5c..50a71add9 100644 --- a/src/video_capture/dvs.c +++ b/src/video_capture/dvs.c @@ -336,8 +336,6 @@ void *vidcap_dvs_init(const struct vidcap_params *params) case DVS10: s->hd_video_mode |= SV_MODE_COLOR_YUV422 | SV_MODE_NBIT_10BDVS; break; - case DVS8: - case Vuy2: case UYVY: s->hd_video_mode |= SV_MODE_COLOR_YUV422; break; diff --git a/src/video_capture/quicktime.c b/src/video_capture/quicktime.c index d70713700..8da334b51 100644 --- a/src/video_capture/quicktime.c +++ b/src/video_capture/quicktime.c @@ -74,10 +74,9 @@ static struct { uint32_t qt_fourcc; codec_t ug_codec; } codec_mapping[] = { - {'2' << 24 | 'v' << 16 | 'u' << 8 | 'y', Vuy2}, // would map to UYVY otherwise - // but codec with yuv2 FourCC - // is different (handled specially - // in this module) + {'2' << 24 | 'v' << 16 | 'u' << 8 | 'y', UYVY}, + {'y' << 24 | 'u' << 16 | 'v' << 8 | '2', UYVY}, + {'y' << 24 | 'u' << 16 | 'V' << 8 | '2', UYVY}, {'j' << 24 | 'p' << 16 | 'e' << 8 | 'g', MJPG}, {'a' << 24 | 'v' << 16 | 'c' << 8 | '1', H264}, {0, 0xffffffff} @@ -130,6 +129,8 @@ struct qt_grabber_state { pthread_cond_t boss_cv; volatile bool should_exit; + + bool translate_yuv2; }; void * vidcap_quicktime_thread(void *state); @@ -821,6 +822,11 @@ static int qt_open_grabber(struct qt_grabber_state *s, char *fmt) } s->frame->color_spec = get_color_spec(pixfmt); + // thiw is a workaround - codec identified by exactly this FourCC seems to have + // different semantics than ordinary UYVY + if (pixfmt == ('2' | 'v' << 8 | 'u' << 16 | 'y' << 24)) { + s->translate_yuv2 = true; + } if (s->frame->color_spec == 0xffffffff) { fprintf(stderr, "[QuickTime] Cannot find UltraGrid codec matching: %c%c%c%c!\n", @@ -1111,7 +1117,7 @@ struct video_frame *vidcap_quicktime_grab(void *state, struct audio_frame **audi // Mac 10.7 seems to change semantics for codec identified with 'yuv2' FourCC, // which is mapped to our UYVY. This simply makes it correct. - if(s->frame->color_spec == UYVY) { + if (s->translate_yuv2) { for(int i = 0; i < s->frame->tiles->data_len; i += 4) { int a = s->frame->tiles[0].data[i]; int b = s->frame->tiles[0].data[i + 1]; diff --git a/src/video_capture/testcard.c b/src/video_capture/testcard.c index 5deaeca15..368ffb13c 100644 --- a/src/video_capture/testcard.c +++ b/src/video_capture/testcard.c @@ -436,7 +436,7 @@ void *vidcap_testcard_init(const struct vidcap_params *params) } } s->data = s->pixmap.data; - if (codec == UYVY || codec == v210 || codec == Vuy2) { + if (codec == UYVY || codec == v210) { rgb2yuv422((unsigned char *) s->data, aligned_x, vf_get_tile(s->frame, 0)->height); } diff --git a/src/video_capture/testcard2.c b/src/video_capture/testcard2.c index 603a05d51..8c0d72006 100644 --- a/src/video_capture/testcard2.c +++ b/src/video_capture/testcard2.c @@ -425,7 +425,7 @@ void * vidcap_testcard2_thread(void *arg) SDL_FreeSurface(text); #endif - if (s->frame->color_spec == UYVY || s->frame->color_spec == v210 || s->frame->color_spec == Vuy2) { + if (s->frame->color_spec == UYVY || s->frame->color_spec == v210) { rgb2yuv422((unsigned char *) copy->pixels, s->aligned_x, s->tile->height); } diff --git a/src/video_codec.c b/src/video_codec.c index 698b7fdc6..e3a1eed0d 100644 --- a/src/video_codec.c +++ b/src/video_codec.c @@ -88,8 +88,6 @@ const struct codec_info_t codec_info[] = { [RGBA] = {RGBA, "RGBA", to_fourcc('R','G','B','A'), 1, 4.0, 4, TRUE, FALSE, FALSE, "rgba"}, [UYVY] = {UYVY, "UYVY", to_fourcc('y','u','v','2'), 2, 2, 4, FALSE, FALSE, FALSE, "yuv"}, [YUYV] = {YUYV, "YUYV", to_fourcc('Y','U','Y','V'), 2, 2, 4, FALSE, FALSE, FALSE, "yuv"}, - [Vuy2] = {Vuy2, "2vuy", to_fourcc('y','u','V','2'), 2, 2, 4, FALSE, FALSE, FALSE, "yuv"}, - [DVS8] = {DVS8, "DVS8", to_fourcc('d','v','s','8'), 2, 2, 4, FALSE, FALSE, FALSE, "yuv"}, [R10k] = {R10k, "R10k", to_fourcc('R','1','0','k'), 64, 4, 4, TRUE, FALSE, FALSE, "r10k"}, [v210] = {v210, "v210", to_fourcc('v','2','1','0'), 48, 8.0 / 3.0, 16, FALSE, FALSE, FALSE, "v210"}, [DVS10] = {DVS10, "DVS10", to_fourcc('D','S','1','0'), 48, 8.0 / 3.0, 4, FALSE, FALSE, FALSE, "dvs10"}, @@ -107,9 +105,6 @@ const struct codec_info_t codec_info[] = { {(codec_t) 0, NULL, 0, 0, 0.0, 0, FALSE, FALSE, FALSE, NULL} }; -/* take care that UYVY is alias for both 2vuy and dvs8, do not use - * the further two and refer only to UYVY!! */ - /* 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. */ @@ -148,9 +143,13 @@ const struct alternate_fourcc fourcc_aliases[] = { // following ones are rather for further compatibility (proposed codecs rename) {to_fourcc('U', 'Y', 'V', 'Y'), to_fourcc('2', 'v', 'u', 'y')}, {to_fourcc('M', 'J', 'P', 'G'), to_fourcc('J', 'P', 'E', 'G')}, - {to_fourcc('D', 'V', 'S', '8'), to_fourcc('d', 'v', 's', '8')}, - {to_fourcc('2', 'V', 'u', 'y'), to_fourcc('y', 'u', 'V', '2')}, + + {to_fourcc('D', 'V', 'S', '8'), to_fourcc('y', 'u', 'v', '2')}, + {to_fourcc('2', 'V', 'u', 'y'), to_fourcc('y', 'u', 'v', '2')}, {to_fourcc('2', 'v', 'u', 'y'), to_fourcc('y', 'u', 'v', '2')}, + {to_fourcc('d', 'v', 's', '8'), to_fourcc('y', 'u', 'v', '2')}, + {to_fourcc('d', 'v', 's', '8'), to_fourcc('y', 'u', 'v', '2')}, + {to_fourcc('U', 'Y', 'V', 'Y'), to_fourcc('y', 'u', 'v', '2')}, {0,0} }; @@ -163,8 +162,6 @@ void show_codec_help(char *module) printf("\t\t\t'RGBA' - Red Green Blue Alpha 32bit\n"); printf("\t\t\t'RGB' - Red Green Blue 24bit\n"); printf("\t\t\t'UYVY' - YUV 4:2:2\n"); - printf("\t\t\t'2vuy' - YUV 4:2:2\n"); - printf("\t\t\t'DVS8' - Centaurus 8bit YUV 4:2:2\n"); printf("\t\t10bits\n"); if (strcmp(module, "dvs") != 0) { diff --git a/src/video_compress/dxt_glsl.cpp b/src/video_compress/dxt_glsl.cpp index 06f290b45..81b2b8915 100644 --- a/src/video_compress/dxt_glsl.cpp +++ b/src/video_compress/dxt_glsl.cpp @@ -112,8 +112,6 @@ static int configure_with(struct state_video_compress_rtdxt *s, struct video_fra format = DXT_FORMAT_YUV422; break; case UYVY: - case Vuy2: - case DVS8: s->decoder = (decoder_t) memcpy; format = DXT_FORMAT_YUV422; break; diff --git a/src/video_compress/jpeg.cpp b/src/video_compress/jpeg.cpp index 1a1d5bd6f..41bbc8a54 100644 --- a/src/video_compress/jpeg.cpp +++ b/src/video_compress/jpeg.cpp @@ -127,8 +127,6 @@ static int configure_with(struct state_video_compress_jpeg *s, struct video_fram s->rgb = FALSE; break; case UYVY: - case Vuy2: - case DVS8: s->decoder = (decoder_t) memcpy; s->rgb = FALSE; break; diff --git a/src/video_compress/libavcodec.c b/src/video_compress/libavcodec.c index 904469ada..1fed510b8 100644 --- a/src/video_compress/libavcodec.c +++ b/src/video_compress/libavcodec.c @@ -421,8 +421,6 @@ static bool configure_with(struct state_video_compress_libav *s, struct video_de s->codec_ctx->gop_size = 20; /* emit one intra frame every ten frames */ s->codec_ctx->max_b_frames = 0; switch(desc.color_spec) { - case Vuy2: - case DVS8: case UYVY: s->decoder = (decoder_t) memcpy; break; diff --git a/src/video_display/quicktime.c b/src/video_display/quicktime.c index 3a131f565..83f22209e 100644 --- a/src/video_display/quicktime.c +++ b/src/video_display/quicktime.c @@ -301,6 +301,8 @@ static void reconf_common(struct state_quicktime *s) sizeof(ImageDescription); if (s->cinfo->codec == v210) (**(ImageDescriptionHandle) imageDesc).cType = 'v210'; + else if (s->cinfo->codec == UYVY) + (**(ImageDescriptionHandle) imageDesc).cType = '2vuy'; else (**(ImageDescriptionHandle) imageDesc).cType = s->cinfo->fcc; /* @@ -664,6 +666,12 @@ void *display_quicktime_init(char *fmt, unsigned int flags) EnterMovies(); if(s->mode != 0) { + // QT aliases + if (strcmp(codec_name, "2vuy") == 0 || + strcmp(codec_name, "2Vuy") == 0) { + strcpy(codec_name, "UYVY"); + } + for (i = 0; codec_info[i].name != NULL; i++) { if (strcmp(codec_name, codec_info[i].name) == 0) { s->cinfo = &codec_info[i]; @@ -925,8 +933,7 @@ int display_quicktime_reconfigure(void *state, struct video_desc desc) } } assert(codec_name != NULL); - if(desc.color_spec == UYVY || desc.color_spec == DVS8) /* just aliases for 2vuy, - * but would confuse QT */ + if(desc.color_spec == UYVY) /* QT name for UYVY */ codec_name = "2vuy"; if(s->frame->tiles[0].data != NULL)