comparison mjpeg.c @ 2270:21f450be6cb5 libavcodec

lowres width/height cleanup 3rd try
author michael
date Mon, 27 Sep 2004 11:50:56 +0000
parents 143c17950b55
children f9f257b41ec2
comparison
equal deleted inserted replaced
2269:535b7dfee202 2270:21f450be6cb5
857 { 857 {
858 MJpegDecodeContext *s = avctx->priv_data; 858 MJpegDecodeContext *s = avctx->priv_data;
859 MpegEncContext s2; 859 MpegEncContext s2;
860 860
861 s->avctx = avctx; 861 s->avctx = avctx;
862 avctx->width = -((-avctx->width ) >> avctx->lowres);
863 avctx->height= -((-avctx->height) >> avctx->lowres);
864 862
865 /* ugly way to get the idct & scantable FIXME */ 863 /* ugly way to get the idct & scantable FIXME */
866 memset(&s2, 0, sizeof(MpegEncContext)); 864 memset(&s2, 0, sizeof(MpegEncContext));
867 s2.avctx= avctx; 865 s2.avctx= avctx;
868 // s2->out_format = FMT_MJPEG; 866 // s2->out_format = FMT_MJPEG;
878 s->buffer = av_malloc(s->buffer_size); 876 s->buffer = av_malloc(s->buffer_size);
879 if (!s->buffer) 877 if (!s->buffer)
880 return -1; 878 return -1;
881 s->start_code = -1; 879 s->start_code = -1;
882 s->first_picture = 1; 880 s->first_picture = 1;
883 s->org_height = avctx->height << avctx->lowres; 881 s->org_height = avctx->coded_height;
884 882
885 build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12); 883 build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12);
886 build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12); 884 build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12);
887 build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251); 885 build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251);
888 build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251); 886 build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251);
1030 if (width != s->width || height != s->height) { 1028 if (width != s->width || height != s->height) {
1031 av_freep(&s->qscale_table); 1029 av_freep(&s->qscale_table);
1032 1030
1033 s->width = width; 1031 s->width = width;
1034 s->height = height; 1032 s->height = height;
1035 s->avctx->width = -((-s->width )>>s->avctx->lowres); 1033 avcodec_set_dimensions(s->avctx, width, height);
1036 s->avctx->height = -((-s->height)>>s->avctx->lowres);
1037 1034
1038 /* test interlaced mode */ 1035 /* test interlaced mode */
1039 if (s->first_picture && 1036 if (s->first_picture &&
1040 s->org_height != 0 && 1037 s->org_height != 0 &&
1041 s->height < ((s->org_height * 3) / 4)) { 1038 s->height < ((s->org_height * 3) / 4)) {
2041 2038
2042 memcpy(recoded+j, &sp5x_data_dht[0], sizeof(sp5x_data_dht)); 2039 memcpy(recoded+j, &sp5x_data_dht[0], sizeof(sp5x_data_dht));
2043 j += sizeof(sp5x_data_dht); 2040 j += sizeof(sp5x_data_dht);
2044 2041
2045 memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof)); 2042 memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof));
2046 recoded[j+5] = (avctx->height >> 8) & 0xFF; //FIXME lowres 2043 recoded[j+5] = (avctx->coded_height >> 8) & 0xFF;
2047 recoded[j+6] = avctx->height & 0xFF; 2044 recoded[j+6] = avctx->coded_height & 0xFF;
2048 recoded[j+7] = (avctx->width >> 8) & 0xFF; 2045 recoded[j+7] = (avctx->coded_width >> 8) & 0xFF;
2049 recoded[j+8] = avctx->width & 0xFF; 2046 recoded[j+8] = avctx->coded_width & 0xFF;
2050 j += sizeof(sp5x_data_sof); 2047 j += sizeof(sp5x_data_sof);
2051 2048
2052 memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos)); 2049 memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos));
2053 j += sizeof(sp5x_data_sos); 2050 j += sizeof(sp5x_data_sos);
2054 2051
2068 av_free(recoded); 2065 av_free(recoded);
2069 2066
2070 #else 2067 #else
2071 /* SOF */ 2068 /* SOF */
2072 s->bits = 8; 2069 s->bits = 8;
2073 s->width = avctx->width; 2070 s->width = avctx->coded_width;
2074 s->height = avctx->height; 2071 s->height = avctx->coded_height;
2075 avctx->width = -((-avctx->width )>>avctx->lowres);
2076 avctx->height = -((-avctx->height)>>avctx->lowres);
2077 s->nb_components = 3; 2072 s->nb_components = 3;
2078 s->component_id[0] = 0; 2073 s->component_id[0] = 0;
2079 s->h_count[0] = 2; 2074 s->h_count[0] = 2;
2080 s->v_count[0] = 2; 2075 s->v_count[0] = 2;
2081 s->quant_index[0] = 0; 2076 s->quant_index[0] = 0;