26
Confidential MPEG-2 System DM사업부 SW2팀 강성곤 2008.04.08

MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

MPEG-2 System

DM사업부 SW2팀 강성곤

2008.04.08

Page 2: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential 1

Contents

Goal

Introduction

Packet structure

Timestamp & Clock reference

PSI

Packet analyzer demo

Reference

Q/A

Page 3: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Goal

2

Actual practice

Logical understand

STB 내부의 packet process 이해

Page 4: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Introduction – MPEG-2 system?

3

Clock control

M

U

X

D

E

M

U

X

Encoding

Encoding

Clock control

Decoding

Decoding

전달 미디어Cable

전파

Ancillary data

Page 5: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Introduction – PS vs TS

Program Stream– 저장용 stream

– 전송에러가 없는 (error-free) 전송 매체에 이용

– 가변 길이의 pack으로 구성

– 27MHz 단위의 SCR (System Clock Reference)을 사용

Transport Stream– 전송용 stream

– 전송에러가 존재하는 (error-prone) 전송 매체에 이용

– 일정한 길이 (188byte)의 packet으로 구성

– 27MHz 단위의 PCR (Program Clock Reference)을 사용

– (Almost) de facto standard

4

Page 6: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Introduction – ATM & TS packet

Asynchronous Transfer Mode– 한 개의 회선을 여러 개의 채널로 분할해서 동시에 통신을 시행하는

multiplexing 방식의 하나

– 47byte마다 분할되며 5byte의 header와 1byte의 AAL (ATM Adaptation Layer)이 부가되어 53byte의 ATM cell이 생성되어 송/수신에 사용됨

Why TS packet size is 188byte?– ATM cell payload size (47) * 4 = 188

– Packet의 크기를 일정하게 유지하면 multiplexing/re-multiplexing/demultiplexing이 용이하며 전송 오차시의 손실이 적음

– 기존의 전송망인 ATM 망과의 호환성을 보장함

5

Page 7: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Introduction - Packetization

6

frame 2 frame 1Audio

ES......

Video

ES B B PB PB B I ......

PES

Packet B B Pfrm1PB B ...... I B

PES packet header

packet

TS packet (188Bytes)

TS

Stream......

TS packet header

stuffing stuffing stuffing

B

Page 8: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Introduction – I/P/B picture

Intra picture– 시간적 압축기술을 사용하지 않고 공간적인 압축 기술만을 사용

– 움직임 예측을 사용하지 않기 때문에 encoding시 많은 bit를 생성

– 단독으로 decoding 가능하므로 random access가 가능 (독립성)

Predictive picture– 이전의 I picture 정보 또는 P picture로부터의 예측을 수행하여 생성

– 차이 값만을 encoding하여 압축을 하게 됨

Bidirectionally predictive picture– 순방향 뿐만이 아니라 역방향 예측까지 포함해서 좀 더 세밀하게

예측함으로써 발생되는 bit를 줄임

– 그러나 역방향 예측으로 인하여 picture들을 재순서화해야 함

– 발생 bit가 적어지는 만큼 오류 발생률도 높아짐 => 질에 따라 조절 필요

7

Page 9: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Introduction - Compression

일반적으로 영상은 상관도가 높기 때문에 (인접화소간의값이 거의 비슷함) 공간적 상관관계를 이용하여 정보를압축

이전 화면과 현재 화면의 차분치로 나타냄으로써 시간적상관관계를 이용해 정보를 압축

위의 2가지 방법으로 부호화 할 때에, 부호의 발생확률이서로 다름을 이용하여 정보를 압축

8

Page 10: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Timestamp & Clock reference

DTS (Decoding Time Stamp)– Elementary stream이 decoding되는 시점

– PES packet header에 위치

PTS (Presentation Time Stamp)– Decoding된 access unit이 재생되는 시점

– PES packet header에 위치

PCR (Program Clock Reference)– TS에서 program에 대한 시간 기준값

– TS packet adaptation field에 위치

9

Page 11: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Timestamp & Clock reference

10

TS

depacketizer

A/V PES

depacketizer

A/V PTS/DTS

extraction

elementary stream

BUF / decoder

decoded

stream memory

D/A matrixing

monitor

D/A

amp/speaker

PCR counter

lower 33bits

decoder clock recovery block

A/V DTS

comparator

A/V PTS

comparator

decoding & display control

PCR

A/V PES stream elementary stream decoded stream

PES header

A/V DTS A/V PTS

A/V ODTS

A/V OPTS

A/V decode start signal

A/V presentation start signal

Video(digital)

audio(digital)

Audio(analog)Video(analog)

Page 12: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Packet structure – PES packet

Packetized Elementary Stream

11

streamID

PESpacketlength

PESheader

packetstartcode

PES packet data bytes

24 8 16

PESpriority

PESscrambling

control

2 2 1 1 1 1 8 8

dataalignmentindicator

10 originalor copy

PES headerdata

length

7flags

optionalfields

stuffing(0XFF)

PTSDTS

33 42 22 8 7 16

33

ERrate

additionalcopyinfo

PES extension

previousPESCRC

DSMtrick

modeESCR

copy-right

Page 13: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Packet structure – TS packet

Transport Stream

12

splicecountdown

discontinuityindicator

adaptationfield

length

8 1 1 1 5 1

ESpriority

indicator

randomaccess

indicator

5flags

optionalfields

stuffing

transporterror

indicator

payloadunit startindicator

PIDsyncbyte

8 1 1 1 13 2 2 4

transportpriority

transportscrambling

control

adaptationfield

control

continuitycounter

adaptationfield

PCR

42 42 8 9 5 3

optionalfields

3flags

TSprivate

data lengthOPCR

TSprivatedata

adaptationfield extension

length

header

4 byte 184 byte

payload header payload header payload

Page 14: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Packet structure – PUSI

Payload Unit Start Indicator

TS packet 내에 PES/PSI header가 존재 (always first byte)

– Payload가 새로운 PES packet이면 PES header가…

– Payload가 PSI이면 Pointer filed를…

13

TS

PacketB Pfrm1 ......

TS headerTS packet

adaptation fieldPES header

PUSI=1 PUSI=0 PUSI=0 PUSI=0 PUSI=1PUSI=1PUSI=0 PUSI=0

video ESPES

Packetfrm1Audio ES

PES header

...Audio ESVideo ES

Page 15: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

PSI - Outline

Program Specific Information– MPEG-2에서 TS의 demux 및 program presentation에 필요한 data

– Demultiplexer는 demux 수행 전 ES의 PID를 확인

• PAT : Program Association Table (PID : 0x00)

• PMT : Program Map Table (PID : Assigned by PAT)

• NIT : Network Information Table (PID : Assigned by PAT, PGM : 0x00)

• CAT : Conditional Access Table (PID : 0x01)

• Private section : User define (limit 4096 bytes)

– Decoder는 PID가 0인지 (PAT?) 감지 후 다음 작업 수행

– Pointer Field : PSI의 section이 시작될 offset을 알려주는 8bit field

– 각 PSI들의 CRC32는 header 4bytes를 제외한 payload길이만큼의 값

14

Page 16: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

PSI - PAT

Program Associate Table

15

networkPID

program number 0

16 3 13 16 3 13

section syntax

indicator‘0’

tableid

8 1 1 2 12 16 2 5 1 8 8 32

sectionlength

versionnumber

currentnext

indicator

sectionnumber

N looptransportstream

id

lastsectionnumber

CRC32

programmapPID i

program number i

Page 17: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

PSI – table id

16

0xFF

Page 18: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

PSI - PMT

Program Map Table

17

elementaryPID

streamtype

8 3 13 4 12

ES infolength

section syntax

indicator‘0’

tableid

8 1 1 2 12 16 2 5 1 8 8 3 13 4

sectionlength

versionnumber

currentnext

indicator

sectionnumber

N loop

programnumber

lastsectionnumber

PCRPID

N loopdescriptors

CRC32program

infolength

N loopdescriptors

12 32

Page 19: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

PSI – Stream type

18

Page 20: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

PSI - Descriptor

Program과 program element를 규정하기 위해 사용

공통적으로 다음 두 개의 field로 시작됨– descriptor_tag (8bits) : 각 descriptor를 규정

– descriptor_length (8bits) : 바로 다음 byte부터 끝까지의 byte 수

Tag의 내용은 다음을 참조– MPEG-2 system part

– DVB-SI 300 468 (european)

– Any other specific documents…

19

Page 21: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

PSI – TS packet detection

Tuner locking

Demodulator locking

Find TS sync byte (0x47) (1st)

188 byte skip and check TS sync byte (2nd)

188 byte skip and check TS sync byte (3rd)– 3번 연속으로 성공하면? “Locking”

– 틀리면 다시 처음부터…

20

Page 22: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

PSI – Select program

Tuner acquisition

FEC (Forward Error Correction)

System demux for PID=0 (PAT)

System demux for PGM#1 (PID=100)

Decode PID=101 (video) and PID=102 (audio)

21

Program Association Table

PGM # PMT PID

1 100

2 200

3 300

audiovideo video

program # 3

video PID 301

audio PID 302

Program Map Table

program # 1

video PID 101

audio PID 102

Program Map Tableprogram # 2

video PID 201

audio PID 202

Program Map Table

101 201 301 101 201 102302 201 301 301100 200 3000

Page 23: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Packet analyzer demo - dvbsnoop

dvbsnoop is a DVB / MPEG stream analyzer program.

Its purpose is to debug, dump or view stream information (e.g. digital television broadcasts) send via satellite, cable or terrestrial. Streams can be SI, PES or transport streams. DSM-CC and MHP will follow...Basically you can describe dvbsnoop as a simple stream analyzing program, similar to TCP network sniffer programs like snoop …

22

Page 24: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Reference

ISO/IEC 13818-1

ISO 639-2

ETSI DVB-SI 300 468

HUMAX 사내교육 자료 (Juha Park)

MPEG 시스템 (브레인코리아)

그림으로 보는 최신 MPEG (교보문고)

Dvbsnoop (http://dvbsnoop.sourceforge.net/)

23

Page 25: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Q/A

24

Page 26: MPEG-2 System · 2015-01-22 · 0 100 200 300 101 201 301 101 201 302 102 201 301 301. Confidential Packet analyzer demo - dvbsnoop dvbsnoop is a DVB / MPEG stream analyzer program

Confidential

Thank you!

25