comparison mjpeg.c @ 28:b611fafddf9e libavcodec

added 422P and 444P support - fixed block parsing error
author glantau
date Mon, 06 Aug 2001 01:54:05 +0000
parents ce751dfbcace
children e04aea3bbf51
comparison
equal deleted inserted replaced
27:b8723ec6c80f 28:b611fafddf9e
581 /* compute hmax and vmax (only used in interleaved case) */ 581 /* compute hmax and vmax (only used in interleaved case) */
582 if (s->h_count[i] > s->h_max) 582 if (s->h_count[i] > s->h_max)
583 s->h_max = s->h_count[i]; 583 s->h_max = s->h_count[i];
584 if (s->v_count[i] > s->v_max) 584 if (s->v_count[i] > s->v_max)
585 s->v_max = s->v_count[i]; 585 s->v_max = s->v_count[i];
586 #if 1
587 /* XXX: only 420 is accepted */
588 if ((i == 0 && (s->h_count[i] != 2 || s->v_count[i] != 2)) ||
589 (i != 0 && (s->h_count[i] != 1 || s->v_count[i] != 1)))
590 return -1;
591 #endif
592 s->quant_index[i] = get_bits(&s->gb, 8); 586 s->quant_index[i] = get_bits(&s->gb, 8);
593 if (s->quant_index[i] >= 4) 587 if (s->quant_index[i] >= 4)
594 return -1; 588 return -1;
595 dprintf("component %d %d:%d\n", i, s->h_count[i], s->v_count[i]); 589 dprintf("component %d %d:%d\n", i, s->h_count[i], s->v_count[i]);
596 } 590 }
657 return -1; 651 return -1;
658 } 652 }
659 val = val * quant_matrix[0] + s->last_dc[component]; 653 val = val * quant_matrix[0] + s->last_dc[component];
660 s->last_dc[component] = val; 654 s->last_dc[component] = val;
661 block[0] = val; 655 block[0] = val;
662
663 /* AC coefs */ 656 /* AC coefs */
664 ac_vlc = &s->vlcs[1][ac_index]; 657 ac_vlc = &s->vlcs[1][ac_index];
665 i = 1; 658 i = 1;
666 for(;;) { 659 for(;;) {
667 code = get_vlc(&s->gb, ac_vlc); 660 code = get_vlc(&s->gb, ac_vlc);
686 return -1; 679 return -1;
687 } 680 }
688 j = zigzag_direct[i]; 681 j = zigzag_direct[i];
689 block[j] = level * quant_matrix[j]; 682 block[j] = level * quant_matrix[j];
690 i++; 683 i++;
684 if (i >= 64)
685 break;
691 } 686 }
692 } 687 }
693 return 0; 688 return 0;
694 } 689 }
695 690
725 720
726 comp_index[i] = index; 721 comp_index[i] = index;
727 nb_blocks[i] = s->h_count[index] * s->v_count[index]; 722 nb_blocks[i] = s->h_count[index] * s->v_count[index];
728 h_count[i] = s->h_count[index]; 723 h_count[i] = s->h_count[index];
729 v_count[i] = s->v_count[index]; 724 v_count[i] = s->v_count[index];
730 725
731 dc_index[i] = get_bits(&s->gb, 4); 726 dc_index[i] = get_bits(&s->gb, 4);
732 if (dc_index[i] >= 4) 727 if (dc_index[i] >= 4)
733 return -1; 728 return -1;
734 ac_index[i] = get_bits(&s->gb, 4); 729 ac_index[i] = get_bits(&s->gb, 4);
735 if (ac_index[i] >= 4) 730 if (ac_index[i] >= 4)
880 mjpeg_decode_sof0(s, s->buffer, input_size); 875 mjpeg_decode_sof0(s, s->buffer, input_size);
881 break; 876 break;
882 case SOS: 877 case SOS:
883 mjpeg_decode_sos(s, s->buffer, input_size); 878 mjpeg_decode_sos(s, s->buffer, input_size);
884 if (s->start_code == EOI) { 879 if (s->start_code == EOI) {
885 /* XXX: YUV420 hardcoded */
886 for(i=0;i<3;i++) { 880 for(i=0;i<3;i++) {
887 picture->data[i] = s->current_picture[i]; 881 picture->data[i] = s->current_picture[i];
888 picture->linesize[i] = s->linesize[i]; 882 picture->linesize[i] = s->linesize[i];
889 } 883 }
890 *data_size = sizeof(AVPicture); 884 *data_size = sizeof(AVPicture);
891 avctx->height = s->height; 885 avctx->height = s->height;
892 avctx->width = s->width; 886 avctx->width = s->width;
893 avctx->pix_fmt = PIX_FMT_YUV420P; 887 /* XXX: not complete test ! */
888 switch((s->h_count[0] << 4) | s->v_count[0]) {
889 case 0x11:
890 avctx->pix_fmt = PIX_FMT_YUV444P;
891 break;
892 case 0x21:
893 avctx->pix_fmt = PIX_FMT_YUV422P;
894 break;
895 default:
896 case 0x22:
897 avctx->pix_fmt = PIX_FMT_YUV420P;
898 break;
899 }
894 goto the_end; 900 goto the_end;
895 } 901 }
896 break; 902 break;
897 } 903 }
898 } 904 }