History

avdevice/lavfi: Use av_packet_pack_dictionary() to pack dictionary

Andreas Rheinhardt committed 6 years ago

Commit 26469ae1 parent 7ad085b1 file · +8 −17Browse files

Unified · Split

libavdevice/lavfi.c+8−17
@@ -444,25 +444,16 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) · 443 unmodified lines
444444
445445 frame_metadata = frame->metadata;
446446 if (frame_metadata) {
447− uint8_t *metadata;
448− AVDictionaryEntry *e = NULL;
449− AVBPrint meta_buf;
450−
451− av_bprint_init(&meta_buf, 0, AV_BPRINT_SIZE_UNLIMITED);
452− while ((e = av_dict_get(frame_metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
453− av_bprintf(&meta_buf, "%s", e->key);
454− av_bprint_chars(&meta_buf, '\0', 1);
455− av_bprintf(&meta_buf, "%s", e->value);
456− av_bprint_chars(&meta_buf, '\0', 1);
457− }
458− if (!av_bprint_is_complete(&meta_buf) ||
459− !(metadata = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
460− meta_buf.len))) {
461− av_bprint_finalize(&meta_buf, NULL);
447+ int size;
448+ uint8_t *metadata = av_packet_pack_dictionary(frame_metadata, &size);
449+
450+ if (!metadata)
462451 return AVERROR(ENOMEM);
452+ if ((ret = av_packet_add_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
453+ metadata, size)) < 0) {
454+ av_freep(&metadata);
455+ return ret;
463456 }
464− memcpy(metadata, meta_buf.str, meta_buf.len);
465− av_bprint_finalize(&meta_buf, NULL);
466457 }
467458
468459 if ((ret = create_subcc_packet(avctx, frame, min_pts_sink_idx)) < 0) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t