|
|
@@ -37,11 +37,17 @@ int main(int argc, char *argv[]) |
|
|
pipi_pixels_t *p; |
|
|
pipi_pixels_t *p; |
|
|
uint8_t *dst[4], *data = NULL; |
|
|
uint8_t *dst[4], *data = NULL; |
|
|
char *parser; |
|
|
char *parser; |
|
|
int stream, pitch[4], i, k = 0; |
|
|
|
|
|
|
|
|
int stream, pitch[4], i, k = 0, nframes = -1; |
|
|
|
|
|
double skip_seconds = 0.0; |
|
|
|
|
|
|
|
|
if(argc < 2) |
|
|
|
|
|
|
|
|
if (argc < 2) |
|
|
return EXIT_FAILURE; |
|
|
return EXIT_FAILURE; |
|
|
|
|
|
|
|
|
|
|
|
if (argc > 2) |
|
|
|
|
|
skip_seconds = atof(argv[2]); |
|
|
|
|
|
if (argc > 3) |
|
|
|
|
|
nframes = atoi(argv[3]); |
|
|
|
|
|
|
|
|
/* Ensure our linear YUV values do not get gamma-corrected */ |
|
|
/* Ensure our linear YUV values do not get gamma-corrected */ |
|
|
pipi_set_gamma(1.0); |
|
|
pipi_set_gamma(1.0); |
|
|
|
|
|
|
|
|
@@ -72,9 +78,14 @@ int main(int argc, char *argv[]) |
|
|
if(avcodec_open(ctx, codec) < 0) |
|
|
if(avcodec_open(ctx, codec) < 0) |
|
|
return EXIT_FAILURE; |
|
|
return EXIT_FAILURE; |
|
|
|
|
|
|
|
|
|
|
|
skip_seconds /= av_q2d(fmt->streams[stream]->time_base); |
|
|
|
|
|
av_seek_frame(fmt, stream, (int)(skip_seconds + 0.5), SEEK_SET); |
|
|
|
|
|
//avformat_seek_file(fmt, stream, skip_bytes, skip_bytes, |
|
|
|
|
|
// skip_bytes, AVSEEK_FLAG_BYTE); |
|
|
|
|
|
|
|
|
frame = avcodec_alloc_frame(); |
|
|
frame = avcodec_alloc_frame(); |
|
|
|
|
|
|
|
|
for(;;) |
|
|
|
|
|
|
|
|
for (k = 0; k < nframes || nframes == -1; /* k incremented below */) |
|
|
{ |
|
|
{ |
|
|
int finished, ret, x, y; |
|
|
int finished, ret, x, y; |
|
|
|
|
|
|
|
|
@@ -112,34 +123,37 @@ int main(int argc, char *argv[]) |
|
|
image = pipi_new(ctx->width, ctx->height); |
|
|
image = pipi_new(ctx->width, ctx->height); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
sws_scale(sws, (uint8_t const **)frame->data, frame->linesize, 0, |
|
|
|
|
|
ctx->height, dst, pitch); |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
char buf[1024]; |
|
|
|
|
|
sprintf(buf, fmtstr, k); |
|
|
|
|
|
printf("saving in %s\n", buf); |
|
|
|
|
|
|
|
|
p = pipi_get_pixels(image, PIPI_PIXELS_RGBA_U8); |
|
|
|
|
|
data = (uint8_t *)p->pixels; |
|
|
|
|
|
|
|
|
sws_scale(sws, (uint8_t const **)frame->data, frame->linesize, 0, |
|
|
|
|
|
ctx->height, dst, pitch); |
|
|
|
|
|
|
|
|
for (y = 0; y < ctx->height; y++) |
|
|
|
|
|
{ |
|
|
|
|
|
int off = y * ctx->width; |
|
|
|
|
|
|
|
|
p = pipi_get_pixels(image, PIPI_PIXELS_RGBA_U8); |
|
|
|
|
|
data = (uint8_t *)p->pixels; |
|
|
|
|
|
|
|
|
for (x = 0; x < ctx->width; x++, off++) |
|
|
|
|
|
|
|
|
for (y = 0; y < ctx->height; y++) |
|
|
{ |
|
|
{ |
|
|
/* Reorder components to store YUVA */ |
|
|
|
|
|
data[4 * off] = dst[0][off]; |
|
|
|
|
|
data[4 * off + 1] = dst[2][off]; |
|
|
|
|
|
data[4 * off + 2] = dst[1][off]; |
|
|
|
|
|
data[4 * off + 3] = 0xff; |
|
|
|
|
|
|
|
|
int off = y * ctx->width; |
|
|
|
|
|
|
|
|
|
|
|
for (x = 0; x < ctx->width; x++, off++) |
|
|
|
|
|
{ |
|
|
|
|
|
/* Reorder components to store YUVA */ |
|
|
|
|
|
data[4 * off] = dst[0][off]; |
|
|
|
|
|
data[4 * off + 1] = dst[2][off]; |
|
|
|
|
|
data[4 * off + 2] = dst[1][off]; |
|
|
|
|
|
data[4 * off + 3] = 0xff; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
char buf[1024]; |
|
|
|
|
|
sprintf(buf, fmtstr, k++); |
|
|
|
|
|
printf("saving in %s\n", buf); |
|
|
|
|
|
pipi_save(image, buf); |
|
|
pipi_save(image, buf); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
av_free_packet(&packet); |
|
|
av_free_packet(&packet); |
|
|
|
|
|
|
|
|
|
|
|
k++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return EXIT_SUCCESS; |
|
|
return EXIT_SUCCESS; |
|
|
|