00001
00002 #ifndef Impala_Core_VideoSet_RgbDataSrcLavcTestGUI_h
00003 #define Impala_Core_VideoSet_RgbDataSrcLavcTestGUI_h
00004
00005 #include "Basis/CmdOptions.h"
00006 #include "Core/Array/Arrays.h"
00007 #include "Core/Array/Pattern/PatBinaryPixOp.h"
00008 #include "Core/Array/Trait/BpoTestEqual.h"
00009 #include "Core/Geometry/Rectangle.h"
00010 #include "Core/Stream/RgbDataSrc.h"
00011 #include "Core/Stream/RgbDataSrcFactory.h"
00012 #include "Core/VideoSet/MakeVideoSet.h"
00013 #include "OglGui/DropDownWindow.h"
00014 #include "OglGui/StaticText.h"
00015 #include "OglGui/TextField.h"
00016 #include "OglGui/CheckBox.h"
00017 #include "OglGui/ScrollWnd.h"
00018 #include "OglGui/StringSelector.h"
00019 #include "OglGui/Strut.h"
00020 #include "OglGui/Tabs.h"
00021 #include "OglGui/SizableWindow.h"
00022 #include "Visualization/VideoNav.h"
00023 #include "Visualization/AppControlSrc.h"
00024 #undef Next
00025 #include <sstream>
00026
00027 enum FRAME_TYPE{
00028 I_FRAME=1,
00029 P_FRAME=2,
00030 B_FRAME=3,
00031 S_FRAME=4,
00032 SI_FRAME=5,
00033 SP_FRAME=6,
00034 };
00035
00036 namespace Impala
00037 {
00038 namespace Visualization
00039 {
00040
00041 using namespace Util;
00042 using namespace OglGui;
00043 using namespace Core::Array;
00044 using namespace Core::Stream;
00045 using namespace Core::VideoSet;
00046
00047
00048
00049 class PropertySheet:public Window
00050 {
00051 public:
00052 PropertySheet(Window* W, int w, int h)
00053 :Window(W,w,h,true)
00054 {
00055 mScrl=new ScrollWnd(this,w-6,h-6);
00056 mScrl->ConnectTo(this, ALLSIDES);
00057
00058 }
00059
00060 OglGui::Window* ContentPane(){
00061 return mScrl->ContentPane();
00062 }
00063 private:
00064 ScrollWnd* mScrl;
00065
00066 };
00067
00068
00069
00070 class PropCtrl:public OglGui::Window
00071 {
00072 public:
00073 PropCtrl(OglGui::Window* parent,int width, int height,
00074 std::string Name,std::string Value)
00075 :OglGui::Window(parent, width, height)
00076 {
00077 mName = new StaticText(this,(width-20)/2,20,Name,false);
00078 mValue = new StaticText(this,(width-20)/2,20,Value,false);
00079 mValue->SetBackground(oglWHITE);
00080 }
00081 void Update(std::string Value){
00082 if((mValue->GetText()!=Value)&&(mValue->GetText()!=""))
00083 mValue->SetBackground(oglRED);
00084 mValue->SetText(Value);
00085 }
00086 private:
00087 StaticText* mName;
00088 StaticText* mValue;
00089 };
00090
00091
00092 class PropertyHolder:public OglGui::DropDownWindow{
00093 public:
00094 PropertyHolder(Window* parent,int width,int height,std::string Name)
00095 :DropDownWindow(parent,width,height,Name)
00096 {
00097 DropDown(true);
00098 }
00099
00100 void AddProp(std::string Prop,std::string Value){
00101 PropCtrl* p=new PropCtrl(this,W()-30,20,Prop,Value);
00102 mPropCtrls[Prop]=p;
00103 AddWindow(p);
00104 }
00105 void AddPropHolder(PropertyHolder* ph){
00106 AddWindow((Window*)ph);
00107 }
00108
00109 void UpdateCtrl(std::string Prop,std::string Value){
00110 mPropCtrls[Prop]->Update(Value);
00111 }
00112 void UpdateCtrl(std::string Prop,char* Value){
00113 if((Value==NULL)||(Value==0))
00114 mPropCtrls[Prop]->Update(std::string("NULL"));
00115 else
00116 mPropCtrls[Prop]->Update(std::string(Value));
00117 }
00118
00119 void UpdateCtrl(std::string Prop,bool Value){
00120 std::string val = (Value?"True":"False");
00121 mPropCtrls[Prop]->Update(val);
00122 }
00123 void UpdateCtrl(std::string Prop,unsigned int Value){
00124 std::ostringstream oss;
00125 oss<<Value;
00126 mPropCtrls[Prop]->Update(oss.str());
00127 }
00128 void UpdateCtrl(std::string Prop,int Value){
00129 std::ostringstream oss;
00130 oss<<Value;
00131 mPropCtrls[Prop]->Update(oss.str());
00132 }
00133 void UpdateCtrl(std::string Prop,int64_t Value){
00134 std::ostringstream oss;
00135 oss<<Value;
00136 mPropCtrls[Prop]->Update(oss.str());
00137 }
00138
00139 void UpdateCtrl(std::string Prop,float Value){
00140 std::ostringstream oss;
00141 oss<<Value;
00142 mPropCtrls[Prop]->Update(oss.str());
00143 }
00144
00145 void UpdateCtrl(std::string Prop,AVRational Value){
00146 std::ostringstream oss;
00147 oss<<Value.num<<" / "<<Value.den;
00148 mPropCtrls[Prop]->Update(oss.str());
00149 }
00150 void UpdateCtrl(std::string Prop,AVFrac& Value){
00151 std::ostringstream oss;
00152 oss<<Value.val<<" + "<<Value.num<<" / "<<Value.den;
00153 mPropCtrls[Prop]->Update(oss.str());
00154 }
00155 void UpdateCtrl(std::string Prop,enum AVDiscard Value){
00156 std::string val;
00157 switch(Value){
00158 case AVDISCARD_NONE:
00159 val="AVDISCARD_NONE";break;
00160 case AVDISCARD_DEFAULT:
00161 val="AVDISCARD_DEFAULT";break;
00162 case AVDISCARD_NONREF:
00163 val="AVDISCARD_NONREF";break;
00164 case AVDISCARD_BIDIR:
00165 val="AVDISCARD_BIDIR";break;
00166 case AVDISCARD_NONKEY:
00167 val="AVDISCARD_NONKEY";break;
00168 case AVDISCARD_ALL:
00169 val="AVDISCARD_ALL";break;
00170 }
00171 mPropCtrls[Prop]->Update(val);
00172 }
00173 void UpdateCtrl(std::string Prop,enum FRAME_TYPE Value){
00174 std::string val;
00175 std::ostringstream oss;
00176 switch(Value){
00177 case I_FRAME:
00178 val="I Frame";break;
00179 case B_FRAME:
00180 val="B Frame";break;
00181 case P_FRAME:
00182 val="P Frame";break;
00183 case S_FRAME:
00184 val="S Frame";break;
00185 case SI_FRAME:
00186 val="SI Frame";break;
00187 case SP_FRAME:
00188 val="SP Frame";break;
00189 default:
00190 oss<<"Unknown Type: "<<Value;
00191 val=oss.str();
00192 }
00193 mPropCtrls[Prop]->Update(val);
00194 }
00195 private:
00196 std::map<std::string,PropCtrl*> mPropCtrls;
00197 };
00198
00199 class AVPacketDD:public PropertyHolder{
00200 public:
00201 AVPacketDD(Window* parent,int width,int height,std::string Name="AVPacket")
00202 :PropertyHolder(parent,width,height,Name)
00203 {
00204 AddProp("pts","");
00205 AddProp("dts","");
00206 AddProp("size","");
00207 AddProp("pos","");
00208 AddProp("stream_index","");
00209 AddProp("flags","");
00210 AddProp("duration","");
00211 }
00212 void Update(AVPacket* p){
00213 UpdateCtrl("pos",p->pos);
00214 UpdateCtrl("pts",p->pts);
00215 UpdateCtrl("dts",p->dts);
00216 UpdateCtrl("size",p->size);
00217 UpdateCtrl("stream_index",p->stream_index);
00218 UpdateCtrl("flags",std::string(p->flags?"KeyFrame":"Non-KeyFrame"));
00219 UpdateCtrl("duration",p->duration);
00220 }
00221 };
00222
00223 class AVStreamDD:public PropertyHolder{
00224 public:
00225 AVStreamDD(Window* parent,int width,int height,std::string Name="AVStream")
00226 :PropertyHolder(parent,width,height,Name)
00227 {
00228 AddProp("pts","");
00229 AddProp("cur_dts","");
00230 AddProp("last_IP_pts","");
00231 AddProp("last_IP_duration","");
00232 AddProp("id","");
00233 AddProp("index","");
00234 AddProp("time_base","");
00235 AddProp("r_frame_rate","");
00236 AddProp("pts_wrap_bits","");
00237 AddProp("stream_copy","");
00238 AddProp("discard","");
00239 AddProp("quality","");
00240 AddProp("start_time","");
00241 AddProp("duration","");
00242 AddProp("language","");
00243 AddProp("nb_index_entries","");
00244 AddProp("nb_frames","");
00245 }
00246 void
00247 Update(AVStream* s){
00248 UpdateCtrl("index",s->index);
00249 UpdateCtrl("id",s->id);
00250 UpdateCtrl("cur_dts",s->cur_dts);
00251 UpdateCtrl("pts",s->pts);
00252 UpdateCtrl("time_base",s->time_base);
00253 UpdateCtrl("r_frame_rate",s->r_frame_rate);
00254 UpdateCtrl("pts_wrap_bits",s->pts_wrap_bits);
00255 UpdateCtrl("stream_copy",s->stream_copy);
00256 UpdateCtrl("discard",s->discard);
00257 UpdateCtrl("quality",s->quality);
00258 UpdateCtrl("start_time",s->start_time);
00259 UpdateCtrl("duration",s->duration);
00260 UpdateCtrl("language",s->language);
00261 UpdateCtrl("last_IP_duration",s->last_IP_duration);
00262 UpdateCtrl("last_IP_pts",s->last_IP_pts);
00263 UpdateCtrl("nb_index_entries",s->nb_index_entries);
00264 UpdateCtrl("nb_frames",s->nb_frames);
00265 }
00266 };
00267
00268
00269 class ByteIOContextDD:public PropertyHolder{
00270 public:
00271 ByteIOContextDD(Window* parent,int width,int height,std::string Name="AVFormat")
00272 :PropertyHolder(parent,width,height,Name)
00273 {
00274 AddProp("pos","");
00275 AddProp("fpos","");
00276 AddProp("must_flush","");
00277 AddProp("eof_reached","");
00278 AddProp("write_flag","");
00279 AddProp("is_streamed","");
00280 AddProp("max_packet_size","");
00281 AddProp("error","");
00282 }
00283 void Update(ByteIOContext* b)
00284 {
00285 UpdateCtrl("pos",b->pos);
00286 UpdateCtrl("fpos",url_ftell(b));
00287 UpdateCtrl("must_flush",b->must_flush);
00288 UpdateCtrl("eof_reached",b->eof_reached);
00289 UpdateCtrl("write_flag",b->write_flag);
00290 UpdateCtrl("is_streamed",b->is_streamed);
00291 UpdateCtrl("max_packet_size",b->max_packet_size);
00292 UpdateCtrl("error",b->error);
00293 }
00294 };
00295 class AVFormatDD:public PropertyHolder{
00296 public:
00297 AVFormatDD(Window* parent,int width,int height,std::string Name="AVFormat")
00298 :PropertyHolder(parent,width,height,Name)
00299 {
00300 mPb = new ByteIOContextDD(this,width-20,height,"pb");
00301 mCurPkt = new AVPacketDD(this,width-20,height,"cur_pkt");
00302 AddWindow(mPb);
00303 AddWindow(mCurPkt);
00304 AddProp("cur_len","");
00305 AddProp("cur_ptr","");
00306 AddProp("filename","");
00307 AddProp("nb_streams","");
00308 AddProp("title","");
00309 AddProp("author","");
00310 AddProp("copyright","");
00311 AddProp("comment","");
00312 AddProp("album","");
00313 AddProp("year","");
00314 AddProp("track","");
00315 AddProp("genre","");
00316 AddProp("ctx_flags","");
00317 AddProp("start_time","");
00318 AddProp("duration","");
00319 AddProp("file_size","");
00320 AddProp("bit_rate","");
00321 AddProp("data_offset","");
00322 AddProp("index_built","");
00323 AddProp("mux_rate","");
00324 AddProp("packet_size","");
00325 AddProp("preload","");
00326 AddProp("max_delay","");
00327 AddProp("loop_output","");
00328 AddProp("flags","");
00329 #if LIBAVFORMAT_VERSION_INT >= ((51<<16)+(14<<8)+0)
00330 AddProp("loop_input","");
00331 AddProp("probesize","");
00332 #endif
00333
00334 for(int i=0;i<MAX_STREAMS;i++){
00335 mStreams[i]=0;
00336 }
00337 mStreamsDD = new DropDownWindow(this,width-20,height,"streams");
00338 AddWindow(mStreamsDD);
00339 };
00340 void Update(AVFormatContext* f){
00341 UpdateCtrl("filename",f->filename);
00342 UpdateCtrl("nb_streams",f->nb_streams);
00343 UpdateCtrl("title",f->title);
00344 UpdateCtrl("author",f->author);
00345 UpdateCtrl("copyright",f->copyright);
00346 UpdateCtrl("comment",f->comment);
00347 UpdateCtrl("album",f->album);
00348 UpdateCtrl("year",f->year);
00349 UpdateCtrl("track",f->track);
00350 UpdateCtrl("genre",f->genre);
00351 UpdateCtrl("ctx_flags",f->ctx_flags);
00352 UpdateCtrl("start_time",f->start_time);
00353 UpdateCtrl("duration",f->duration);
00354 UpdateCtrl("file_size",f->file_size);
00355 UpdateCtrl("bit_rate",f->bit_rate);
00356 UpdateCtrl("cur_len",f->cur_len);
00357 UpdateCtrl("cur_ptr",f->cur_ptr);
00358 UpdateCtrl("data_offset",f->data_offset);
00359 UpdateCtrl("index_built",f->index_built);
00360 UpdateCtrl("mux_rate",f->mux_rate);
00361 UpdateCtrl("packet_size",f->packet_size);
00362 UpdateCtrl("preload",f->preload);
00363 UpdateCtrl("max_delay",f->max_delay);
00364 UpdateCtrl("loop_output",f->loop_output);
00365 UpdateCtrl("flags",f->flags);
00366 #if LIBAVFORMAT_VERSION_INT >= ((51<<16)+(14<<8)+0)
00367 UpdateCtrl("loop_input",f->loop_input);
00368 UpdateCtrl("probesize",f->probesize);
00369 #endif
00370 mPb->Update(&f->pb);
00371 mCurPkt->Update(&f->cur_pkt);
00372 for(int i=0;i<f->nb_streams;i++){
00373 if(mStreams[i]==0){
00374 std::ostringstream oss;
00375 oss<<"Stream "<<i<<":"<<W();
00376 mStreams[i] = new AVStreamDD(mStreamsDD,W()-30,20,oss.str());
00377 mStreamsDD->AddWindow((mStreams[i]));
00378 }
00379 mStreams[i]->Update(f->streams[i]);
00380 }
00381
00382 }
00383
00384 AVStreamDD* mStreams[MAX_STREAMS];
00385 AVPacketDD* mCurPkt;
00386 ByteIOContextDD* mPb;
00387 DropDownWindow* mStreamsDD;
00388 };
00389
00390
00391 class AVCodecDD:public PropertyHolder{
00392 public:
00393 AVCodecDD(Window* parent,int width,int height,std::string Name="AVFormat")
00394 :PropertyHolder(parent,width,height,Name)
00395 {
00396 AddProp("internal_buffer_count","");
00397 AddProp("frame_number","");
00398 AddProp("real_pict_num","");
00399 AddProp("codec_name","");
00400 AddProp("codec_type","");
00401 AddProp("codec_id","");
00402 AddProp("codec_tag","");
00403 AddProp("gop_size","");
00404 AddProp("flags","");
00405 AddProp("sub_id","");
00406 AddProp("me_method","");
00407 AddProp("time_base","");
00408 AddProp("frame_size","");
00409 AddProp("width","");
00410 AddProp("height","");
00411 AddProp("sample_aspect_ratio","");
00412 AddProp("coded_width","");
00413 AddProp("coded_height","");
00414 AddProp("bit_rate","");
00415 AddProp("bit_rate_tolerance","");
00416 AddProp("hurry_up","");
00417 AddProp("skip_count","");
00418 AddProp("timecode_frame_start","");
00419 AddProp("pix_fmt","");
00420 AddProp("rate_emu","");
00421 AddProp("sample_rate","");
00422 AddProp("channels","");
00423 AddProp("sample_fmt","");
00424 AddProp("delay","");
00425 AddProp("qcompress","");
00426 AddProp("qblur","");
00427 AddProp("qmin","");
00428 AddProp("qmax","");
00429 AddProp("max_qdiff","");
00430 AddProp("max_b_frames","");
00431 AddProp("b_quant_factor","");
00432 AddProp("b_frame_strategy","");
00433 AddProp("rtp_payload_size","");
00434 AddProp("mv_bits","");
00435 AddProp("header_bits","");
00436 AddProp("i_tex_bits","");
00437 AddProp("p_tex_bits","");
00438 AddProp("i_count","");
00439 AddProp("p_count","");
00440 AddProp("misc_bits","");
00441 AddProp("frame_bits","");
00442 AddProp("workaround_bugs","");
00443 AddProp("luma_elim_threshold","");
00444 AddProp("chroma_elim_threshold","");
00445 AddProp("strict_std_compliance","");
00446 AddProp("b_quant_offset","");
00447 AddProp("error_resilience","");
00448 AddProp("has_b_frames","");
00449 AddProp("block_align","");
00450 AddProp("parse_only","");
00451 AddProp("mpeg_quant","");
00452 AddProp("stats_out","");
00453 AddProp("stats_in","");
00454 AddProp("rc_qsquish","");
00455 AddProp("rc_qmod_amp","");
00456 AddProp("rc_qmod_freq","");
00457 AddProp("rc_override_count","");
00458 AddProp("rc_eq","");
00459 AddProp("rc_max_rate","");
00460 AddProp("rc_min_rate","");
00461 AddProp("rc_buffer_size","");
00462 AddProp("rc_buffer_aggressivity","");
00463 AddProp("i_quant_factor","");
00464 AddProp("i_quant_offset","");
00465 AddProp("rc_initial_cplx","");
00466 AddProp("dct_algo","");
00467 AddProp("lumi_masking","");
00468 AddProp("temporal_cplx_masking","");
00469 AddProp("spatial_cplx_masking","");
00470 AddProp("p_masking","");
00471 AddProp("dark_masking","");
00472 AddProp("unused","");
00473 AddProp("idct_algo","");
00474 AddProp("slice_count","");
00475 AddProp("slice_offset","");
00476 AddProp("error_concealment","");
00477 AddProp("dsp_mask","");
00478 AddProp("bits_per_sample","");
00479 AddProp("prediction_method","");
00480 AddProp("debug","");
00481 AddProp("debug_mv","");
00482 AddProp("error","");
00483 AddProp("mb_qmin","");
00484 AddProp("mb_qmax","");
00485 AddProp("me_cmp","");
00486 AddProp("me_sub_cmp","");
00487 AddProp("mb_cmp","");
00488 AddProp("ildct_cmp","");
00489 AddProp("dia_size","");
00490 AddProp("last_predictor_count","");
00491 AddProp("pre_me","");
00492 AddProp("me_pre_cmp","");
00493 AddProp("pre_dia_size","");
00494 AddProp("me_subpel_quality","");
00495 AddProp("dtg_active_format","");
00496 AddProp("me_range","");
00497 AddProp("intra_quant_bias","");
00498 AddProp("inter_quant_bias","");
00499 AddProp("color_table_id","");
00500 AddProp("global_quality","");
00501 AddProp("coder_type","");
00502 AddProp("context_model","");
00503 AddProp("slice_flags","");
00504 AddProp("xvmc_acceleration","");
00505 AddProp("mb_decision","");
00506 AddProp("stream_codec_tag","");
00507 AddProp("scenechange_threshold","");
00508 AddProp("lmin","");
00509 AddProp("lmax","");
00510 AddProp("noise_reduction","");
00511 AddProp("rc_initial_buffer_occupancy","");
00512 AddProp("inter_threshold","");
00513 AddProp("flags2","");
00514 AddProp("error_rate","");
00515 AddProp("antialias_algo","");
00516 AddProp("quantizer_noise_shaping","");
00517 AddProp("thread_count","");
00518 AddProp("me_threshold","");
00519 AddProp("mb_threshold","");
00520 AddProp("intra_dc_precision","");
00521 AddProp("nsse_weight","");
00522 AddProp("skip_top","");
00523 AddProp("skip_bottom","");
00524 AddProp("profile","");
00525 AddProp("level","");
00526 AddProp("lowres","");
00527 AddProp("frame_skip_threshold","");
00528 AddProp("frame_skip_factor","");
00529 AddProp("frame_skip_exp","");
00530 AddProp("frame_skip_cmp","");
00531 AddProp("border_masking","");
00532 AddProp("mb_lmin","");
00533 AddProp("mb_lmax","");
00534 AddProp("me_penalty_compensation","");
00535 AddProp("skip_loop_filter","");
00536 AddProp("skip_idct","");
00537 AddProp("skip_frame","");
00538 AddProp("bidir_refine","");
00539 AddProp("brd_scale","");
00540 AddProp("crf","");
00541 AddProp("cqp","");
00542 AddProp("keyint_min","");
00543 AddProp("refs","");
00544 AddProp("chromaoffset","");
00545 AddProp("bframebias","");
00546 AddProp("trellis","");
00547 AddProp("complexityblur","");
00548 AddProp("deblockalpha","");
00549 AddProp("deblockbeta","");
00550 AddProp("partitions","");
00551 AddProp("directpred","");
00552 AddProp("cutoff","");
00553 AddProp("scenechange_factor","");
00554 #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(44<<8)+0)
00555 AddProp("mv0_threshold","");
00556 AddProp("b_sensitivity","");
00557 AddProp("compression_level","");
00558 AddProp("use_lpc","");
00559 AddProp("lpc_coeff_precision","");
00560 AddProp("min_prediction_order","");
00561 AddProp("max_prediction_order","");
00562 AddProp("prediction_order_method","");
00563 AddProp("min_partition_order","");
00564 AddProp("max_partition_order","");
00565 #endif
00566 }
00567 void
00568 Update(AVCodecContext* c){
00569 UpdateCtrl("bit_rate",c->bit_rate);
00570 UpdateCtrl("bit_rate_tolerance",c->bit_rate_tolerance);
00571 UpdateCtrl("flags",c->flags);
00572 UpdateCtrl("sub_id",c->sub_id);
00573 UpdateCtrl("me_method",c->me_method);
00574 UpdateCtrl("time_base",c->time_base);
00575 UpdateCtrl("width",c->width);
00576 UpdateCtrl("height",c->height);
00577 UpdateCtrl("gop_size",c->gop_size);
00578 UpdateCtrl("pix_fmt",c->pix_fmt);
00579 UpdateCtrl("rate_emu",c->rate_emu);
00580 UpdateCtrl("sample_rate",c->sample_rate);
00581 UpdateCtrl("channels",c->channels);
00582 UpdateCtrl("sample_fmt",c->sample_fmt);
00583 UpdateCtrl("frame_size",c->frame_size);
00584 UpdateCtrl("frame_number",c->frame_number);
00585 UpdateCtrl("real_pict_num",c->real_pict_num);
00586 UpdateCtrl("delay",c->delay);
00587 UpdateCtrl("qcompress",c->qcompress);
00588 UpdateCtrl("qblur",c->qblur);
00589 UpdateCtrl("qmin",c->qmin);
00590 UpdateCtrl("qmax",c->qmax);
00591 UpdateCtrl("max_qdiff",c->max_qdiff);
00592 UpdateCtrl("max_b_frames",c->max_b_frames);
00593 UpdateCtrl("b_quant_factor",c->b_quant_factor);
00594 UpdateCtrl("b_frame_strategy",c->b_frame_strategy);
00595 UpdateCtrl("hurry_up",c->hurry_up);
00596 UpdateCtrl("rtp_payload_size",c->rtp_payload_size);
00597 UpdateCtrl("mv_bits",c->mv_bits);
00598 UpdateCtrl("header_bits",c->header_bits);
00599 UpdateCtrl("i_tex_bits",c->i_tex_bits);
00600 UpdateCtrl("p_tex_bits",c->p_tex_bits);
00601 UpdateCtrl("i_count",c->i_count);
00602 UpdateCtrl("p_count",c->p_count);
00603 UpdateCtrl("skip_count",c->skip_count);
00604 UpdateCtrl("misc_bits",c->misc_bits);
00605 UpdateCtrl("frame_bits",c->frame_bits);
00606 UpdateCtrl("codec_name",c->codec_name);
00607 UpdateCtrl("codec_type",c->codec_type);
00608 UpdateCtrl("codec_id",c->codec_id);
00609 UpdateCtrl("codec_tag",c->codec_tag);
00610 UpdateCtrl("workaround_bugs",c->workaround_bugs);
00611 UpdateCtrl("luma_elim_threshold",c->luma_elim_threshold);
00612 UpdateCtrl("chroma_elim_threshold",c->chroma_elim_threshold);
00613 UpdateCtrl("strict_std_compliance",c->strict_std_compliance);
00614 UpdateCtrl("b_quant_offset",c->b_quant_offset);
00615 UpdateCtrl("error_resilience",c->error_resilience);
00616 UpdateCtrl("has_b_frames",c->has_b_frames);
00617 UpdateCtrl("block_align",c->block_align);
00618 UpdateCtrl("parse_only",c->parse_only);
00619 UpdateCtrl("mpeg_quant",c->mpeg_quant);
00620 UpdateCtrl("stats_out",c->stats_out);
00621 UpdateCtrl("stats_in",c->stats_in);
00622 UpdateCtrl("rc_qsquish",c->rc_qsquish);
00623 UpdateCtrl("rc_qmod_amp",c->rc_qmod_amp);
00624 UpdateCtrl("rc_qmod_freq",c->rc_qmod_freq);
00625 UpdateCtrl("rc_override_count",c->rc_override_count);
00626 UpdateCtrl("rc_eq",c->rc_eq);
00627 UpdateCtrl("rc_max_rate",c->rc_max_rate);
00628 UpdateCtrl("rc_min_rate",c->rc_min_rate);
00629 UpdateCtrl("rc_buffer_size",c->rc_buffer_size);
00630 UpdateCtrl("rc_buffer_aggressivity",c->rc_buffer_aggressivity);
00631 UpdateCtrl("i_quant_factor",c->i_quant_factor);
00632 UpdateCtrl("i_quant_offset",c->i_quant_offset);
00633 UpdateCtrl("rc_initial_cplx",c->rc_initial_cplx);
00634 UpdateCtrl("dct_algo",c->dct_algo);
00635 UpdateCtrl("lumi_masking",c->lumi_masking);
00636 UpdateCtrl("temporal_cplx_masking",c->temporal_cplx_masking);
00637 UpdateCtrl("spatial_cplx_masking",c->spatial_cplx_masking);
00638 UpdateCtrl("p_masking",c->p_masking);
00639 UpdateCtrl("dark_masking",c->dark_masking);
00640 UpdateCtrl("unused",c->unused);
00641 UpdateCtrl("idct_algo",c->idct_algo);
00642 UpdateCtrl("slice_count",c->slice_count);
00643 UpdateCtrl("slice_offset",c->slice_offset);
00644 UpdateCtrl("error_concealment",c->error_concealment);
00645 UpdateCtrl("dsp_mask",c->dsp_mask);
00646 UpdateCtrl("bits_per_sample",c->bits_per_sample);
00647 UpdateCtrl("prediction_method",c->prediction_method);
00648 UpdateCtrl("sample_aspect_ratio",c->sample_aspect_ratio);
00649 UpdateCtrl("debug",c->debug);
00650 UpdateCtrl("debug_mv",c->debug_mv);
00651 UpdateCtrl("error",c->error);
00652 UpdateCtrl("mb_qmin",c->mb_qmin);
00653 UpdateCtrl("mb_qmax",c->mb_qmax);
00654 UpdateCtrl("me_cmp",c->me_cmp);
00655 UpdateCtrl("me_sub_cmp",c->me_sub_cmp);
00656 UpdateCtrl("mb_cmp",c->mb_cmp);
00657 UpdateCtrl("ildct_cmp",c->ildct_cmp);
00658 UpdateCtrl("dia_size",c->dia_size);
00659 UpdateCtrl("last_predictor_count",c->last_predictor_count);
00660 UpdateCtrl("pre_me",c->pre_me);
00661 UpdateCtrl("me_pre_cmp",c->me_pre_cmp);
00662 UpdateCtrl("pre_dia_size",c->pre_dia_size);
00663 UpdateCtrl("me_subpel_quality",c->me_subpel_quality);
00664 UpdateCtrl("dtg_active_format",c->dtg_active_format);
00665 UpdateCtrl("me_range",c->me_range);
00666 UpdateCtrl("intra_quant_bias",c->intra_quant_bias);
00667 UpdateCtrl("inter_quant_bias",c->inter_quant_bias);
00668 UpdateCtrl("color_table_id",c->color_table_id);
00669 UpdateCtrl("internal_buffer_count",c->internal_buffer_count);
00670 UpdateCtrl("global_quality",c->global_quality);
00671 UpdateCtrl("coder_type",c->coder_type);
00672 UpdateCtrl("context_model",c->context_model);
00673 UpdateCtrl("slice_flags",c->slice_flags);
00674 UpdateCtrl("xvmc_acceleration",c->xvmc_acceleration);
00675 UpdateCtrl("mb_decision",c->mb_decision);
00676 UpdateCtrl("stream_codec_tag",c->stream_codec_tag);
00677 UpdateCtrl("scenechange_threshold",c->scenechange_threshold);
00678 UpdateCtrl("lmin",c->lmin);
00679 UpdateCtrl("lmax",c->lmax);
00680 UpdateCtrl("noise_reduction",c->noise_reduction);
00681 UpdateCtrl("rc_initial_buffer_occupancy",c->rc_initial_buffer_occupancy);
00682 UpdateCtrl("inter_threshold",c->inter_threshold);
00683 UpdateCtrl("flags2",c->flags2);
00684 UpdateCtrl("error_rate",c->error_rate);
00685 UpdateCtrl("antialias_algo",c->antialias_algo);
00686 UpdateCtrl("quantizer_noise_shaping",c->quantizer_noise_shaping);
00687 UpdateCtrl("thread_count",c->thread_count);
00688 UpdateCtrl("me_threshold",c->me_threshold);
00689 UpdateCtrl("mb_threshold",c->mb_threshold);
00690 UpdateCtrl("intra_dc_precision",c->intra_dc_precision);
00691 UpdateCtrl("nsse_weight",c->nsse_weight);
00692 UpdateCtrl("skip_top",c->skip_top);
00693 UpdateCtrl("skip_bottom",c->skip_bottom);
00694 UpdateCtrl("profile",c->profile);
00695 UpdateCtrl("level",c->level);
00696 UpdateCtrl("lowres",c->lowres);
00697 UpdateCtrl("coded_width",c->coded_width);
00698 UpdateCtrl("coded_height",c->coded_height);
00699 UpdateCtrl("frame_skip_threshold",c->frame_skip_threshold);
00700 UpdateCtrl("frame_skip_factor",c->frame_skip_factor);
00701 UpdateCtrl("frame_skip_exp",c->frame_skip_exp);
00702 UpdateCtrl("frame_skip_cmp",c->frame_skip_cmp);
00703 UpdateCtrl("border_masking",c->border_masking);
00704 UpdateCtrl("mb_lmin",c->mb_lmin);
00705 UpdateCtrl("mb_lmax",c->mb_lmax);
00706 UpdateCtrl("me_penalty_compensation",c->me_penalty_compensation);
00707 UpdateCtrl("skip_loop_filter",c->skip_loop_filter);
00708 UpdateCtrl("skip_idct",c->skip_idct);
00709 UpdateCtrl("skip_frame",c->skip_frame);
00710 UpdateCtrl("bidir_refine",c->bidir_refine);
00711 UpdateCtrl("brd_scale",c->brd_scale);
00712 UpdateCtrl("crf",c->crf);
00713 UpdateCtrl("cqp",c->cqp);
00714 UpdateCtrl("keyint_min",c->keyint_min);
00715 UpdateCtrl("refs",c->refs);
00716 UpdateCtrl("chromaoffset",c->chromaoffset);
00717 UpdateCtrl("bframebias",c->bframebias);
00718 UpdateCtrl("trellis",c->trellis);
00719 UpdateCtrl("complexityblur",c->complexityblur);
00720 UpdateCtrl("deblockalpha",c->deblockalpha);
00721 UpdateCtrl("deblockbeta",c->deblockbeta);
00722 UpdateCtrl("partitions",c->partitions);
00723 UpdateCtrl("directpred",c->directpred);
00724 UpdateCtrl("cutoff",c->cutoff);
00725 UpdateCtrl("scenechange_factor",c->scenechange_factor);
00726 #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(44<<8)+0)
00727 UpdateCtrl("mv0_threshold",c->mv0_threshold);
00728 UpdateCtrl("b_sensitivity",c->b_sensitivity);
00729 UpdateCtrl("compression_level",c->compression_level);
00730 UpdateCtrl("use_lpc",c->use_lpc);
00731 UpdateCtrl("lpc_coeff_precision",c->lpc_coeff_precision);
00732 UpdateCtrl("min_prediction_order",c->min_prediction_order);
00733 UpdateCtrl("max_prediction_order",c->max_prediction_order);
00734 UpdateCtrl("prediction_order_method",c->prediction_order_method);
00735 UpdateCtrl("min_partition_order",c->min_partition_order);
00736 UpdateCtrl("max_partition_order",c->max_partition_order);
00737 UpdateCtrl("timecode_frame_start",c->timecode_frame_start);
00738 #endif
00739
00740 }
00742
00743 };
00744 class AVFrameDD:public PropertyHolder{
00745 public:
00746 AVFrameDD(Window* parent,int width,int height,std::string Name="AVFrame")
00747 :PropertyHolder(parent,width,height,Name)
00748 {
00749 AddProp("key_frame","");
00750 AddProp("pict_type","");
00751 AddProp("reference","");
00752 AddProp("coded_picture_number","");
00753 AddProp("display_picture_number","");
00754 AddProp("pts","");
00755 AddProp("quality","");
00756 AddProp("age","");
00757 AddProp("qstride","");
00758 AddProp("type","");
00759 AddProp("repeat_pict","");
00760 AddProp("qscale_type","");
00761 AddProp("interlaced_frame","");
00762 AddProp("top_field_first","");
00763 AddProp("palette_has_changed","");
00764 }
00765 void Update(AVFrame* f){
00766 UpdateCtrl("key_frame",f->key_frame);
00767 UpdateCtrl("pict_type",FRAME_TYPE(f->pict_type));
00768 UpdateCtrl("pts",f->pts);
00769 UpdateCtrl("coded_picture_number",f->coded_picture_number);
00770 UpdateCtrl("display_picture_number",f->display_picture_number);
00771 UpdateCtrl("quality",f->quality);
00772 UpdateCtrl("age",f->age);
00773 UpdateCtrl("reference",f->reference);
00774 UpdateCtrl("qstride",f->qstride);
00775 UpdateCtrl("type",f->type);
00776 UpdateCtrl("repeat_pict",f->repeat_pict);
00777 UpdateCtrl("qscale_type",f->qscale_type);
00778 UpdateCtrl("interlaced_frame",f->interlaced_frame);
00779 UpdateCtrl("top_field_first",f->top_field_first);
00780 UpdateCtrl("palette_has_changed",f->palette_has_changed);
00781 }
00782
00783 };
00784
00785 class DropDownList:public DropDownWindow,public StringListener{
00786 public:
00787 DropDownList(Window* W,int x,int y,int w, int h,std::string head)
00788 :mList(0),
00789 mCurSelection(0),
00790 DropDownWindow(W,x,y,w,h,head,0){
00791
00792 mList = new StringSelector(this,w-10,160);
00793 mList->SetStringListener(this,0);
00794
00795 AddWindow(mList,5);
00796 HeaderText()->SetAlign(oglLeftAlign, oglCenterAlign);
00797 HeaderWindow()->SetBorderType(BEV_ETCHED);
00798 }
00799
00800 void AddString(std::string s){
00801 mList->AddString(s);
00802 }
00803
00804 void SetDefault(int strIndex){
00805 mCurSelection = strIndex;
00806 HeaderText()->SetText(mList->GetString(strIndex));
00807 }
00808 void
00809 StringSelectionEvent(StringSelector *src, int strIndex, void* listenerData)
00810 {
00811 mCurSelection = strIndex;
00812 HeaderText()->SetText(src->GetString(strIndex));
00813 DropDown(false);
00814 }
00815
00816 virtual void
00817 WindowMouseEvent(Window *src, int msg, int but, int state, int x, int y,
00818 void* listenerData)
00819 {
00820 if (but==oglLeftButton)
00821 {
00822 if ((msg == oglMouseDown)||( msg == oglMouseDblClick))
00823 DropDown(!IsDropped());
00824 }
00825 }
00826 int GetCurSel(){
00827 return mCurSelection;
00828 }
00829
00830 StringSelector* mList;
00831 int mCurSelection;
00832 };
00833
00834
00835 class FFMPEGControl:public Window,public ButtonListener{
00836 public:
00837 FFMPEGControl(Window* W,int w, int h,RgbDataSrcLavc* src,AppControlSrc* ctrl)
00838 :Window(W,w,h)
00839 {
00840 mCtrl=ctrl;
00841 mSrc=src;
00842 mSeekFrmField = new TextField(this,20,h-40,80,20,"");
00843 mSeekPosField = new TextField(this,20,h-80,80,20,"");
00844 mSeekFlags = new DropDownList(this,20,h-120,130,20,"CHOOSE SEEK FLAGS");
00845 mFlushCodec = new DropDownList(this,170,h-120,130,20,"FLUSH CODEC?");
00846 mSyncFrame = new DropDownList(this,320,h-120,130,20,"SYNC FRAME");
00847
00848 mSeekFlags->AddString("NONE");
00849 mSeekFlags->AddString("BACKWARD");
00850 mSeekFlags->AddString("BYTE");
00851 mSeekFlags->AddString("BYTE & BACKWARD");
00852 mSeekFlags->AddString("ANY");
00853 mSeekFlags->AddString("ANY & BACKWARD");
00854 mSeekFlags->AddString("ANY & BYTE");
00855 mSeekFlags->AddString("ANY & BYTE & BACKWARD");
00856 (new Button(this,350,h-40,100,20,"JUMP"))
00857 ->SetButtonListener(this,0);
00858 (new Button(this,350,h-80,100,20,"SEEK"))
00859 ->SetButtonListener(this,1);
00860 (new Button(this,350,h-160,100,20,"NEXT"))
00861 ->SetButtonListener(this,3);
00862 (new Button(this,350,h-200,100,20,"RESET"))
00863 ->SetButtonListener(this,2);
00864 mFlushCodec->AddString("NONE");
00865 mFlushCodec->AddString("BEFORE");
00866 mFlushCodec->AddString("AFTER");
00867 mFlushCodec->AddString("BEFORE & AFTER");
00868 mSyncFrame->AddString("NONE");
00869 mSyncFrame->AddString("FRAME");
00870 mSyncFrame->AddString("KEYFRAME");
00871 mSeekFlags->SetDefault(2);
00872 mFlushCodec->SetDefault(2);
00873 mSyncFrame->SetDefault(2);
00874 SetBackground(oglTrLIGHTGREEN);
00875
00876
00877
00878
00879
00880 }
00881 void ButtonSelectionEvent(Button *src, void* vData)
00882 {
00883 int userData = (long long) vData;
00884 switch(userData){
00885 case 0:
00886 {
00887 int frm;
00888 std::istringstream iss(mSeekFrmField->GetText());
00889 if(iss.str()=="")
00890 break;
00891 iss >> frm;
00892 if(iss.fail()){
00893 mSeekPosField->SetText("");
00894 break;
00895 }
00896 mSrc->GotoFrame(frm) ;
00897
00898
00899 break;
00900 }
00901
00902 case 1:
00903 {
00904 int64_t pos;
00905 std::istringstream iss(mSeekPosField->GetText());
00906 if(iss.str()=="")
00907 break;
00908 iss >> pos;
00909 if(iss.fail())
00910 mSeekPosField->SetText("");
00911 else
00912 mSrc->Jump(pos,mSeekFlags->GetCurSel(),mFlushCodec->GetCurSel(),mSyncFrame->GetCurSel());
00913
00914
00915 break;
00916 }
00917
00918 case 2:
00919 mSrc->Jump(0,2,true);
00920
00921 break;
00922
00923 case 3:
00924 mSrc->NextFrame();
00925 break;
00926
00927 }
00928 mCtrl->HandleNewFrame();
00929 }
00930 DropDownList* mSeekFlags;
00931 TextField* mSeekPosField;
00932 TextField* mSeekFrmField;
00933 DropDownList* mFlushCodec;
00934 DropDownList* mSyncFrame;
00935 RgbDataSrcLavc* mSrc;
00936 AppControlSrc* mCtrl;
00937 };
00938 class RgbDataSrcLavcTestGUI : public Window, public AppControlSrc,
00939 public VideoNavListener, public OglGui::ViewListener
00940 {
00941 VideoNav* mVideoNav;
00942 DropDownWindow* mDropDown;
00943 AVFormatDD *mDDFormat;
00944 AVCodecDD *mDDCodec;
00945 AVFrameDD* mDDFrame;
00946 AVStreamDD* mDDStream;
00947 AVPacketDD* mDDPacket;
00948
00949 StaticText* mStaticText;
00950 PropertySheet* mFPropSheet,*mCPropSheet,
00951 *mFrPropSheet,*mSPropSheet,*mPPropSheet;
00952 RgbDataSrcLavc* mLavcsrc;
00953 VideoSet* mVideoSet;
00954 FFMPEGControl* mVideoCtrl;
00955 Tabs* mTabs;
00956
00957 private:
00958 ILOG_VAR_DEC;
00959
00960 public:
00961
00962 RgbDataSrcLavcTestGUI(int x, int y, bool doZoom, bool mainIs2d,
00963 bool vpIs2d,RgbDataSrcLavc* src)
00964 : Window(x, y, 1280, SuggestWndHeight(1, src->FrameHeight()+550),
00965 mainIs2d),
00966 AppControlSrc(1)
00967 {
00968
00969 CmdOptions& options = CmdOptions::GetInstance();
00970
00971
00972 SetSource(src);
00973 mLavcsrc=src;
00974 SetForeground(oglDARKGREY);
00975 SetBackground(oglLIGHTGREY);
00976 mTabs = new Tabs(this, src->FrameWidth()+20, src->FrameHeight()+70);
00977
00978 mVideoNav = new VideoNav(mTabs->CreateTab("Video", 80), src);
00979 mVideoNav->SetVideoNavListener(this);
00980
00981
00982
00983
00984
00985
00986
00987 mTabs->SetActiveTab(0);
00988
00989
00990
00991 mVideoCtrl=new FFMPEGControl(this,W()-src->FrameWidth()-50,70+src->FrameHeight(),src,this);
00992 mFPropSheet = new PropertySheet(this, 250, 500);
00993 mCPropSheet = new PropertySheet(this, 250, 500);
00994 mFrPropSheet= new PropertySheet(this, 250, 500);
00995 mSPropSheet = new PropertySheet(this, 250, 500);
00996 mPPropSheet = new PropertySheet(this, 250, 500);
00997
00998
00999
01000
01001
01002 OglGui::Window* content = mFPropSheet->ContentPane();
01003 content->SetDimensions(0, 0, 250, 4000);
01004 mDDFormat = new AVFormatDD(content,240,20,"Format Context");
01005
01006 content = mCPropSheet->ContentPane();
01007 content->SetDimensions(0, 0, 250, 4000);
01008 mDDCodec = new AVCodecDD(content,240,20,"CodecContext");
01009
01010 content = mFrPropSheet->ContentPane();
01011 content->SetDimensions(0, 0, 250, 4000);
01012 mDDFrame = new AVFrameDD(content,240,20,"Frame");
01013
01014 content = mSPropSheet->ContentPane();
01015 content->SetDimensions(0, 0, 250, 4000);
01016 mDDStream = new AVStreamDD(content,240,20,"Stream");
01017
01018 content = mPPropSheet->ContentPane();
01019 content->SetDimensions(0, 0, 250, 4000);
01020 mDDPacket = new AVPacketDD(content,240,20,"Packet");
01021
01022 mVideoSet = MakeVideoSet(src->GetName());
01023 mVideoCtrl->SetBackground(oglTrLIGHTGREEN);
01024
01025
01026
01027 #ifdef OGL_USING_GLUT
01028 SetAlwaysDraw();
01029 #endif
01030 AppController::Instance().MainLoop();
01031
01032 }
01033
01034 void TempTest(){
01035
01036
01037 ILOG_INFO("Starting");
01038 mLavcsrc->NextFrame();
01039 for (int i=168626;i<294912;i++){
01040
01041 mLavcsrc->Jump(i,AVSEEK_FLAG_BYTE,2,2);
01042
01043 if(mLavcsrc->IsFrameAccurate())
01044 {
01045 std::cout<<"Success @ "<<i<<std::endl;
01046 }else{
01047 std::cout<<"No Success @ "<<i<<std::endl;
01048 }
01049 }
01050 exit(0);
01051
01052 }
01053
01054 void SetSource(RgbDataSrc* src){
01055 SetSrc(src);
01056 AppController::Instance().AddControl((AppControlSrc*) this, true);
01057 }
01058
01059 void
01060 MainLoop(){
01061 AppController::Instance().MainLoop();
01062 }
01063
01064 void
01065 HandleCycleSrc()
01066 {
01067 UpdateScene();
01068 SetStatusStr((char*) GetFpsString().c_str());
01069 }
01070
01071 void
01072 HandleDestroyEvent()
01073 {
01074
01075 }
01076
01077 void
01078 HandleNewFrame()
01079 {
01080 Array2dVec3UInt8* rgb = ArrayCreate<Array2dVec3UInt8>
01081 (GetSrc()->FrameWidth(), GetSrc()->FrameHeight(),
01082 0, 0,GetSrc()->DataPtr(),true);
01083
01084 mVideoNav->UpdateView(0,rgb,"");
01085 mDDFormat->Update(mLavcsrc->GetFormatCtx());
01086 mDDCodec->Update(mLavcsrc->GetCodecCtx());
01087 mDDFrame->Update(mLavcsrc->GetFrameCtx());
01088 mDDStream->Update(mLavcsrc->GetStream());
01089 mDDPacket->Update(mLavcsrc->GetPacket());
01090
01091 if(mLavcsrc->IsFrameAccurate())
01092 {
01093
01094 }else{
01095 mVideoCtrl->SetBackground(oglTrLIGHTRED);
01096 }
01097 delete rgb;
01098 }
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146 void
01147 NavFrameEvent(VideoNav* src, int requestedFrame, void* listenerData)
01148 {
01149 Jump(requestedFrame);
01150 }
01151
01152 virtual void
01153 OnViewMouse(OglGui::View* view, int msg, int btn, int state,
01154 float x, float y)
01155 {
01156 }
01157
01158
01159 };
01160 ILOG_VAR_INIT(RgbDataSrcLavcTestGUI,Impala.Visualization);
01161 }
01162 }
01163 #endif