Skip to content

Commit fcdb58e

Browse files
committed
vdec/lavc: get_priority - delegate to from_lavc
Since the pixfmt conversion is responsibility of from_lavc conversion, delegate the get_priority query there (after we know that we can decode codec).
1 parent 22ec0a9 commit fcdb58e

File tree

3 files changed

+36
-25
lines changed

3 files changed

+36
-25
lines changed

src/libavcodec/from_lavc_vid_conv.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#include "utils/worker.h" // task_run_parallel
7676
#include "video.h"
7777
#include "video_codec.h"
78+
#include "video_decompress.h" // for VDEC_PRIO_*
7879

7980
#ifdef __SSE3__
8081
#include "pmmintrin.h"
@@ -3158,6 +3159,30 @@ av_to_uv_convert(const av_to_uv_convert_t *convert,
31583159
task_run_parallel(convert_task, cpu_count, d, sizeof d[0], NULL);
31593160
}
31603161

3162+
int
3163+
from_lavc_pf_priority(struct pixfmt_desc internal, codec_t ugc)
3164+
{
3165+
switch (ugc) {
3166+
case UYVY:
3167+
case VUYA:
3168+
case RG48:
3169+
case RGB:
3170+
case RGBA:
3171+
case R10k:
3172+
case R12L:
3173+
case v210:
3174+
case Y416:
3175+
break;
3176+
default:
3177+
return VDEC_PRIO_NA;
3178+
}
3179+
if (internal.depth == 0) { // unspecified internal format
3180+
return VDEC_PRIO_LOW;
3181+
}
3182+
return codec_is_a_rgb(ugc) == internal.rgb ? VDEC_PRIO_NORMAL
3183+
: VDEC_PRIO_NOT_PREFERRED;
3184+
}
3185+
31613186
#pragma GCC diagnostic pop
31623187

31633188
/* vi: set expandtab sw=8: */

src/libavcodec/from_lavc_vid_conv.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @sa to_lavc_vid_conv.h
77
*/
88
/*
9-
* Copyright (c) 2013-2023 CESNET, z. s. p. o.
9+
* Copyright (c) 2013-2025 CESNET
1010
* All rights reserved.
1111
*
1212
* Redistribution and use in source and binary forms, with or without
@@ -47,11 +47,14 @@
4747
#include <stdbool.h>
4848
#endif
4949

50+
#include "types.h" // for codec_t
51+
5052
#ifdef __cplusplus
5153
extern "C" {
5254
#endif
5355

5456
struct av_to_uv_convert_state;
57+
struct pixfmt_desc;
5558
typedef struct av_to_uv_convert_state av_to_uv_convert_t;
5659

5760
av_to_uv_convert_t *get_av_to_uv_conversion(int av_codec, codec_t uv_codec);
@@ -63,6 +66,7 @@ codec_t get_best_ug_codec_to_av(const enum AVPixelFormat *fmt, bool use_hwaccel)
6366
enum AVPixelFormat lavd_get_av_to_ug_codec(const enum AVPixelFormat *fmt, codec_t c, bool use_hwaccel);
6467
enum AVPixelFormat pick_av_convertible_to_ug(codec_t color_spec,
6568
av_to_uv_convert_t **av_conv);
69+
int from_lavc_pf_priority(struct pixfmt_desc internal, codec_t ugc);
6670

6771
#ifdef __cplusplus
6872
}

src/video_decompress/libavcodec.c

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,10 +1192,6 @@ static void libavcodec_decompress_done(void *state)
11921192
free(s);
11931193
}
11941194

1195-
/**
1196-
* @todo
1197-
* This should be take into account existing conversions.
1198-
*/
11991195
static int libavcodec_decompress_get_priority(codec_t compression, struct pixfmt_desc internal, codec_t ugc) {
12001196
if (internal.accel_type != HWACCEL_NONE &&
12011197
hw_accel_to_ug_pixfmt(internal.accel_type) == ugc) {
@@ -1220,27 +1216,13 @@ static int libavcodec_decompress_get_priority(codec_t compression, struct pixfmt
12201216
return VDEC_PRIO_NA;
12211217
}
12221218

1223-
switch (ugc) {
1224-
case VIDEO_CODEC_NONE:
1225-
return VDEC_PRIO_PROBE_LO; // for probe
1226-
case UYVY:
1227-
case VUYA:
1228-
case RG48:
1229-
case RGB:
1230-
case RGBA:
1231-
case R10k:
1232-
case R12L:
1233-
case v210:
1234-
case Y416:
1235-
break;
1236-
default:
1237-
return VDEC_PRIO_NA;
1219+
if (ugc == VC_NONE) { // probe
1220+
return VDEC_PRIO_PROBE_LO;
12381221
}
1239-
if (internal.depth == 0) { // unspecified internal format
1240-
return VDEC_PRIO_LOW;
1241-
}
1242-
return codec_is_a_rgb(ugc) == internal.rgb ? VDEC_PRIO_NORMAL
1243-
: VDEC_PRIO_NOT_PREFERRED;
1222+
1223+
// now we assume that will be able to decompress the stream so we
1224+
// check if we are able to convert to output codec ugc
1225+
return from_lavc_pf_priority(internal, ugc);
12441226
}
12451227

12461228
static const struct video_decompress_info libavcodec_info = {

0 commit comments

Comments
 (0)