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

Showing the changes to libavdevice (1 of 1 file). Show all

Unified · Split

libavdevice/lavfi.c+8−17
@@ -444,25 +444,16 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) · 443 unmodified lines
444 444
445 frame_metadata = frame->metadata;445 frame_metadata = frame->metadata;
446 if (frame_metadata) {446 if (frame_metadata) {
447 uint8_t *metadata;447 int size;
448 AVDictionaryEntry *e = NULL;448 uint8_t *metadata = av_packet_pack_dictionary(frame_metadata, &size);
449 AVBPrint meta_buf;449
450 450 if (!metadata)
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);
462 return AVERROR(ENOMEM);451 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;
463 }456 }
464 memcpy(metadata, meta_buf.str, meta_buf.len);
465 av_bprint_finalize(&meta_buf, NULL);
466 }457 }
467 458
468 if ((ret = create_subcc_packet(avctx, frame, min_pts_sink_idx)) < 0) {459 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