Skip to content

Commit 13c2e6a

Browse files
committed
vdec/lavc: accept corrupted to separate fn
+ print the value in VERBOSE (for all video decoders)
1 parent 6d2ab24 commit 13c2e6a

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/rtp/video_decoders.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,8 @@ static bool reconfigure_decoder(struct state_video_decoder *decoder,
13841384
DECOMPRESS_PROPERTY_ACCEPTS_CORRUPTED_FRAME,
13851385
&res, &size);
13861386
decoder->accepts_corrupted_frame = ret && res;
1387+
MSG(VERBOSE, "Decoder accepts corrupted frames: %d",
1388+
(int) decoder->accepts_corrupted_frame);
13871389
}
13881390

13891391
// Pass metadata to receiver thread (it can tweak parameters)

src/video_decompress/libavcodec.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,22 @@ ADD_TO_PARAM("lavd-accept-corrupted",
11451145
"* lavd-accept-corrupted[=no]\n"
11461146
" Pass corrupted frames to decoder. If decoder isn't error-resilient,\n"
11471147
" may crash! Use \"no\" to disable even if enabled by default.\n");
1148+
static bool
1149+
accept_corrupted(const AVCodecContext *ctx)
1150+
{
1151+
const char *const val = get_commandline_param("lavd-accept-corrupted");
1152+
if (val != NULL) {
1153+
return strcmp(val, "no") != 0;
1154+
}
1155+
if (ctx == NULL) {
1156+
return false;
1157+
}
1158+
if (ctx->codec->id == AV_CODEC_ID_H264) {
1159+
return true;
1160+
}
1161+
return false;
1162+
}
1163+
11481164
static int libavcodec_decompress_get_property(void *state, int property, void *val, size_t *len)
11491165
{
11501166
struct state_libavcodec_decompress *s =
@@ -1156,15 +1172,7 @@ static int libavcodec_decompress_get_property(void *state, int property, void *v
11561172
if (*len < sizeof(int)) {
11571173
return false;
11581174
}
1159-
*(int *) val = false;
1160-
if (s->codec_ctx && strcmp(s->codec_ctx->codec->name, "h264") == 0) {
1161-
*(int *) val = true;
1162-
}
1163-
if (get_commandline_param("lavd-accept-corrupted")) {
1164-
*(int *) val =
1165-
strcmp(get_commandline_param("lavd-accept-corrupted"), "no") != 0;
1166-
}
1167-
1175+
*(int *) val = accept_corrupted(s->codec_ctx);
11681176
*len = sizeof(int);
11691177
ret = true;
11701178
break;

0 commit comments

Comments
 (0)