comparison utils.c @ 3330:374e74567a4e libavformat

Make ff_new_chapter() return AVChapter instead of int so its consistant with av_new_program() and its simpler to set other fields in AVChapter which arent set by ff_new_chapter().
author michael
date Fri, 23 May 2008 13:14:11 +0000
parents b228cfb5a4f5
children 74e2cfc79cda
comparison
equal deleted inserted replaced
3329:8426e474011f 3330:374e74567a4e
2232 program->provider_name = av_strdup(provider_name); 2232 program->provider_name = av_strdup(provider_name);
2233 program-> name = av_strdup( name); 2233 program-> name = av_strdup( name);
2234 } 2234 }
2235 } 2235 }
2236 2236
2237 int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title) 2237 AVChapter *ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title)
2238 { 2238 {
2239 AVChapter *chapter = NULL; 2239 AVChapter *chapter = NULL;
2240 int i; 2240 int i;
2241 2241
2242 for(i=0; i<s->nb_chapters; i++) 2242 for(i=0; i<s->nb_chapters; i++)
2244 chapter = s->chapters[i]; 2244 chapter = s->chapters[i];
2245 2245
2246 if(!chapter){ 2246 if(!chapter){
2247 chapter= av_mallocz(sizeof(AVChapter)); 2247 chapter= av_mallocz(sizeof(AVChapter));
2248 if(!chapter) 2248 if(!chapter)
2249 return AVERROR(ENOMEM); 2249 return NULL;
2250 dynarray_add(&s->chapters, &s->nb_chapters, chapter); 2250 dynarray_add(&s->chapters, &s->nb_chapters, chapter);
2251 } 2251 }
2252 if(chapter->title) 2252 if(chapter->title)
2253 av_free(chapter->title); 2253 av_free(chapter->title);
2254 chapter->title = av_strdup(title); 2254 chapter->title = av_strdup(title);
2255 chapter->id = id; 2255 chapter->id = id;
2256 chapter->start = start; 2256 chapter->start = start;
2257 chapter->end = end; 2257 chapter->end = end;
2258 2258
2259 return 0; 2259 return chapter;
2260 } 2260 }
2261 2261
2262 /************************************************************/ 2262 /************************************************************/
2263 /* output media file */ 2263 /* output media file */
2264 2264