avformat: add AVFormatContext.name

Analog to AVFilterContext. May be used to set a custom logging name to
disambiguate multiple AVFormatContext instances in the logs.
This commit is contained in:
Niklas Haas
2026-01-31 11:50:34 +01:00
committed by Niklas Haas
parent 9bfa1635ae
commit f2b13f783a
5 changed files with 13 additions and 3 deletions

View File

@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
API changes, most recent first:
2026-02-xx - xxxxxxxxxx - lavf 62.9.100 - avformat.h
Add AVFormatContext.name.
2026-01-xx - xxxxxxxxxx - lavu 60.24.100 - hwcontext_d3d11va.h
Add BindFlags and MiscFlags to AVD3D11VADeviceContext

View File

@@ -190,6 +190,7 @@ void avformat_free_context(AVFormatContext *s)
if (s->iformat)
ff_flush_packet_queue(s);
av_freep(&s->url);
av_freep(&s->name);
av_free(s);
}

View File

@@ -1884,6 +1884,11 @@ typedef struct AVFormatContext {
* @see skip_estimate_duration_from_pts
*/
int64_t duration_probesize;
/**
* Name of this format context, only used for logging purposes.
*/
char *name;
} AVFormatContext;
/**

View File

@@ -45,7 +45,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
static const char* format_to_name(void* ptr)
{
AVFormatContext* fc = (AVFormatContext*) ptr;
if(fc->iformat) return fc->iformat->name;
if (fc->name) return fc->name;
else if(fc->iformat) return fc->iformat->name;
else if(fc->oformat) return fc->oformat->name;
else return fc->av_class->class_name;
}

View File

@@ -31,8 +31,8 @@
#include "version_major.h"
#define LIBAVFORMAT_VERSION_MINOR 8
#define LIBAVFORMAT_VERSION_MICRO 102
#define LIBAVFORMAT_VERSION_MINOR 9
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \