| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * copyright (c) 2009 Michael Niedermayer | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with FFmpeg; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include "avformat.h" | ||
| 22 | #include "metadata.h" | ||
| 23 | #include "libavutil/dict.h" | ||
| 24 | #include "libavutil/avstring.h" | ||
| 25 | |||
| 26 | 11707 | void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv, | |
| 27 | const AVMetadataConv *s_conv) | ||
| 28 | { | ||
| 29 | /* TODO: use binary search to look up the two conversion tables | ||
| 30 | if the tables are getting big enough that it would matter speed wise */ | ||
| 31 | const AVMetadataConv *sc, *dc; | ||
| 32 | 11707 | const AVDictionaryEntry *mtag = NULL; | |
| 33 | 11707 | AVDictionary *dst = NULL; | |
| 34 | const char *key; | ||
| 35 | |||
| 36 |
2/4✓ Branch 0 taken 11707 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11707 times.
|
11707 | if (d_conv == s_conv || !pm) |
| 37 | ✗ | return; | |
| 38 | |||
| 39 |
2/2✓ Branch 1 taken 5694 times.
✓ Branch 2 taken 11707 times.
|
17401 | while ((mtag = av_dict_iterate(*pm, mtag))) { |
| 40 | 5694 | key = mtag->key; | |
| 41 |
2/2✓ Branch 0 taken 2034 times.
✓ Branch 1 taken 3660 times.
|
5694 | if (s_conv) |
| 42 |
2/2✓ Branch 0 taken 14889 times.
✓ Branch 1 taken 1702 times.
|
16591 | for (sc=s_conv; sc->native; sc++) |
| 43 |
2/2✓ Branch 1 taken 332 times.
✓ Branch 2 taken 14557 times.
|
14889 | if (!av_strcasecmp(key, sc->native)) { |
| 44 | 332 | key = sc->generic; | |
| 45 | 332 | break; | |
| 46 | } | ||
| 47 |
2/2✓ Branch 0 taken 3660 times.
✓ Branch 1 taken 2034 times.
|
5694 | if (d_conv) |
| 48 |
2/2✓ Branch 0 taken 35306 times.
✓ Branch 1 taken 3269 times.
|
38575 | for (dc=d_conv; dc->native; dc++) |
| 49 |
2/2✓ Branch 1 taken 391 times.
✓ Branch 2 taken 34915 times.
|
35306 | if (!av_strcasecmp(key, dc->generic)) { |
| 50 | 391 | key = dc->native; | |
| 51 | 391 | break; | |
| 52 | } | ||
| 53 | 5694 | av_dict_set(&dst, key, mtag->value, AV_DICT_MULTIKEY | AV_DICT_DEDUP); | |
| 54 | } | ||
| 55 | 11707 | av_dict_free(pm); | |
| 56 | 11707 | *pm = dst; | |
| 57 | } | ||
| 58 | |||
| 59 | 4971 | void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv, | |
| 60 | const AVMetadataConv *s_conv) | ||
| 61 | { | ||
| 62 | int i; | ||
| 63 | 4971 | ff_metadata_conv(&ctx->metadata, d_conv, s_conv); | |
| 64 |
2/2✓ Branch 0 taken 5118 times.
✓ Branch 1 taken 4971 times.
|
10089 | for (i=0; i<ctx->nb_streams ; i++) |
| 65 | 5118 | ff_metadata_conv(&ctx->streams [i]->metadata, d_conv, s_conv); | |
| 66 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 4971 times.
|
5005 | for (i=0; i<ctx->nb_chapters; i++) |
| 67 | 34 | ff_metadata_conv(&ctx->chapters[i]->metadata, d_conv, s_conv); | |
| 68 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4971 times.
|
4971 | for (i=0; i<ctx->nb_programs; i++) |
| 69 | ✗ | ff_metadata_conv(&ctx->programs[i]->metadata, d_conv, s_conv); | |
| 70 | 4971 | } | |
| 71 |