Changeset 4765
- Timestamp:
- Feb 8, 2011, 11:09:53 PM (11 years ago)
- Location:
- libpipi/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/examples/makemovie.c
r4694 r4765 59 59 bitrate = atoi(argv[7]); 60 60 61 seq = pipi_open_sequence(argv[1], width, height, fps,61 seq = pipi_open_sequence(argv[1], width, height, 0 /* YUV */, fps, 62 62 par_num, par_den, bitrate); 63 63 if(!seq) -
libpipi/trunk/pipi/pipi.h
r4697 r4765 242 242 243 243 __extern pipi_sequence_t *pipi_open_sequence(char const *, int, int, int, 244 int, int, int );244 int, int, int, int); 245 245 __extern int pipi_feed_sequence(pipi_sequence_t *, uint8_t const *, int, int); 246 246 __extern int pipi_close_sequence(pipi_sequence_t *); -
libpipi/trunk/pipi/sequence.c
r4704 r4765 50 50 51 51 struct SwsContext *sws_ctx; 52 int src_width, src_height ;52 int src_width, src_height, src_fmt; 53 53 } 54 54 ffmpeg_codec_t; … … 56 56 57 57 pipi_sequence_t *pipi_open_sequence(char const *file, 58 int width, int height, int fps,58 int width, int height, int rgb, int fps, 59 59 int par_num, int par_den, int bitrate) 60 60 { … … 183 183 ff->buf = (uint8_t *)av_malloc(ff->buf_len); 184 184 185 ff->src_fmt = rgb ? PIX_FMT_RGB32 : PIX_FMT_YUV444P; 186 185 187 av_write_header(ff->fmt_ctx); 186 188 … … 220 222 if (!ff->sws_ctx) 221 223 { 222 ff->sws_ctx = sws_getContext(width, height, PIX_FMT_YUV444P,224 ff->sws_ctx = sws_getContext(width, height, ff->src_fmt, 223 225 ff->cod_ctx->width, 224 226 ff->cod_ctx->height, … … 235 237 236 238 /* Convert interleaved YUV to planar YUV */ 237 if (!seq->convert_buf) 238 seq->convert_buf = malloc(width * height * 3); 239 240 for (n = 0; n < width * height; n++) 241 { 242 seq->convert_buf[n] = buffer[4 * n]; 243 seq->convert_buf[n + width * height] = buffer[4 * n + 1]; 244 seq->convert_buf[n + 2 * width * height] = buffer[4 * n + 2]; 245 } 246 247 /* Feed the buffers to FFmpeg */ 248 buflist[0] = seq->convert_buf; 249 buflist[1] = seq->convert_buf + 2 * width * height; 250 buflist[2] = seq->convert_buf + width * height; 251 pitchlist[0] = pitchlist[1] = pitchlist[2] = width; 239 if (ff->src_fmt == PIX_FMT_YUV444P) 240 { 241 if (!seq->convert_buf) 242 seq->convert_buf = malloc(width * height * 3); 243 244 for (n = 0; n < width * height; n++) 245 { 246 seq->convert_buf[n] = buffer[4 * n]; 247 seq->convert_buf[n + width * height] = buffer[4 * n + 1]; 248 seq->convert_buf[n + 2 * width * height] = buffer[4 * n + 2]; 249 } 250 251 /* Feed the buffers to FFmpeg */ 252 buflist[0] = seq->convert_buf; 253 buflist[1] = seq->convert_buf + 2 * width * height; 254 buflist[2] = seq->convert_buf + width * height; 255 pitchlist[0] = pitchlist[1] = pitchlist[2] = width; 256 } 257 else 258 { 259 buflist[0] = buffer; 260 pitchlist[0] = 4 * width; 261 } 262 252 263 sws_scale(ff->sws_ctx, buflist, pitchlist, 0, height, 253 264 ff->frame->data, ff->frame->linesize); … … 280 291 ffmpeg_codec_t *ff = (ffmpeg_codec_t *)seq->codec_priv; 281 292 282 if (ff->fmt_ctx) 293 /* Finish the sequence */ 294 if (ff->buf) 283 295 { 284 296 av_write_trailer(ff->fmt_ctx); 285 297 } 286 298 299 /* Close everything */ 287 300 if (ff->buf) 288 301 { … … 312 325 ff->stream = NULL; 313 326 314 if (!(ff->fmt_ctx->flags & AVFMT_NOFILE) )327 if (!(ff->fmt_ctx->flags & AVFMT_NOFILE) && ff->fmt_ctx->pb) 315 328 url_fclose(ff->fmt_ctx->pb); 316 329
Note: See TracChangeset
for help on using the changeset viewer.