⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpeg_lib.ps

📁 mpeng Lib
💻 PS
📖 第 1 页 / 共 4 页
字号:
1639 y(sibly)f(want)g(to)f(know)f(about)i(an)g(MPEG)g(str)n(eam\).)1361826 y Fh(\017)46 b Fl(SetMPEGOption\(\))21 b Fm(can)29b(be)e(used)g(to)g(contr)n(ol)g(somewhat)g(the)g(decoding)f(of)i(frames.)43 b(In)27 b(addition)227 1939 y(to)k(selecting)f(a)h(dithering)f(mode,)i(you)e(can)i(also)f(select)f(the)g(luminance)i(and)f(chr)n(ominance)h(ranges)227 2052 y(used)20 b(for)h(dithering.)26b(Also,)21 b(note)f(that)h Fl(SetMPEGOption\(\))15 bFm(should)20 b(be)h(called)h Fg(befor)n(e)i Fl(OpenMPEG\(\))2272165 y Fm(when)e(setting)f(the)h(dithering)g(method.)1362353 y Fh(\017)46 b Fm(The)32 b(MPEG)g(data)h(can)g(be)f(decoded)e(using)i(a)h(variety)f(of)g(dithering)g(methods.)55 b(\(Note)31b(that)h(in)g(this)227 2466 y(context,)j Fg(dithering)iFm(r)n(efers)c(to)g(converting)g(fr)n(om)h(the)f(luminance-chr)n(omaticity)-10 b(,)39 b(or)33 b(YCrCb,)k(colour)227 2579y(space)23 b(in)g(which)g(MPEG)f(data)h(is)g(encoded,)d(to)i(the)g(mor)n(e)h(conventional)g(RGB)f(scheme.\))136 2766 y Fh(\017)46b Fm(Y)-8 b(ou)34 b(don't)h(need)f(to)g(pass)h(any)g(parameters)f(to)hFl(GetMPEGFrame\(\))29 b Fm(or)35 b Fl(CloseMPEG\(\))30b Fm(to)k(tell)i(it)227 2879 y(which)22 b(MPEG)e(str)n(eam)h(you)f(mean;)i(this)e(is)h(because)g(the)f(Berkeley)e(decoding)i(engine)g(\(and)h(hence)f(the)227 2992 y(MPEG)h(Library)h(itself\))f(depends)d(heavily)k(on)f(global)h(variables,)h(and)e(unfortunately)f(cannot)h(decode)227 3105 y(mor)n(e)i(than)f(one)g(MPEG)h(at)g(a)g(time.)1413293 y(Mor)n(e)f(detailed)g(information)h(is)g(pr)n(ovided)f(in)h(sections)e(below)-8 b(.)0 3591 y Fo(3)119 b(Concepts)31b(and)f(Data)e(Formats)0 3802 y Fm(This)22 b(section)g(deals)h(with)f(the)g(main)i(concepts)d(needed)g(to)h(contr)n(ol)g(the)g(MPEG)h(Library)g(and)f(to)h(display)f(the)0 3915 y(data)31b(it)h(r)n(eturns.)52 b(It)30 b(does)g Fg(not)h Fm(deal)h(with)f(the)f(details)h(of)g(how)g(MPEG)g(str)n(eams)f(ar)n(e)i(encoded,)f(stor)n(ed,)g(or)0 4028 y(decoded.)0 4283 y Ff(3.1)99 b(Dithering)25b(modes)0 4460 y Fm(A)i(lar)n(ge)g(number)g(of)g(dithering)f(modes)g(\(in)i(fact,)h(all)f(the)e(modes)g(pr)n(ovided)g(by)h(the)g(original)hFl(mpeg)p 3626 4460 28 4 v 31 w(play)p Fm(\))0 4573 y(ar)n(e)g(available.)46 b(A)27 b(few)h(pr)n(oduce)e(nonsensical)h(r)n(esults,)h(but)f(all)i(have)f(been)f(fully)i(tested)c(in)j(the)f(context)f(of)04686 y(the)c(MPEG)g(Library)h(and)g(found)f(to)g(agr)n(ee)g(with)g(the)g(r)n(esults)g(given)g(by)h Fl(mpeg)p 2786 4686 V 31w(play)p Fm(.)141 4799 y(\223Dithering\224)29 b(in)f(this)g(context)f(is)h(the)f(conversion)g(fr)n(om)i(luminance-chr)n(ominance)i(colour)d(space)f(\(aka)0 4911 y(YCrCb,)33 b(YIQ,)d(or)g(YUV)-12b(,)30 b(which)h(is)f(how)g(MPEG)h(str)n(eams)e(ar)n(e)i(encoded)e(and)h(is)h(the)f(same)g(space)g(used)f(by)0 5024 y(NTSC)j(television)h(signals\))g(to)f(some)g(form)h(of)g(RGB)g(space.)58b(The)32 b(implementors)g(of)h Fl(mpeg)p 3380 5024 V31 w(play)e Fm(found)p 0 5111 1560 4 v 105 5168 a Fe(1)1345199 y Fj(For)24 b(an)h(even)f(mor)o(e)f(r)o(ealistic)g(\(but)i(of)f(course)f(considerably)g(lar)o(ger\))g(example,)h(take)g(a)h(look)e(at)i Fd(glmpeg)p 3292 5199 23 4 v 26 w(play)p Fj(.)39 b(This)24b(is)f(the)0 5291 y(full-featur)o(ed)14 b(MPEG)h(player)f(that)j(was)f(the)g(impetus)g(for)e(cr)o(eating)h(the)i(MPEG)e(Library;)f(it)i(is)f(available)h(by)g(fr)o(om)e(the)i(same)g(location)0 5382y(as)j(the)g(library)e(itself:)22 b Fd(ftp://ftp.bic.mni.mcgill.ca/pub/mpeg)p Fj(.)1927 5656y Fm(3)p eop%%Page: 4 44 3 bop 0 399 a Fm(that)29 b(outright)g(conversion)g(to)g(r)n(ed/gr)n(een/blue)f(values)i(takes)e(both)i(mor)n(e)f(time)h(and)f(memory)g(than)h(any)0 511 y(other)38 b(method)g(they)g(experimented)e(with,)43b(so)c(most)f(modes)g(ar)n(e)i(colour)f(mapped.)76 b(This)39b(means)g(that)0 624 y Fl(OpenMPEG\(\))15 b Fm(will)21b(cr)n(eate)e(a)i(colour)e(map)h(which)g(can)h(be)e(accessed)g(by)g(the)g(user)f(via)j(the)e Fl(ColormapEntry)0 737 y Fm(pointer)k(in)iFl(ImageDesc)p Fm(,)c(and)k(that)f(the)g(pixel)g(values)h(r)n(eturned)e(by)i Fl(GetMPEGFrame\(\))18 b Fm(ar)n(e)25 b(indeces)e(into)0850 y(this)e(colour)g(map.)27 b(The)21 b(dithering)f(mode)g(af)n(fects)h(the)g(quality)g(of)g(the)f(decoded)f(images,)i(the)f(number)h(of)g(bits)0 963 y(used)g(per)h(pixel,)g(and)h(the)f(colour)g(depth)f(of)i(the)f(image.)141 1076 y(The)g(dithering)f(mode)h(is)g(selected)f(with)h Fl(SetMPEGOption\(\))o Fm(,)17 b(using)k(the)h Fl(MPEG)p3085 1076 28 4 v 31 w(DITHER)e Fm(option)h(and)0 1189y(one)h(of)g(the)g(following)h(values:)150 1377 y Fl(ORDERED)p540 1377 V 30 w(DITHER:)320 b Fm(8-bit)34 b(colour)n(-mapped;)j(r)n(easonable)d(quality;)k(decoding)32 b(is)h(almost)12701489 y(as)22 b(fast)h(as)g Fl(GRAY)p 1875 1489 V 31 w(DITHER)1501677 y(ORDERED2)p 595 1677 V 29 w(DITHER:)266 b Fm(8-bit)23b(colour)n(-mapped;)f(r)n(easonable)h(quality)150 1865y Fl(MBORDERED)p 650 1865 V 29 w(DITHER:)211 b Fm(8-bit)23b(colour)n(-mapped;)f(r)n(easonable)h(quality)150 2052y Fl(FS4)p 320 2052 V 31 w(DITHER:)539 b Fm(8-bit)23b(colour)n(-mapped;)f(colours)g(ar)n(e)h(all)i(wr)n(ong)1502240 y Fl(FS2)p 320 2240 V 31 w(DITHER:)539 b Fm(8-bit)23b(colour)n(-mapped;)f(colours)g(ar)n(e)h(all)i(wr)n(ong)1502428 y Fl(FS2FAST)p 540 2428 V 30 w(DITHER:)320 b Fm(8-bit)18b(colour)f(mapped)f(using)h(Floyd-Steinber)n(g)e(err)n(or)i(dif)n(fusion;)i(r)n(ea-)1270 2540 y(sonable)j(quality)1502728 y Fl(HYBRID)p 485 2728 V 30 w(DITHER:)375 b Fm(8-bit)23b(colour)n(-mapped;)f(passable)h(colour)150 2916 y Fl(HYBRID2)p540 2916 V 30 w(DITHER:)320 b Fm(8-bit)23 b(colour)n(-mapped;)f(slightly)h(worse)e(than)h Fl(HYBRID)p 3268 2916 V 30w(DITHER)150 3103 y(Twox2)p 430 3103 V 30 w(DITHER:)430b Fm(8-bit)23 b(colour)n(-mapped)g(with)f(pixels)g(doubled;)g(poor)f(quality)150 3291 y Fl(GRAY)p 375 3291 V 31 w(DITHER:)484b Fm(a)31 b(256-shade)g(grayscale)g(r)n(endering;)i(nice)e(quality)g(and)g(fastest)f(de-)1270 3404 y(coding)150 3592 y Fl(FULL)p375 3592 V 31 w(COLOR)p 681 3592 V 30 w(DITHER:)179 bFm(a)32 b(high-quality)g(24-bit)h(colour)f(r)n(endering;)i(r)n(esults)d(in)h(slowest)e(de-)1270 3704 y(coding)150 3892 y Fl(MONO)p375 3892 V 31 w(DITHER:)484 b Fm(1-bit)36 b(monochr)n(ome)f(dithering;)41 b(use)35 b(as)g(last)h(r)n(esort)e(for)h(1-bit)i(dis-)12704005 y(plays)150 4193 y Fl(THRESHOLD)p 650 4193 V 29w(DITHER:)211 b Fm(??)0 4380 y(The)22 b(descriptions)f(her)n(e)h(ar)n(e)g(my)h(entir)n(ely)f(subjective)g(judgments)f(of)i(the)e(image)i(quality)g(with)f(each)h(dither)n(-)0 4493 y(ing)33 b(mode.)59b(\223Reasonable\224)33 b(quality)h(is)f(better)f(than)h(\223passable.\224)61 b(Y)-8 b(our)31 b(mileage)j(may)f(vary)-10b(.)60 b(\2238-bit\224)35 b(or)0 4606 y(\22324-bit\224)c(her)n(e)d(r)n(efers)f(to)h(the)f(colour)i(depth)d(in)j(the)f(\002nal)h(images,)h(i.e.)44 b(the)28 b(minimum)i(number)e(of)g(bits)h(al-)04719 y(located)h(to)f(each)h(pixel.)50 b(Authoritative)29b(information)i(about)e(the)h(actual)h(pixel)f(size)g(can)h(be)e(found)h(in)g(the)0 4832 y Fl(ImageDesc)22 b Fm(str)o(uctur)n(e)i(\002lled)i(in)g(by)f Fl(OpenMPEG\(\))p Fm(;)d(for)k(instance,)g(if)g(you)f(select)g Fl(FULL)p 3219 4832 V 31 w(COLOR)p 3525 4832V 30 w(DITHER)p Fm(,)0 4945 y(the)35 b(colour)g(depth)f(is)i(24)h(bits,)h(but)d(32)i(bits)f(ar)n(e)g(allocated)g(per)f(pixel.)66b(Thus,)38 b(the)d Fl(PixelSize)c Fm(\002eld)36 b(in)05058 y Fl(ImageDesc)19 b Fm(will)24 b(be)e(32,)h(and)g(the)fFl(Depth)e Fm(\002eld)j(will)h(be)e(24.)141 5171 y(Note)h(that)i(the)e(dithering)h(mode)g(must)g(be)g(set)g Fg(befor)n(e)jFl(OpenMPEG\(\))20 b Fm(is)25 b(called.)34 b(For)24 b(example,)h(to)f(select)0 5284 y(gray-scale)f(dithering)e(and)i(then)f(open)f(the)h(\002le)h Fl(example.mpg)18 b Fm(as)k(an)h(MPEG)g(str)n(eam:)19275656 y(4)p eop%%Page: 5 55 4 bop 273 399 a Fl(char)380 b(filename[])50 b(=)k("example.mpg";)273511 y(FILE)380 b(*mpeg;)273 624 y(ImageDesc)105 b(image;)273850 y(mpeg)52 b(=)j(fopen)d(\(filename,)e("r"\);)273963 y(SetMPEGOption)e(\(MPEG_DITHER,)h(\(int\))j(GRAY_DITHER\);)2731076 y(OpenMPEG)f(\(&image\);)0 1331 y Ff(3.2)99 b(Colour)26b(maps)0 1508 y Fm(Most)32 b(dithering)h(modes)e(r)n(esult)i(in)h(images)f(whose)f(pixel)h(values)h(ar)n(e)g(indeces)e(to)g(an)i(8-bit)h(colour)e(map.)0 1621 y(This)20 b(colour)g(map)h(is)g(accessed)e(via)j(the)d Fl(ImageDesc)e Fm(str)o(uctur)n(e,)i(and)i(it)f(is)h(cr)n(eated)e(by)i Fl(OpenMPEG\(\))16 b Fm(based)0 1733 y(on)24 b(the)g(dithering)f(type)g(selected)g(by)i Fl(SetMPEGOption\()o(\))19 bFm(\(this)24 b(is)h(why)f(the)f(dithering)h(type)f(must)h(be)g(set)01846 y(befor)n(e)i(calling)i Fl(OpenMPEG\(\))p Fm(\).)34b(Note)24 b(that)i(\2238-bit\224)j(r)n(efers)c(to)g(the)h(size)g(of)g(the)g(colour)g(map:)35 b(each)26 b(pixel)h(in)0 1959y(the)22 b(colour)n(-mapped)g(images)h(is)f(8)i(bits)e(long,)g(so)g(the)g(colour)g(map)i(itself)e(has)h(256)h(entries.)1412072 y(The)i(colour)h(map)h(is)f(accessed)f(via)i(the)eFl(Colormap)e Fm(\002eld)j(of)g Fl(ImageDesc)p Fm(,)c(which)28b(points)e(to)g(an)i(array)0 2185 y(of)23 b Fl(ColormapSize)17b Fm(colour)22 b(map)i(entries.)i(Each)d(colour)g(map)g(entry)e(is)i(a)g(str)o(uctur)n(e)e(of)i(the)f(form)0 2373 y Fl(typedef)51b(struct)0 2486 y({)164 2599 y(short)h(red,)h(green,)e(blue;)02711 y(})j(ColormapEntry;)0 2899 y Fm(and)27 b(the)f(colour)h(map)h(is)f(cr)n(eated)f(when)h Fl(OpenMPEG\(\))22 b Fm(is)27 b(called.)42b(If)27 b(no)g(colour)g(map)h(is)f(cr)n(eated)f(\(i.e.,)i(the)03012 y(dithering)c(mode)g(is)g Fl(FULL)p 967 3012 284 v 31 w(COLOR)p 1273 3012 V 31 w(DITHER)p Fm(\),)e(then)iFl(ColormapSize)19 b Fm(will)26 b(be)f(-1)g(and)g Fl(Colormap)cFm(will)26 b(be)0 3125 y Fl(NULL)p Fm(.)21 b(For)g(example:)1643313 y Fl(char)325 b(*filename;)164 3425 y(FILE)g(*MPEG;)1643538 y(ImageDesc)50 b(MPEGInfo;)164 3764 y(filename)h(=)j(argv[1];)1643990 y(/*)f(Prepare)f(to)h(read)g(and)g(decode)f(an)i(MPEG)e(stream)g(*/)164 4216 y(MPEG)g(=)i(fopen)f(\(filename,)d("rb"\);)1644329 y(if)j(\(!OpenMPEG)d(\(MPEG,)i(&MPEGInfo\)\))3274442 y(exit;)164 4667 y(/*)h(Do)h(we)g(have)e(a)i(colour-mapped)49b(mode?)j(*/)164 4893 y(if)h(\(MPEGInfo.Color)o(map)48b(!=)53 b(NULL\))164 5006 y({)327 5119 y(for)g(\(i)h(=)g(0;)g(i)g(<)g(MPEGInfo.Colorm)o(ap)o(Si)o(ze)o(;)49 b(i++\))327 5232y({)491 5345 y(mapcolor)i(\(i,)i(MPEGInfo.Colorm)o(ap)o([i)o(].)o(red)o(,)1927 5656 y Fm(5)p eop%%Page: 6 66 5 bop 1200 399 a Fl(MPEGInfo.Colorm)o(ap)o([i)o(].)o(gre)o(en)o(,)1200 511 y(MPEGInfo.Colorm)o(ap)o([i)o(].)o(blu)o(e\))o(;)327624 y(})164 737 y(})164 850 y(/*)53 b(...)g(*/)0 1029y Fm(Her)n(e,)21 b(we)i(assume)e(that)i(the)f(function)gFl(mapcolor\(\))d Fm(is)j(available)k(to)c(set)f(the)h(system)f(colour)i(map.)0 1282 y Ff(3.3)99 b(Image)24 b(data)h(format)01459 y Fm(The)f(image)h(data,)g(as)g(r)n(eturned)e(by)iFl(GetMPEGFrame\(\))p Fm(,)19 b(is)25 b(formatted)f(in)h(a)g(straightforwar)n(d)f(way)-10 b(.)34 b(Pixels)0 1572y(ar)n(e)c(stor)n(ed)e(in)i(r)n(ow-major)g(or)n(der)-7b(,)30 b(starting)f(at)g(the)g(upper)f(left-hand)i(corner)f(of)g(the)g(image.)49 b(The)28 b(number)0 1685 y(of)g(bits)g(allocated)h(per)e(pixel)i(is)f(given)g(by)g(the)f Fl(PixelSize)e Fm(\002eld)i(of)hFl(ImageDesc)p Fm(.)41 b(This)28 b(is)g(illustrated)g(in)01798 y(Figur)n(e)f(1,)i(which)f(shows)e(a)i(sample)gFc(8)c Fh(\002)g Fc(10)p Fm(-pixel)29 b(image,)f(with)g(the)f(of)n(fset)g(into)g(the)g(image)h(data)f(for)h(each)0 1910y(pixel.)g(If)23 b(the)e(pixels)i(ar)n(e)g(8)g(bits)f(each,)h(then)f(this)g(will)i(be)f(a)g(simple)f(byte)g(of)n(fset.)12002032 y 11840716 9472573 0 0 11840716 9472573 startTexFig 1200 2032 a%%BeginDocument: image_format.eps/$F2psDict 32 dict def $F2psDict begin	$F2psDict /mtrx matrix put	end	/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def	/$F2psEnd {$F2psEnteredState restore end} def	%%EndProlog$F2psBegin1 setlinecap 1 setlinejoin-162 108 translate0.000000 144.000000 translate 0.900 -0.900 scale1.000 setlinewidth% Polylinenewpath 219 119 moveto 219 279 lineto  stroke% Polylinenewpath 259 119 moveto 259 279 lineto  stroke% Polylinenewpath 279 119 moveto 279 279 lineto  stroke% Polylinenewpath 339 119 moveto 339 279 lineto  stroke% Polylinenewpath 359 119 moveto 359 279 lineto  stroke% Polylinenewpath 379 119 moveto 379 279 lineto  stroke% Polylinenewpath 239 119 moveto 239 279 lineto  stroke% Polylinenewpath 299 119 moveto 299 279 lineto  stroke% Polylinenewpath 319 119 moveto 319 279 lineto  stroke% Polylinenewpath 179 139 moveto 379 139 lineto  stroke% Polylinenewpath 179 159 moveto 379 159 lineto  stroke% Polylinenewpath 179 179 moveto 379 179 lineto  stroke% Polylinenewpath 179 199 moveto 379 199 lineto  stroke% Polylinenewpath 179 219 moveto 379 219 lineto  stroke% Polylinenewpath 179 239 moveto 379 239 lineto  stroke% Polylinenewpath 179 259 moveto 379 259 lineto  stroke% Polylinenewpath 179 279 moveto 379 279 lineto  stroke% Polylinenewpath 179 119 moveto 379 119 lineto  stroke% Polylinenewpath 199 119 moveto 199 279 lineto  stroke% Polylinenewpath 179 119 moveto 179 279 lineto  stroke/Courier findfont 12.000 scalefont setfont364 274 moveto 1 -1 scale(79) gsave  0.000 rotate show grestore 1 -1 scale/Courier findfont 12.000 scalefont setfont

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -