mirror of
				https://github.com/nyanmisaka/ffmpeg-rockchip.git
				synced 2025-10-31 04:26:37 +08:00 
			
		
		
		
	modify the way to pass parameters to av_metadata_set()
This improves code readability and this avoid warnings about discarding qualifiers from pointer target type. Originally committed as revision 16952 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
		| @@ -89,10 +89,11 @@ av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int f | |||||||
|  |  | ||||||
| /** | /** | ||||||
|  * sets the given tag in m, overwriting an existing tag. |  * sets the given tag in m, overwriting an existing tag. | ||||||
|  * @param tag tag to add to m, key and value will be av_strduped. |  * @param key tag key to add to m (will be av_strduped). | ||||||
|  |  * @param value tag value to add to m (will be av_strduped). | ||||||
|  * @return >= 0 if success otherwise error code that is <0. |  * @return >= 0 if success otherwise error code that is <0. | ||||||
|  */ |  */ | ||||||
| int av_metadata_set(AVMetadata **m, AVMetadataTag tag); | int av_metadata_set(AVMetadata **pm, const char *key, const char *value); | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Free all the memory allocated for an AVMetadata struct. |  * Free all the memory allocated for an AVMetadata struct. | ||||||
|   | |||||||
| @@ -229,7 +229,7 @@ static int avi_read_tag(AVFormatContext *s, const char *key, unsigned int size) | |||||||
|     get_strz(pb, value, sizeof(value)); |     get_strz(pb, value, sizeof(value)); | ||||||
|     url_fseek(pb, i+size, SEEK_SET); |     url_fseek(pb, i+size, SEEK_SET); | ||||||
|  |  | ||||||
|     return av_metadata_set(&s->metadata, (const AVMetadataTag){key, value}); |     return av_metadata_set(&s->metadata, key, value); | ||||||
| } | } | ||||||
|  |  | ||||||
| static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) | static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) | ||||||
|   | |||||||
| @@ -44,10 +44,10 @@ av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int f | |||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| int av_metadata_set(AVMetadata **pm, AVMetadataTag elem) | int av_metadata_set(AVMetadata **pm, const char *key, const char *value) | ||||||
| { | { | ||||||
|     AVMetadata *m= *pm; |     AVMetadata *m= *pm; | ||||||
|     AVMetadataTag *tag= av_metadata_get(m, elem.key, NULL, AV_METADATA_MATCH_CASE); |     AVMetadataTag *tag= av_metadata_get(m, key, NULL, AV_METADATA_MATCH_CASE); | ||||||
|  |  | ||||||
|     if(!m) |     if(!m) | ||||||
|         m=*pm= av_mallocz(sizeof(*m)); |         m=*pm= av_mallocz(sizeof(*m)); | ||||||
| @@ -63,10 +63,10 @@ int av_metadata_set(AVMetadata **pm, AVMetadataTag elem) | |||||||
|         }else |         }else | ||||||
|             return AVERROR(ENOMEM); |             return AVERROR(ENOMEM); | ||||||
|     } |     } | ||||||
|     if(elem.value){ |     if(value){ | ||||||
|         elem.key  = av_strdup(elem.key  ); |         m->elems[m->count].key  = av_strdup(key  ); | ||||||
|         elem.value= av_strdup(elem.value); |         m->elems[m->count].value= av_strdup(value); | ||||||
|         m->elems[m->count++]= elem; |         m->count++; | ||||||
|     } |     } | ||||||
|     if(!m->count) |     if(!m->count) | ||||||
|         av_freep(pm); |         av_freep(pm); | ||||||
|   | |||||||
| @@ -106,7 +106,7 @@ void ff_metadata_demux_compat(AVFormatContext *ctx) | |||||||
|  |  | ||||||
| #define FILL_METADATA(s, key, value) {                                        \ | #define FILL_METADATA(s, key, value) {                                        \ | ||||||
|     if (value && *value && !av_metadata_get(s->metadata, #key, NULL, 0))      \ |     if (value && *value && !av_metadata_get(s->metadata, #key, NULL, 0))      \ | ||||||
|         av_metadata_set(&s->metadata, (const AVMetadataTag){#key, value});    \ |         av_metadata_set(&s->metadata, #key, value);                           \ | ||||||
|     } |     } | ||||||
| #define FILL_METADATA_STR(s, key)  FILL_METADATA(s, key, s->key) | #define FILL_METADATA_STR(s, key)  FILL_METADATA(s, key, s->key) | ||||||
| #define FILL_METADATA_INT(s, key) {                                           \ | #define FILL_METADATA_INT(s, key) {                                           \ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Aurelien Jacobs
					Aurelien Jacobs