Mercurial > libavcodec.hg
comparison mjpeg.c @ 1548:dd544554ed42 libavcodec
AVRational
sample_aspect_ratio
aspect ratio in JPEG JFIF is SAR not DAR !
removed nonsense SAR guessing code
various related cleanups
bugs?
author | michael |
---|---|
date | Mon, 20 Oct 2003 20:23:46 +0000 |
parents | 3b31998fe22f |
children | 07dac732074a |
comparison
equal
deleted
inserted
replaced
1547:0183874861fd | 1548:dd544554ed42 |
---|---|
379 put_marker(p, APP0); | 379 put_marker(p, APP0); |
380 put_bits(p, 16, 16); | 380 put_bits(p, 16, 16); |
381 put_string(p, "JFIF"); /* this puts the trailing zero-byte too */ | 381 put_string(p, "JFIF"); /* this puts the trailing zero-byte too */ |
382 put_bits(p, 16, 0x0201); /* v 1.02 */ | 382 put_bits(p, 16, 0x0201); /* v 1.02 */ |
383 put_bits(p, 8, 0); /* units type: 0 - aspect ratio */ | 383 put_bits(p, 8, 0); /* units type: 0 - aspect ratio */ |
384 switch(s->aspect_ratio_info) | 384 put_bits(p, 16, s->avctx->sample_aspect_ratio.num); |
385 { | 385 put_bits(p, 16, s->avctx->sample_aspect_ratio.den); |
386 case FF_ASPECT_4_3_625: | |
387 case FF_ASPECT_4_3_525: | |
388 put_bits(p, 16, 4); | |
389 put_bits(p, 16, 3); | |
390 break; | |
391 case FF_ASPECT_16_9_625: | |
392 case FF_ASPECT_16_9_525: | |
393 put_bits(p, 16, 16); | |
394 put_bits(p, 16, 9); | |
395 break; | |
396 case FF_ASPECT_EXTENDED: | |
397 put_bits(p, 16, s->aspected_width); | |
398 put_bits(p, 16, s->aspected_height); | |
399 break; | |
400 case FF_ASPECT_SQUARE: | |
401 default: | |
402 put_bits(p, 16, 1); /* aspect: 1:1 */ | |
403 put_bits(p, 16, 1); | |
404 break; | |
405 } | |
406 put_bits(p, 8, 0); /* thumbnail width */ | 386 put_bits(p, 8, 0); /* thumbnail width */ |
407 put_bits(p, 8, 0); /* thumbnail height */ | 387 put_bits(p, 8, 0); /* thumbnail height */ |
408 } | 388 } |
409 | 389 |
410 /* comment */ | 390 /* comment */ |
1545 { | 1525 { |
1546 int t_w, t_h; | 1526 int t_w, t_h; |
1547 skip_bits(&s->gb, 8); /* the trailing zero-byte */ | 1527 skip_bits(&s->gb, 8); /* the trailing zero-byte */ |
1548 printf("mjpeg: JFIF header found (version: %x.%x)\n", | 1528 printf("mjpeg: JFIF header found (version: %x.%x)\n", |
1549 get_bits(&s->gb, 8), get_bits(&s->gb, 8)); | 1529 get_bits(&s->gb, 8), get_bits(&s->gb, 8)); |
1550 if (get_bits(&s->gb, 8) == 0) | 1530 skip_bits(&s->gb, 8); |
1551 { | 1531 |
1552 int x_density, y_density; | 1532 s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 16); |
1553 x_density = get_bits(&s->gb, 16); | 1533 s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 16); |
1554 y_density = get_bits(&s->gb, 16); | |
1555 | |
1556 dprintf("x/y density: %d (%f), %d (%f)\n", x_density, | |
1557 (float)x_density, y_density, (float)y_density); | |
1558 #if 0 | |
1559 //MN: needs to be checked | |
1560 if(x_density) | |
1561 // s->avctx->aspect_ratio= s->width*y_density/((float)s->height*x_density); | |
1562 s->avctx->aspect_ratio = (float)x_density/y_density; | |
1563 /* it's better, but every JFIF I have seen stores 1:1 */ | |
1564 else | |
1565 s->avctx->aspect_ratio= 0.0; | |
1566 #endif | |
1567 } | |
1568 else | |
1569 { | |
1570 skip_bits(&s->gb, 16); | |
1571 skip_bits(&s->gb, 16); | |
1572 } | |
1573 | 1534 |
1574 t_w = get_bits(&s->gb, 8); | 1535 t_w = get_bits(&s->gb, 8); |
1575 t_h = get_bits(&s->gb, 8); | 1536 t_h = get_bits(&s->gb, 8); |
1576 if (t_w && t_h) | 1537 if (t_w && t_h) |
1577 { | 1538 { |
2083 j += sizeof(sp5x_data_sof); | 2044 j += sizeof(sp5x_data_sof); |
2084 | 2045 |
2085 memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos)); | 2046 memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos)); |
2086 j += sizeof(sp5x_data_sos); | 2047 j += sizeof(sp5x_data_sos); |
2087 | 2048 |
2088 for (i = 14; i < buf_size, j < buf_size+1024-2; i++) | 2049 for (i = 14; i < buf_size && j < buf_size+1024-2; i++) |
2089 { | 2050 { |
2090 recoded[j++] = buf[i]; | 2051 recoded[j++] = buf[i]; |
2091 if (buf[i] == 0xff) | 2052 if (buf[i] == 0xff) |
2092 recoded[j++] = 0; | 2053 recoded[j++] = 0; |
2093 } | 2054 } |