0% found this document useful (0 votes)
37 views16 pages

# Langkah Kerja Simulasi: Lampiran A

The document describes the steps in a video simulation process including: 1) Encoding a video file in YUV format 2) Embedding the encoded file in a MATLAB script 3) Running the script to generate a graph of BER vs SNR and output an encoded .264 file 4) Decoding the video file to reconstruct the video and calculate PSNR values compared to the original

Uploaded by

hudysayang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views16 pages

# Langkah Kerja Simulasi: Lampiran A

The document describes the steps in a video simulation process including: 1) Encoding a video file in YUV format 2) Embedding the encoded file in a MATLAB script 3) Running the script to generate a graph of BER vs SNR and output an encoded .264 file 4) Decoding the video file to reconstruct the video and calculate PSNR values compared to the original

Uploaded by

hudysayang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

LAMPIRAN A.

# Langkah kerja simulasi

o Encod video YUV

o Hasil encod.txt

o File encoder bus_cif30_1layer_2x1.264 hasil encoder.


o File di sematkan pada scrib matlab

o Hasil running
o Hasil grafik BER dari matlab

o Output matlab .264

o Proses decoder video YUV untuk dapatkan video rekontruksi


o Hasil decod.txt

o File video rekontruksi

o Hasil video rekontruksi dibandingkan untuk dapatkan nilai PSNR


o Nilai PSNR
LAMPIRAN B.

# Listing program

clear all;
close all;
clc;
%input source video
fid=fopen('bus_cif30_1layer_2x1.264','r'); %buka file bit stream
vid_in=fread(fid);
vid_in2=double(vid_in);
b=des2biner(vid_in2);
b1=reshape(b',size(b,1)*8,1);
Lzero=2^(round(log2(length(b1)+1)));
b2=zeros(Lzero,1);
b2(1:length(b1),:)=b1(1:end,1);
b3=reshape(b2,64,Lzero/64);
%--------------- system parameters----------------
nt = 2;
nr = 1;
fft_len = 64; % FFt size
cp_len = 16; % cp length
L = 5; % channel order
framelen = size(b3,2);% frame size
F = 1/sqrt(fft_len)*exp(-j*2*pi/fft_len*[0:fft_len-1]'*[0:fft_len-1]); % FFT matrix

%--------------- simulation parameters-----------


SNR_loop = [0:2:10];
trial_loop = [1 1 1 1 1 1];

%--------------- Monte Carlo --------------------


E = [];
for i = 1:length(SNR_loop)
SNR = SNR_loop(i);
NPW = 10^(-SNR/10);
trial = trial_loop(i);
error = 0;
for i = 1:trial %--------for loop for a specific SNR value
%---------------- geneate source symbol----------------------
S_Usr1 = 1/sqrt(2)*((2*b3-1)+j*(2*b3-1)); % frequency-domain symbols of TX 1
%S_Usr2 = 1/sqrt(2)*( sign(randn(fft_len, framelen)) + j*sign(randn(fft_len,
framelen)) ); % frequency-domain symbols of TX 2

S1(:,1:2:framelen) = S_Usr1(:,1:2:framelen);
S1(:,2:2:framelen) =-conj(S_Usr1(:,2:2:framelen));
S2(:,1:2:framelen) = S_Usr1(:,2:2:framelen);
S2(:,2:2:framelen) = conj(S_Usr1(:,1:2:framelen));

S_t1 = F'*S1; % time-domain symbols of TX 1


S_t2 = F'*S2; % time-domain symbols of TX 2
S_t_cp1 = [ S_t1( end-cp_len+1 : end ,:); S_t1 ]; % attach cp
S_t_cp2 = [ S_t2( end-cp_len+1 : end ,:); S_t2 ];
s_tx1 = sqrt( fft_len/(fft_len+cp_len) )*reshape( S_t_cp1, 1, framelen*(fft_len +
cp_len) ); % parallel to serial
s_tx2 = sqrt( fft_len/(fft_len+cp_len) )*reshape( S_t_cp2, 1, framelen*(fft_len +
cp_len) );

%---------------- generate channel tap------------------------


h11 = 1/sqrt(2*nt*(L+1))*crandn(1,L+1);
h12 = 1/sqrt(2*nt*(L+1))*crandn(1,L+1);
h21 = 1/sqrt(2*nt*(L+1))*crandn(1,L+1);
h22 = 1/sqrt(2*nt*(L+1))*crandn(1,L+1);

%------------ data transmit through multipath channel ---------


s_rx_1 = 0;
s_rx_2 = 0;
for l = 1:L+1
s_rx_1 = s_rx_1 + h11(l)*[zeros(1,l-1) s_tx1 zeros(1,L-l+1)] + h12(l)*[zeros(1,l-
1) s_tx2 zeros(1,L-l+1)];
s_rx_2 = s_rx_2 + h21(l)*[zeros(1,l-1) s_tx1 zeros(1,L-l+1)] + h22(l)*[zeros(1,l-
1) s_tx2 zeros(1,L-l+1)];
end

%------------- add channel noise ----------------------------------


n1 = (NPW/2)*crandn( 1, length(s_rx_1) );
n2 = (NPW/2)*crandn( 1, length(s_rx_2) );
s_rx_1 = s_rx_1 + n1;
s_rx_2 = s_rx_2 + n2;

%--------------- receiver processing --------------------------


S_r1 = [];
S_r2 = [];
for k = 1:framelen
S_r1 = [ S_r1 s_rx_1( (fft_len + cp_len)*(k-1)+1:(fft_len + cp_len)*k ).' ]; %
sreial-to-parallel
S_r_cp1 = S_r1( cp_len + 1:end,: ); % cp removal
S_r_f1 = F*S_r_cp1; % receivd frequency-domain OFDM symbol
end

%-------------- channel frequency impulse response-------------


h_f11 = sqrt(fft_len)*F*[h11 zeros(1,fft_len-(L+1))].';
h_f12 = sqrt(fft_len)*F*[h12 zeros(1,fft_len-(L+1))].';
h_f21 = sqrt(fft_len)*F*[h21 zeros(1,fft_len-(L+1))].';
h_f22 = sqrt(fft_len)*F*[h22 zeros(1,fft_len-(L+1))].';

%-------------- Per-tone MMSE VBLAST -------------------------------


S1_est = [];
%S2_est = [];
for p = 1:fft_len
H = [h_f11(p) h_f12(p); h_f21(p) h_f22(p)]; % MIMO channel freuqncy channel
r_p = [S_r_f1(p, :); S_r_f2(p, :)];

S_est1(p,1:2:framelen) = S_r_f1(p,1:2:framelen).*conj(h_f11(p))
+conj(S_r_f1(p,2:2:framelen)).*h_f12(p)+S_r_f2(p,1:2:framelen).*conj(h_f21(p))
+conj(S_r_f2(p,2:2:framelen)).*h_f22(p);
S_est1(p,2:2:framelen) = S_r_f1(p,1:2:framelen).*conj(h_f12(p))-
conj(S_r_f1(p,2:2:framelen)).*h_f11(p)+S_r_f2(p,1:2:framelen).*conj(h_f22(p))-
conj(S_r_f2(p,2:2:framelen)).*h_f21(p);

S1_est = [S1_est; S_est1(p, : )]; % estimated source symbols of TX 1


%S2_est = [S2_est; S_est(2, :)]; % estimated source symbols of TX 2
end

%-------------- error counting --------------------------------


bit_true = reshape(S_Usr1 , 1, framelen*fft_len);
real_true = sign(real(bit_true));
imag_true = sign(imag(bit_true));

bit_est = reshape( S1_est , 1, framelen*fft_len);


real_est = sign(real(bit_est));
imag_est = sign(imag(bit_est));

error = error + sum( abs(real_true - real_est)/2 ) + sum( abs(imag_true -


imag_est)/2 );
end
E = [E error/(2*trial*fft_len*framelen)]

end
% figure(1);
% subplot(211);
% pwelch(S_t1,[],[],[],2/4e-6);
% subplot(212);
% pwelch(S_t2,[],[],[],2/4e-6);
figure(2);
semilogy(SNR_loop, E,'mo-','LineWidth',2);
title('Sequence BUS MGS');
xlabel('SNR, dB');
ylabel('Bit Error Rate');
axis([0 10 10^-5 0.5]);
grid on;

%write video
outbit=[real_est(:,1:length(b1))];
outbiner=(outbit+1)*0.5;
outbinner=reshape(outbiner',8,length(b1)/8)
outvid=biner2des(outbinner');
gid=fopen('bus_2x1_1layer.264','w');
fwrite(gid,outvid);
yt=fclose('all');
o Konfigurasi program Bus.cfg non-scalable qcif15

o Konfigurasi program Bus.cfg non-scalable cif15


o Konfigurasi program Bus.cfg non-scalable cif30

o Konfigurasi program Bus.cfg scalable 2 layer


o Konfigurasi program Bus.cfg scalable 3 layer

o Konfigurasi program City.cfg non-scalable qcif15


o Konfigurasi program City.cfg non-scalable cif15

o Konfigurasi program City.cfg non-scalable cif30


o Konfigurasi program City.cfg scalable 2 layer

o Konfigurasi program City.cfg scalable 3 layer

You might also like