Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions fftools/graph/graphprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static inline char *upcase_string(char *dst, size_t dst_size, const char *src)
{
unsigned i;
for (i = 0; src[i] && i < dst_size - 1; i++)
dst[i] = (char)av_toupper(src[i]);
dst[i] = av_toupper(src[i]);
dst[i] = 0;
return dst;
}
Expand Down Expand Up @@ -261,7 +261,7 @@ static void print_link(GraphPrintContext *gpc, AVFilterLink *link)
case AVMEDIA_TYPE_VIDEO:

if (hw_frames_ctx && hw_frames_ctx->data) {
AVHWFramesContext * hwfctx = (AVHWFramesContext *)hw_frames_ctx->data;
AVHWFramesContext *hwfctx = (AVHWFramesContext *)hw_frames_ctx->data;
const AVPixFmtDescriptor *pix_desc_hw = av_pix_fmt_desc_get(hwfctx->format);
const AVPixFmtDescriptor *pix_desc_sw = av_pix_fmt_desc_get(hwfctx->sw_format);
if (pix_desc_hw && pix_desc_sw)
Expand Down Expand Up @@ -498,17 +498,17 @@ static void print_filtergraph_single(GraphPrintContext *gpc, FilterGraph *fg, AV
print_int("input_index", ifilter->index);

if (ifilter->linklabel)
print_str("link_label", (const char*)ifilter->linklabel);
print_str("link_label", ifilter->linklabel);

if (ifilter->filter) {
print_id("filter_id", ifilter->filter->name);
print_str("filter_name", ifilter->filter->filter->name);
}

if (ifilter->linklabel && ifilter->filter)
av_dict_set(&input_map, ifilter->filter->name, (const char *)ifilter->linklabel, 0);
av_dict_set(&input_map, ifilter->filter->name, ifilter->linklabel, 0);
else if (ifilter->input_name && ifilter->filter)
av_dict_set(&input_map, ifilter->filter->name, (const char *)ifilter->input_name, 0);
av_dict_set(&input_map, ifilter->filter->name, ifilter->input_name, 0);

print_str("media_type", av_get_media_type_string(media_type));

Expand All @@ -529,7 +529,7 @@ static void print_filtergraph_single(GraphPrintContext *gpc, FilterGraph *fg, AV
print_str("name", ofilter->output_name);

if (fg->outputs[i]->linklabel)
print_str("link_label", (const char*)fg->outputs[i]->linklabel);
print_str("link_label", fg->outputs[i]->linklabel);

if (ofilter->filter) {
print_id("filter_id", ofilter->filter->name);
Expand Down Expand Up @@ -1069,7 +1069,7 @@ static int print_filtergraphs_priv(FilterGraph **graphs, int nb_graphs, InputFil
goto cleanup;
}

avio_write(avio, (const unsigned char *)target_buf.str, FFMIN(target_buf.len, target_buf.size - 1));
avio_write(avio, target_buf.str, FFMIN(target_buf.len, target_buf.size - 1));

if ((ret = avio_closep(&avio)) < 0)
av_log(NULL, AV_LOG_ERROR, "Error closing graph output file, loss of information possible: %s\n", av_err2str(ret));
Expand Down
6 changes: 3 additions & 3 deletions fftools/resources/resman.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static int decompress_gzip(ResourceManagerContext *ctx, uint8_t *in, unsigned in
memset(&strm, 0, sizeof(strm));

// Allocate output buffer with extra byte for null termination
buf = (uint8_t *)av_mallocz(chunk + 1);
buf = av_mallocz(chunk + 1);
if (!buf) {
av_log(ctx, AV_LOG_ERROR, "Failed to allocate decompression buffer\n");
return AVERROR(ENOMEM);
Expand Down Expand Up @@ -112,7 +112,7 @@ static int decompress_gzip(ResourceManagerContext *ctx, uint8_t *in, unsigned in
buf[*out_len] = 0; // Ensure null termination

inflateEnd(&strm);
*out = (char *)buf;
*out = buf;
return Z_OK;
}
#endif
Expand Down Expand Up @@ -156,7 +156,7 @@ char *ff_resman_get_string(FFResourceId resource_id)
char *out = NULL;
size_t out_len;

int ret = decompress_gzip(ctx, (uint8_t *)resource_definition.data, *resource_definition.data_len, &out, &out_len);
int ret = decompress_gzip(ctx, resource_definition.data, *resource_definition.data_len, &out, &out_len);

if (ret) {
av_log(ctx, AV_LOG_ERROR, "Unable to decompress the resource with ID %d\n", resource_id);
Expand Down
10 changes: 4 additions & 6 deletions fftools/textformat/avtextformat.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -209,8 +207,8 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form

/* validate replace string */
{
const uint8_t *p = (uint8_t *)tctx->string_validation_replacement;
const uint8_t *endp = p + strlen((const char *)p);
const uint8_t *p = tctx->string_validation_replacement;
const uint8_t *endp = p + strlen(p);
while (*p) {
const uint8_t *p0 = p;
int32_t code;
Expand Down Expand Up @@ -313,7 +311,7 @@ void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t va

static inline int validate_string(AVTextFormatContext *tctx, char **dstp, const char *src)
{
const uint8_t *p, *endp, *srcp = (const uint8_t *)src;
const uint8_t *p, *endp, *srcp = src;
AVBPrint dstbuf;
AVBPrint invalid_seq;
int invalid_chars_nb = 0, ret = 0;
Expand Down Expand Up @@ -557,7 +555,7 @@ void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key,
av_hash_init(tctx->hash);
av_hash_update(tctx->hash, data, size);
len = snprintf(buf, sizeof(buf), "%s:", av_hash_get_name(tctx->hash));
av_hash_final_hex(tctx->hash, (uint8_t *)&buf[len], (int)sizeof(buf) - len);
av_hash_final_hex(tctx->hash, &buf[len], (int)sizeof(buf) - len);
avtext_print_string(tctx, key, buf, 0);
}

Expand Down
1 change: 0 additions & 1 deletion fftools/textformat/avtextwriters.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#ifndef FFTOOLS_TEXTFORMAT_AVTEXTWRITERS_H
#define FFTOOLS_TEXTFORMAT_AVTEXTWRITERS_H

#include <stdint.h>
#include "libavformat/avio.h"
#include "libavutil/bprint.h"

Expand Down
78 changes: 38 additions & 40 deletions fftools/textformat/tf_compact.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

#include "avtextformat.h"
Expand Down Expand Up @@ -113,12 +111,12 @@ static const AVOption compact_options[] = {

DEFINE_FORMATTER_CLASS(compact);

static av_cold int compact_init(AVTextFormatContext *wctx)
static av_cold int compact_init(AVTextFormatContext *tctx)
{
CompactContext *compact = wctx->priv;
CompactContext *compact = tctx->priv;

if (strlen(compact->item_sep_str) != 1) {
av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n",
av_log(tctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n",
compact->item_sep_str);
return AVERROR(EINVAL);
}
Expand All @@ -131,41 +129,41 @@ static av_cold int compact_init(AVTextFormatContext *wctx)
} else if (!strcmp(compact->escape_mode_str, "csv" )) {
compact->escape_str = csv_escape_str;
} else {
av_log(wctx, AV_LOG_ERROR, "Unknown escape mode '%s'\n", compact->escape_mode_str);
av_log(tctx, AV_LOG_ERROR, "Unknown escape mode '%s'\n", compact->escape_mode_str);
return AVERROR(EINVAL);
}

return 0;
}

static void compact_print_section_header(AVTextFormatContext *wctx, const void *data)
static void compact_print_section_header(AVTextFormatContext *tctx, const void *data)
{
CompactContext *compact = wctx->priv;
const AVTextFormatSection *section = tf_get_section(wctx, wctx->level);
const AVTextFormatSection *parent_section = tf_get_parent_section(wctx, wctx->level);
CompactContext *compact = tctx->priv;
const AVTextFormatSection *section = tf_get_section(tctx, tctx->level);
const AVTextFormatSection *parent_section = tf_get_parent_section(tctx, tctx->level);

if (!section)
return;

compact->terminate_line[wctx->level] = 1;
compact->has_nested_elems[wctx->level] = 0;
compact->terminate_line[tctx->level] = 1;
compact->has_nested_elems[tctx->level] = 0;

av_bprint_clear(&wctx->section_pbuf[wctx->level]);
av_bprint_clear(&tctx->section_pbuf[tctx->level]);
if (parent_section &&
(section->flags & AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE ||
(!(section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY) &&
!(parent_section->flags & (AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER | AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY))))) {

/* define a prefix for elements not contained in an array or
in a wrapper, or for array elements with a type */
const char *element_name = (char *)av_x_if_null(section->element_name, section->name);
AVBPrint *section_pbuf = &wctx->section_pbuf[wctx->level];
const char *element_name = av_x_if_null(section->element_name, section->name);
AVBPrint *section_pbuf = &tctx->section_pbuf[tctx->level];

compact->nested_section[wctx->level] = 1;
compact->has_nested_elems[wctx->level - 1] = 1;
compact->nested_section[tctx->level] = 1;
compact->has_nested_elems[tctx->level - 1] = 1;

av_bprintf(section_pbuf, "%s%s",
wctx->section_pbuf[wctx->level - 1].str, element_name);
tctx->section_pbuf[tctx->level - 1].str, element_name);

if (section->flags & AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE) {
// add /TYPE to prefix
Expand All @@ -182,58 +180,58 @@ static void compact_print_section_header(AVTextFormatContext *wctx, const void *
}
av_bprint_chars(section_pbuf, ':', 1);

wctx->nb_item[wctx->level] = wctx->nb_item[wctx->level - 1];
tctx->nb_item[tctx->level] = tctx->nb_item[tctx->level - 1];
} else {
if (parent_section && !(parent_section->flags & (AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER | AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY)) &&
wctx->level && wctx->nb_item[wctx->level - 1])
writer_w8(wctx, compact->item_sep);
tctx->level && tctx->nb_item[tctx->level - 1])
writer_w8(tctx, compact->item_sep);
if (compact->print_section &&
!(section->flags & (AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER | AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY)))
writer_printf(wctx, "%s%c", section->name, compact->item_sep);
writer_printf(tctx, "%s%c", section->name, compact->item_sep);
}
}

static void compact_print_section_footer(AVTextFormatContext *wctx)
static void compact_print_section_footer(AVTextFormatContext *tctx)
{
CompactContext *compact = wctx->priv;
const AVTextFormatSection *section = tf_get_section(wctx, wctx->level);
CompactContext *compact = tctx->priv;
const AVTextFormatSection *section = tf_get_section(tctx, tctx->level);

if (!section)
return;

if (!compact->nested_section[wctx->level] &&
compact->terminate_line[wctx->level] &&
if (!compact->nested_section[tctx->level] &&
compact->terminate_line[tctx->level] &&
!(section->flags & (AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER | AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY)))
writer_w8(wctx, '\n');
writer_w8(tctx, '\n');
}

static void compact_print_str(AVTextFormatContext *wctx, const char *key, const char *value)
static void compact_print_str(AVTextFormatContext *tctx, const char *key, const char *value)
{
CompactContext *compact = wctx->priv;
CompactContext *compact = tctx->priv;
AVBPrint buf;

if (wctx->nb_item[wctx->level])
writer_w8(wctx, compact->item_sep);
if (tctx->nb_item[tctx->level])
writer_w8(tctx, compact->item_sep);

if (!compact->nokey)
writer_printf(wctx, "%s%s=", wctx->section_pbuf[wctx->level].str, key);
writer_printf(tctx, "%s%s=", tctx->section_pbuf[tctx->level].str, key);

av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
writer_put_str(wctx, compact->escape_str(&buf, value, compact->item_sep, wctx));
writer_put_str(tctx, compact->escape_str(&buf, value, compact->item_sep, tctx));
av_bprint_finalize(&buf, NULL);
}

static void compact_print_int(AVTextFormatContext *wctx, const char *key, int64_t value)
static void compact_print_int(AVTextFormatContext *tctx, const char *key, int64_t value)
{
CompactContext *compact = wctx->priv;
CompactContext *compact = tctx->priv;

if (wctx->nb_item[wctx->level])
writer_w8(wctx, compact->item_sep);
if (tctx->nb_item[tctx->level])
writer_w8(tctx, compact->item_sep);

if (!compact->nokey)
writer_printf(wctx, "%s%s=", wctx->section_pbuf[wctx->level].str, key);
writer_printf(tctx, "%s%s=", tctx->section_pbuf[tctx->level].str, key);

writer_printf(wctx, "%"PRId64, value);
writer_printf(tctx, "%"PRId64, value);
}

const AVTextFormatter avtextformatter_compact = {
Expand Down
48 changes: 24 additions & 24 deletions fftools/textformat/tf_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,71 +57,71 @@ static inline char *upcase_string(char *dst, size_t dst_size, const char *src)
unsigned i;

for (i = 0; src[i] && i < dst_size - 1; i++)
dst[i] = (char)av_toupper(src[i]);
dst[i] = av_toupper(src[i]);
dst[i] = 0;
return dst;
}

static void default_print_section_header(AVTextFormatContext *wctx, const void *data)
static void default_print_section_header(AVTextFormatContext *tctx, const void *data)
{
DefaultContext *def = wctx->priv;
DefaultContext *def = tctx->priv;
char buf[32];
const AVTextFormatSection *section = tf_get_section(wctx, wctx->level);
const AVTextFormatSection *parent_section = tf_get_parent_section(wctx, wctx->level);
const AVTextFormatSection *section = tf_get_section(tctx, tctx->level);
const AVTextFormatSection *parent_section = tf_get_parent_section(tctx, tctx->level);

if (!section)
return;

av_bprint_clear(&wctx->section_pbuf[wctx->level]);
av_bprint_clear(&tctx->section_pbuf[tctx->level]);
if (parent_section &&
!(parent_section->flags & (AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER | AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY))) {
def->nested_section[wctx->level] = 1;
av_bprintf(&wctx->section_pbuf[wctx->level], "%s%s:",
wctx->section_pbuf[wctx->level - 1].str,
def->nested_section[tctx->level] = 1;
av_bprintf(&tctx->section_pbuf[tctx->level], "%s%s:",
tctx->section_pbuf[tctx->level - 1].str,
upcase_string(buf, sizeof(buf),
av_x_if_null(section->element_name, section->name)));
}

if (def->noprint_wrappers || def->nested_section[wctx->level])
if (def->noprint_wrappers || def->nested_section[tctx->level])
return;

if (!(section->flags & (AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER | AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY)))
writer_printf(wctx, "[%s]\n", upcase_string(buf, sizeof(buf), section->name));
writer_printf(tctx, "[%s]\n", upcase_string(buf, sizeof(buf), section->name));
}

static void default_print_section_footer(AVTextFormatContext *wctx)
static void default_print_section_footer(AVTextFormatContext *tctx)
{
DefaultContext *def = wctx->priv;
const AVTextFormatSection *section = tf_get_section(wctx, wctx->level);
DefaultContext *def = tctx->priv;
const AVTextFormatSection *section = tf_get_section(tctx, tctx->level);

char buf[32];

if (!section)
return;

if (def->noprint_wrappers || def->nested_section[wctx->level])
if (def->noprint_wrappers || def->nested_section[tctx->level])
return;

if (!(section->flags & (AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER | AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY)))
writer_printf(wctx, "[/%s]\n", upcase_string(buf, sizeof(buf), section->name));
writer_printf(tctx, "[/%s]\n", upcase_string(buf, sizeof(buf), section->name));
}

static void default_print_str(AVTextFormatContext *wctx, const char *key, const char *value)
static void default_print_str(AVTextFormatContext *tctx, const char *key, const char *value)
{
DefaultContext *def = wctx->priv;
DefaultContext *def = tctx->priv;

if (!def->nokey)
writer_printf(wctx, "%s%s=", wctx->section_pbuf[wctx->level].str, key);
writer_printf(wctx, "%s\n", value);
writer_printf(tctx, "%s%s=", tctx->section_pbuf[tctx->level].str, key);
writer_printf(tctx, "%s\n", value);
}

static void default_print_int(AVTextFormatContext *wctx, const char *key, int64_t value)
static void default_print_int(AVTextFormatContext *tctx, const char *key, int64_t value)
{
DefaultContext *def = wctx->priv;
DefaultContext *def = tctx->priv;

if (!def->nokey)
writer_printf(wctx, "%s%s=", wctx->section_pbuf[wctx->level].str, key);
writer_printf(wctx, "%"PRId64"\n", value);
writer_printf(tctx, "%s%s=", tctx->section_pbuf[tctx->level].str, key);
writer_printf(tctx, "%"PRId64"\n", value);
}

const AVTextFormatter avtextformatter_default = {
Expand Down
Loading