comparison vorbis_enc.c @ 3870:986fb3b8fe60 libavcodec

Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines channel coupling
author ods15
date Mon, 02 Oct 2006 06:08:09 +0000
parents 9b1217a7e09f
children 7fffd3ab056a
comparison
equal deleted inserted replaced
3869:9b1217a7e09f 3870:986fb3b8fe60
90 typedef struct { 90 typedef struct {
91 int submaps; 91 int submaps;
92 int * mux; 92 int * mux;
93 int * floor; 93 int * floor;
94 int * residue; 94 int * residue;
95 int coupling_steps;
96 int * magnitude;
97 int * angle;
95 } mapping_t; 98 } mapping_t;
96 99
97 typedef struct { 100 typedef struct {
98 int blockflag; 101 int blockflag;
99 int mapping; 102 int mapping;
387 mc->residue = av_malloc(sizeof(int) * mc->submaps); 390 mc->residue = av_malloc(sizeof(int) * mc->submaps);
388 for (i = 0; i < mc->submaps; i++) { 391 for (i = 0; i < mc->submaps; i++) {
389 mc->floor[i] = 0; 392 mc->floor[i] = 0;
390 mc->residue[i] = 0; 393 mc->residue[i] = 0;
391 } 394 }
395 mc->coupling_steps = venc->channels == 2 ? 1 : 0;
396 mc->magnitude = av_malloc(sizeof(int) * mc->coupling_steps);
397 mc->angle = av_malloc(sizeof(int) * mc->coupling_steps);
398 if (mc->coupling_steps) {
399 mc->magnitude[0] = 0;
400 mc->angle[0] = 1;
401 }
392 402
393 venc->nmodes = 1; 403 venc->nmodes = 1;
394 venc->modes = av_malloc(sizeof(vorbis_mode_t) * venc->nmodes); 404 venc->modes = av_malloc(sizeof(vorbis_mode_t) * venc->nmodes);
395 405
396 // single mode 406 // single mode
600 put_bits(&pb, 16, 0); // mapping type 610 put_bits(&pb, 16, 0); // mapping type
601 611
602 put_bits(&pb, 1, mc->submaps > 1); 612 put_bits(&pb, 1, mc->submaps > 1);
603 if (mc->submaps > 1) put_bits(&pb, 4, mc->submaps - 1); 613 if (mc->submaps > 1) put_bits(&pb, 4, mc->submaps - 1);
604 614
605 put_bits(&pb, 1, 0); // channel coupling 615 put_bits(&pb, 1, !!mc->coupling_steps);
616 if (mc->coupling_steps) {
617 put_bits(&pb, 8, mc->coupling_steps - 1);
618 for (j = 0; j < mc->coupling_steps; j++) {
619 av_log(NULL, AV_LOG_ERROR, "%d %d %d %d\n", venc->channels, ilog(venc->channels - 1), mc->magnitude[j], mc->angle[j]);
620 put_bits(&pb, ilog(venc->channels - 1), mc->magnitude[j]);
621 put_bits(&pb, ilog(venc->channels - 1), mc->angle[j]);
622 }
623 }
606 624
607 put_bits(&pb, 2, 0); // reserved 625 put_bits(&pb, 2, 0); // reserved
608 626
609 if (mc->submaps > 1) for (j = 0; j < venc->channels; j++) put_bits(&pb, 4, mc->mux[j]); 627 if (mc->submaps > 1) for (j = 0; j < venc->channels; j++) put_bits(&pb, 4, mc->mux[j]);
610 628
930 for (j = 0; j < samples; j++) { 948 for (j = 0; j < samples; j++) {
931 venc->coeffs[i * samples + j] /= venc->floor[i * samples + j]; 949 venc->coeffs[i * samples + j] /= venc->floor[i * samples + j];
932 } 950 }
933 } 951 }
934 952
953 for (i = 0; i < mapping->coupling_steps; i++) {
954 float * mag = venc->coeffs + mapping->magnitude[i] * samples;
955 float * ang = venc->coeffs + mapping->angle[i] * samples;
956 int j;
957 for (j = 0; j < samples; j++) {
958 float m = mag[j];
959 float a = ang[j];
960 if (m > 0) {
961 ang[j] = m - a;
962 if (a > m) mag[j] = a;
963 else mag[j] = m;
964 } else {
965 ang[j] = a - m;
966 if (a > m) mag[j] = m;
967 else mag[j] = a;
968 }
969 }
970 }
971
935 residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]], &pb, venc->coeffs, samples, venc->channels); 972 residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]], &pb, venc->coeffs, samples, venc->channels);
936 973
937 return (put_bits_count(&pb) + 7) / 8; 974 return (put_bits_count(&pb) + 7) / 8;
938 } 975 }
939 976