mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
fftools/textformat/avtextformat: Move avtext_print_integers to ffprobe.c
This is its only user and because this function is so specialised
it is very likely to stay that way. So move it back to ffprobe.c
(where it already was before d7a3f68fea).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -452,6 +452,30 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
|
||||
#define print_duration_ts(k, v) avtext_print_ts(tfc, k, v, 1)
|
||||
#define print_val(k, v, u) avtext_print_unit_integer(tfc, k, v, u)
|
||||
|
||||
static void print_integers(AVTextFormatContext *tfc, const char *key,
|
||||
const void *data, int size, const char *format,
|
||||
int columns, int bytes, int offset_add)
|
||||
{
|
||||
AVBPrint bp;
|
||||
unsigned offset = 0;
|
||||
|
||||
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
|
||||
av_bprint_chars(&bp, '\n', 1);
|
||||
while (size) {
|
||||
av_bprintf(&bp, "%08x: ", offset);
|
||||
for (int i = 0, l = FFMIN(size, columns); i < l; i++) {
|
||||
if (bytes == 1) av_bprintf(&bp, format, *(const uint8_t*)data);
|
||||
else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
|
||||
else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
|
||||
data = (const char*)data + bytes;
|
||||
size--;
|
||||
}
|
||||
av_bprint_chars(&bp, '\n', 1);
|
||||
offset += offset_add;
|
||||
}
|
||||
avtext_print_string(tfc, key, bp.str, 0);
|
||||
}
|
||||
|
||||
#define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n) \
|
||||
{ \
|
||||
ret = av_reallocp_array(&(ptr), (new_n), sizeof(*(ptr))); \
|
||||
@@ -483,7 +507,7 @@ static void print_displaymatrix(AVTextFormatContext *tfc, const int32_t matrix[9
|
||||
double rotation = av_display_rotation_get(matrix);
|
||||
if (isnan(rotation))
|
||||
rotation = 0;
|
||||
avtext_print_integers(tfc, "displaymatrix", (void*)matrix, 9, " %11d", 3, 4, 1);
|
||||
print_integers(tfc, "displaymatrix", matrix, 9, " %11d", 3, 4, 1);
|
||||
print_int("rotation", rotation);
|
||||
}
|
||||
|
||||
|
||||
@@ -558,34 +558,6 @@ void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key,
|
||||
avtext_print_string(tctx, key, buf, 0);
|
||||
}
|
||||
|
||||
void avtext_print_integers(AVTextFormatContext *tctx, const char *key,
|
||||
uint8_t *data, int size, const char *format,
|
||||
int columns, int bytes, int offset_add)
|
||||
{
|
||||
AVBPrint bp;
|
||||
unsigned offset = 0;
|
||||
|
||||
if (!key || !data || !format || columns <= 0 || bytes <= 0)
|
||||
return;
|
||||
|
||||
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
|
||||
av_bprintf(&bp, "\n");
|
||||
while (size) {
|
||||
av_bprintf(&bp, "%08x: ", offset);
|
||||
for (int i = 0, l = FFMIN(size, columns); i < l; i++) {
|
||||
if (bytes == 1) av_bprintf(&bp, format, *data);
|
||||
else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
|
||||
else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
|
||||
data += bytes;
|
||||
size--;
|
||||
}
|
||||
av_bprintf(&bp, "\n");
|
||||
offset += offset_add;
|
||||
}
|
||||
avtext_print_string(tctx, key, bp.str, 0);
|
||||
av_bprint_finalize(&bp, NULL);
|
||||
}
|
||||
|
||||
static const char *writercontext_get_writer_name(void *p)
|
||||
{
|
||||
AVTextWriterContext *wctx = p;
|
||||
|
||||
@@ -190,9 +190,6 @@ void avtext_print_data(AVTextFormatContext *tctx, const char *key, const uint8_t
|
||||
|
||||
void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size);
|
||||
|
||||
void avtext_print_integers(AVTextFormatContext *tctx, const char *key, uint8_t *data, int size,
|
||||
const char *format, int columns, int bytes, int offset_add);
|
||||
|
||||
const AVTextFormatter *avtext_get_formatter_by_name(const char *name);
|
||||
|
||||
extern const AVTextFormatter avtextformatter_default;
|
||||
|
||||
Reference in New Issue
Block a user